QcmZgResampleFrm.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.Judge.Commons;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. namespace Core.StlMes.Client.Judge.Forms
  12. {
  13. public partial class QcmZgResampleFrm : FrmBase
  14. {
  15. private Dal _d;
  16. private string _checkNo = "";
  17. private DataRow _consign;
  18. public QcmZgResampleFrm(OpeBase ob, DataRow consign)
  19. {
  20. InitializeComponent();
  21. _d = new Dal(ob);
  22. _consign = consign;
  23. _checkNo = consign["checkNo"].ToString();
  24. Query();
  25. }
  26. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  27. {
  28. switch (e.Tool.Key)
  29. {
  30. case "确认":
  31. ApplyResample();
  32. break;
  33. }
  34. }
  35. private void ApplyResample()
  36. {
  37. List<string> jsons = new List<string>();
  38. var chkRows = ultraGrid1.Rows.Where(a => a.GetValue("chk") == "True");
  39. if (chkRows.Count() == 0)
  40. {
  41. MessageUtil.ShowWarning("请至少勾选一条记录!");
  42. return;
  43. }
  44. foreach (DataRow row in dataTable1.Rows)
  45. {
  46. if (row["chk"].ToString() == "True")
  47. {
  48. if (row["sampleCount"].ToString() == "")
  49. {
  50. MessageUtil.ShowWarning("请输入管头个数!");
  51. return;
  52. }
  53. jsons.Add(JsonHelper.ToJson(row));
  54. }
  55. }
  56. if (MessageUtil.ShowYesNoAndQuestion("是否确认进行此操作?") == System.Windows.Forms.DialogResult.No)
  57. {
  58. return;
  59. }
  60. CoreClientParam ccp = _d.Set("com.steering.pss.judge.Bll.BllRolledTubePhyJudge.applyResample",
  61. new object[] { _checkNo, UserInfo.GetUserName(), jsons });
  62. if (ccp.ReturnInfo != "")
  63. {
  64. MessageUtil.ShowWarning(ccp.ReturnInfo);
  65. }
  66. else
  67. {
  68. MessageUtil.ShowTips("确认成功!");
  69. }
  70. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  71. }
  72. private void Query()
  73. {
  74. string ordLnDlyPk = _consign["ordLnDlyPk"].ToString();
  75. string craftSeq = _consign["craftSeq"].ToString();
  76. string craftSource = _consign["craftSource"].ToString();
  77. string mscPline = _consign["indexSeq"].ToString();
  78. string processCode = _consign["processCode"].ToString();
  79. string pic = _consign["pic"].ToString();
  80. string judgeStoveNo = _consign["judgeStoveNo"].ToString();
  81. string batchNo = _consign["batchNo"].ToString();
  82. string lotNo = _consign["lotNo"].ToString();
  83. string lotNoGroup = _consign["lotNoGroup"].ToString();
  84. //获取所有已委托的试样组
  85. DataTable dtBatchNo = _d.GetTableByXmlId("JdgQcmZcCheckConsignDetail.getAllByCheckNo", _checkNo);
  86. for (int i = dtBatchNo.Rows.Count - 1; i >= 0; i--)
  87. {
  88. if (dtBatchNo.Rows[i]["phyCodeMin"].ToString() == "HX" || dtBatchNo.Rows[i]["phyCodeMin"].ToString() == "ONH")
  89. {
  90. dtBatchNo.Rows.Remove(dtBatchNo.Rows[i]);
  91. }
  92. }
  93. dtBatchNo.AcceptChanges();
  94. DataTable dtChemFailed = _d.GetTableByXmlId("QcmBcPhyresultDAL.getChemResampleData", new object[] { _checkNo });
  95. GridHelper.CopyDataToDatatable(dtChemFailed, dtBatchNo, false);
  96. dtBatchNo.DefaultView.Sort = "judgeStoveNo, batchNo, nkResult, phyNameMin";
  97. GridHelper.CopyDataToDatatable(dtBatchNo.DefaultView.ToTable(), dataTable1, true);
  98. //DataTable dtJudgeStoveNo = _d.GetTableByXmlId("JdgQcmZcCheckConsignDetail.getAllByJudgeStoveNo", judgeStoveNo, batchNo, ordLnDlyPk);
  99. //GridHelper.CopyDataToDatatable(dtJudgeStoveNo, dataTable1, false);
  100. //DataTable dtLotNo = _d.GetTableByXmlId("JdgQcmZcCheckConsignDetail.getAllByLotNo", judgeStoveNo, batchNo, ordLnDlyPk);
  101. //GridHelper.CopyDataToDatatable(dtLotNo, dataTable1, false);
  102. //DataTable dt = _d.GetTableByXmlId("QcmBcPhyresultDAL.getResampleData",
  103. // new object[] { _checkNo });
  104. //GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  105. DataTable dtNo = _d.GetTable("com.steering.pss.judge.Bll.BllRolledTubePhyJudge.getCheckNoQualifiedData",
  106. new object[] { _checkNo });
  107. //DataRow drSscCondition = _d.GetRowByXmlId("JdgCraftOrdDesignStdPicSmp.getSscConditonCnt", ordLnDlyPk, craftSeq, craftSource,
  108. // mscPline, processCode, pic);
  109. //if (drSscCondition["count"].ToString() != "0")
  110. //{
  111. // DataTable dtLsyd = _d.GetTableByXmlId("JdgQcmZcCheckConsignDetail.getHardnessPhy", _checkNo);
  112. // GridHelper.CopyDataToDatatable(dtLsyd, dataTable1, false);
  113. //}
  114. DataTable dtComplexChem = _d.GetTableByXmlId("JdgComBaseChem.getComplexChemOrderByLength");
  115. foreach (var row in ultraGrid1.Rows)
  116. {
  117. var drChems = dtComplexChem.Select("chemName = '" + row.GetValue("phyNameMin") + "'");
  118. if (drChems.Length > 0)
  119. {
  120. if (drChems[0]["chemType"].ToString() == "B")
  121. {
  122. Dictionary<string, string> chems = new Dictionary<string, string>();
  123. String chemFormula = drChems[0]["chemFormula"].ToString();
  124. DataTable dtChem = _d.GetTableByXmlId("JdgComBaseChem.queryBaseChemOrderByLength");
  125. foreach (DataRow drChem in dtChem.Rows)
  126. {
  127. if (chemFormula.Contains(drChem["chemName"].ToString()))
  128. {
  129. chemFormula = chemFormula.Replace(drChem["chemName"].ToString(), "");
  130. chems.Add(drChem["chemCode"].ToString(), drChem["chemName"].ToString());
  131. }
  132. }
  133. bool exists = true;
  134. DataRow[] drChemNos = null;
  135. foreach (string chemCode in chems.Keys)
  136. {
  137. drChemNos = dtNo.Select("phyCode = '" + chemCode + "' and judgeStoveNo = '" + row.GetValue("judgeStoveNo")
  138. + "' and batchNo = '" + row.GetValue("batchNo") + "'");
  139. if (drChemNos.Length == 0)
  140. {
  141. exists = false;
  142. break;
  143. }
  144. }
  145. if (exists && drChemNos != null)
  146. {
  147. row.SetValue("isOriginal", drChemNos[0]["isOriginal"].ToString());
  148. row.SetValue("sampleCount", drChemNos[0]["sampleCount"].ToString());
  149. row.Cells["chk"].Value = true;
  150. row.Update();
  151. }
  152. }
  153. else
  154. {
  155. var drAChemNos = dtNo.Select("phyName = '" + row.GetValue("phyCodeMin") + "' and judgeStoveNo = '" + row.GetValue("judgeStoveNo")
  156. + "' and batchNo = '" + row.GetValue("batchNo") + "'");
  157. if (drAChemNos.Length > 0)
  158. {
  159. row.SetValue("isOriginal", drAChemNos[0]["isOriginal"].ToString());
  160. row.SetValue("sampleCount", drAChemNos[0]["sampleCount"].ToString());
  161. row.Cells["chk"].Value = true;
  162. row.Update();
  163. }
  164. }
  165. }
  166. var drs = dtNo.Select("phyCodeMax = '" + row.GetValue("phyCodeMin") + "' and judgeStoveNo = '" + row.GetValue("judgeStoveNo")
  167. + "' and batchNo = '" + row.GetValue("batchNo") + "'");
  168. if (drs.Length > 0)
  169. {
  170. row.SetValue("isOriginal", drs[0]["isOriginal"].ToString());
  171. row.SetValue("sampleCount", drs[0]["sampleCount"].ToString());
  172. row.Cells["chk"].Value = true;
  173. row.Update();
  174. }
  175. }
  176. }
  177. private void ultraGrid1_CellChange(object sender, CellEventArgs e)
  178. {
  179. e.Cell.Row.Update();
  180. }
  181. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  182. {
  183. Color red = Color.FromArgb(255, 106, 106);
  184. if (e.Row.GetValue("nkResult") == "不合格")
  185. {
  186. e.Row.Appearance.BackColor = red;
  187. }
  188. }
  189. }
  190. }