Purity.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using OTSCLRINTERFACE;
  2. using OTSCommon;
  3. using OTSIncAReportApp.OTSRstMgrFunction;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace OTSIncAReportApp._1_UI.GBCalculate
  15. {
  16. public partial class Purity : Form
  17. {
  18. #region 全局变量
  19. OTSIncAReportApp.frmReportApp m_ReportApp = null;
  20. DataTable Table = new DataTable();
  21. /// <summary>
  22. /// 权重比重
  23. /// </summary>
  24. readonly Dictionary<string, double> weightFactor = new Dictionary<string, double>()
  25. {
  26. { "0.5",0.05 },
  27. { "1",0.1 },
  28. {"1.5",0.2 },
  29. {"2",0.5 },
  30. {"2.5",1 },
  31. {"3",2 },
  32. {"3.5",5 },
  33. {"4",10 },
  34. {"4.5",20},
  35. {"5",50 }
  36. };
  37. Language lan;
  38. Hashtable table;
  39. #endregion
  40. public Purity(OTSIncAReportApp.frmReportApp a_ReportApp)
  41. {
  42. InitializeComponent();
  43. m_ReportApp = a_ReportApp;
  44. cBox_gride.DataSource=new string[] { "0.5", "1", "1.5", "2", "2.5", "3", "3.5", "4", "4.5", "5" };
  45. cBox_gride.SelectedIndex=0;
  46. rBx_process.Font = new Font(rBx_process.Font.FontFamily, 15);
  47. lan = new Language(this);
  48. table = lan.GetNameTable(this.Name);
  49. }
  50. private void Purity_Load(object sender, EventArgs e)
  51. {
  52. InitTable(Table);
  53. pictureBox_PurityFormula.Image = Properties.Resources.PurityFormula;
  54. }
  55. void InitTable(DataTable Table)
  56. {
  57. Table.Columns.Add("0.5", typeof(int));
  58. Table.Columns.Add("1", typeof(int));
  59. Table.Columns.Add("1.5", typeof(int));
  60. Table.Columns.Add("2", typeof(int));
  61. Table.Columns.Add("2.5", typeof(int));
  62. Table.Columns.Add("3", typeof(int));
  63. Table.Columns.Add("3.5", typeof(int));
  64. Table.Columns.Add("4", typeof(int));
  65. Table.Columns.Add("4.5", typeof(int));
  66. Table.Columns.Add("5", typeof(int));
  67. Table.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0,0);
  68. }
  69. private void btn_cal_Click(object sender, EventArgs e)
  70. {
  71. Table.Rows.Clear();
  72. Table.Rows.Add(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  73. tB_result.Text = "";this.Refresh();
  74. Cursor = Cursors.WaitCursor;
  75. rBx_process.Text = "";
  76. int index = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListIndexByItemName(OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  77. for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
  78. {
  79. string anothername = m_ReportApp.m_rstDataMgr.ResultFilesList[i].anotherFileName.ToString();
  80. string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[i].FilePath.ToString() + "\\" + m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName_real.ToString();
  81. m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile, anothername);
  82. }
  83. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  84. List<string> datasourcelist = m_ReportApp.m_conditionChoose.m_conditionData.GetComboDownListByItemName(OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE);
  85. clr_prop.SetDataSourceList(datasourcelist);
  86. clr_prop.SetDataSourceId(index);
  87. clr_prop.SetType((int)OTSSampleReportInfo.DisplayPicutureType.AnalyzeDataTable);//table
  88. clr_prop.SetCalTableType((int)OTSSampleReportInfo.CALCULATE_TABLE_TYPE.GB_Method1);
  89. DataTable tbl = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetAllGBFields(clr_prop);
  90. if (tbl != null)
  91. {
  92. foreach (DataRow row in tbl.Rows)
  93. {
  94. string[] str = Convert.ToString(row["grade"]).Split(' ');
  95. for (int i = 0; i < str.Length; i++)
  96. {
  97. if (str[i].Contains(":"))
  98. {
  99. str[i] = Convert.ToString(str[i].Split(':')[1]);
  100. }
  101. switch (str[i])
  102. {
  103. case "0.5":
  104. Table.Rows[0]["0.5"] = Convert.ToInt64(Table.Rows[0]["0.5"]) + 1;
  105. break;
  106. case "1.0":
  107. Table.Rows[0]["1"] = Convert.ToInt64(Table.Rows[0]["1"]) + 1;
  108. break;
  109. case "1.5":
  110. Table.Rows[0]["1.5"] = Convert.ToInt64(Table.Rows[0]["1.5"]) + 1;
  111. break;
  112. case "2.0":
  113. Table.Rows[0]["2"] = Convert.ToInt64(Table.Rows[0]["2"]) + 1;
  114. break;
  115. case "2.5":
  116. Table.Rows[0]["2.5"] = Convert.ToInt64(Table.Rows[0]["2.5"]) + 1;
  117. break;
  118. case "3.0":
  119. Table.Rows[0]["3"] = Convert.ToInt64(Table.Rows[0]["3"]) + 1;
  120. break;
  121. case "3.5":
  122. Table.Rows[0]["3.5"] = Convert.ToInt64(Table.Rows[0]["3.5"]) + 1;
  123. break;
  124. case "4.0":
  125. Table.Rows[0]["4"] = Convert.ToInt64(Table.Rows[0]["4"]) + 1;
  126. break;
  127. case "4.5":
  128. Table.Rows[0]["4.5"] = Convert.ToInt64(Table.Rows[0]["4.5"]) + 1;
  129. break;
  130. case "5.0":
  131. Table.Rows[0]["5"] = Convert.ToInt64(Table.Rows[0]["5"]) + 1;
  132. break;
  133. default:
  134. break;
  135. }
  136. }
  137. }
  138. }
  139. rBx_process.AppendText("经国标方法1评级后数据统计如下:\n");
  140. string r1 = "";
  141. string r2 = "K=( ";
  142. double K = 0;
  143. for (int i= cBox_gride.SelectedIndex;i< Table.Columns.Count; i++)
  144. {
  145. K += weightFactor[Convert.ToString(cBox_gride.SelectedItem)] * Convert.ToInt64(Table.Rows[0][i]);
  146. r1 += cBox_gride.Items[i].ToString() + "级视场数:" + Table.Rows[0][i].ToString()+"\n";
  147. r2 += weightFactor[Convert.ToString(cBox_gride.Items[i])].ToString() + " * " + Table.Rows[0][i].ToString() + " + ";
  148. }
  149. r2 = r2.Remove(r2.Length - 2, 2);
  150. r2 += ")";
  151. double area = tbl.Rows.Count*0.5;
  152. K = K * 1000 / area;
  153. tB_result.Text = (Math.Round(K, 3).ToString());
  154. r1 += "总检验面积:" + area.ToString() + "\n";
  155. r2 += "* 1000 /" + area.ToString();
  156. rBx_process.AppendText(r1 + "\n");
  157. rBx_process.AppendText("代入公式计算:\n");
  158. rBx_process.AppendText(r2 + "\n");
  159. rBx_process.AppendText("K = "+ K.ToString());
  160. this.Refresh();
  161. this.Cursor= Cursors.Default;
  162. }
  163. }
  164. }