using OTSCLRINTERFACE;
using OTSCommon;
using OTSIncAReportApp.OTSRstMgrFunction;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OTSIncAReportApp._1_UI.GBCalculate
{
public partial class Purity : Form
{
#region 全局变量
OTSIncAReportApp.frmReportApp m_ReportApp = null;
DataTable Table = new DataTable();
///
/// 权重比重
///
readonly Dictionary weightFactor = new Dictionary()
{
{ "0.5",0.05 },
{ "1",0.1 },
{"1.5",0.2 },
{"2",0.5 },
{"2.5",1 },
{"3",2 },
{"3.5",5 },
{"4",10 },
{"4.5",20},
{"5",50 }
};
Language lan;
Hashtable table;
#endregion
public Purity(OTSIncAReportApp.frmReportApp a_ReportApp)
{
InitializeComponent();
m_ReportApp = a_ReportApp;
cBox_gride.DataSource=new string[] { "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5" };
cBox_gride.SelectedIndex=0;
rBx_process.Font = new Font(rBx_process.Font.FontFamily, 15);
lan = new Language(this);
table = lan.GetNameTable(this.Name);
}
private void Purity_Load(object sender, EventArgs e)
{
InitTable(Table);
pictureBox_PurityFormula.Image = Properties.Resources.PurityFormula;
}
void InitTable(DataTable Table)
{
Table.Columns.Add("0.5", typeof(int));
Table.Columns.Add("1", typeof(int));
Table.Columns.Add("1.5", typeof(int));
Table.Columns.Add("2", typeof(int));
Table.Columns.Add("2.5", typeof(int));
Table.Columns.Add("3", typeof(int));
Table.Columns.Add("3.5", typeof(int));
Table.Columns.Add("4", typeof(int));
Table.Columns.Add("4.5", typeof(int));
Table.Columns.Add("5", typeof(int));
Table.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0,0);
}
private void btn_cal_Click(object sender, EventArgs e)
{
Table.Rows.Clear();
Table.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
tB_result.Text = "";this.Refresh();
Cursor = Cursors.WaitCursor;
rBx_process.Text = "";
int index = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
{
string anothername = m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath.ToString() + "\\" + m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName_real.ToString();
m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
}
OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
List datasourcelist = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
clr_prop.SetDataSourceList(datasourcelist);
clr_prop.SetDataSourceId(index);
clr_prop.SetType((int)OTSSampleReportInfo.DisplayPicutureType.AnalyzeDataTable);//table
clr_prop.SetCalTableType((int)OTSSampleReportInfo.CALCULATE_TABLE_TYPE.GB_Method1);
DataTable tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
if (tbl != null)
{
foreach (DataRow row in tbl.Rows)
{
string[] str = Convert.ToString(row["grade"]).Split(' ');
for (int i = 0; i < str.Length; i++)
{
if (str[i].Contains(":"))
{
str[i] = Convert.ToString(str[i].Split(':')[1]);
}
switch (str[i])
{
case "0.5":
Table.Rows[0]["0.5"] = Convert.ToInt64(Table.Rows[0]["0.5"]) + 1;
break;
case "1.0":
Table.Rows[0]["1"] = Convert.ToInt64(Table.Rows[0]["1"]) + 1;
break;
case "1.5":
Table.Rows[0]["1.5"] = Convert.ToInt64(Table.Rows[0]["1.5"]) + 1;
break;
case "2.0":
Table.Rows[0]["2"] = Convert.ToInt64(Table.Rows[0]["2"]) + 1;
break;
case "2.5":
Table.Rows[0]["2.5"] = Convert.ToInt64(Table.Rows[0]["2.5"]) + 1;
break;
case "3.0":
Table.Rows[0]["3"] = Convert.ToInt64(Table.Rows[0]["3"]) + 1;
break;
case "3.5":
Table.Rows[0]["3.5"] = Convert.ToInt64(Table.Rows[0]["3.5"]) + 1;
break;
case "4.0":
Table.Rows[0]["4"] = Convert.ToInt64(Table.Rows[0]["4"]) + 1;
break;
case "4.5":
Table.Rows[0]["4.5"] = Convert.ToInt64(Table.Rows[0]["4.5"]) + 1;
break;
case "5.0":
Table.Rows[0]["5"] = Convert.ToInt64(Table.Rows[0]["5"]) + 1;
break;
default:
break;
}
}
}
}
rBx_process.AppendText("经国标方法1评级后数据统计如下:\n");
string r1 = "";
string r2 = "K=( ";
double K = 0;
for (int i= cBox_gride.SelectedIndex;i< Table.Columns.Count; i++)
{
K += weightFactor[Convert.ToString(cBox_gride.SelectedItem)] * Convert.ToInt64(Table.Rows[0][i]);
r1 += cBox_gride.Items[i].ToString() + "级视场数:" + Table.Rows[0][i].ToString()+"\n";
r2 += weightFactor[Convert.ToString(cBox_gride.Items[i])].ToString() + " * " + Table.Rows[0][i].ToString() + " + ";
}
r2 = r2.Remove(r2.Length - 2, 2);
r2 += ")";
double area = tbl.Rows.Count*0.5;
K = K * 1000 / area;
tB_result.Text = (Math.Round(K, 3).ToString());
r1 += "总检验面积:" + area.ToString() + "\n";
r2 += "* 1000 /" + area.ToString();
rBx_process.AppendText(r1 + "\n");
rBx_process.AppendText("代入公式计算:\n");
rBx_process.AppendText(r2 + "\n");
rBx_process.AppendText("K = "+ K.ToString());
this.Refresh();
this.Cursor= Cursors.Default;
}
}
}