FrmScrapNumCrack.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. using com.steering.mes.mcp.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Mcp.Control;
  6. using CoreFS.CA06;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.Mcp.Treatment
  19. {
  20. public partial class FrmScrapNumCrack : FrmBase
  21. {
  22. private ArrayList list = null;
  23. private string plineCode = "";
  24. private string SLGx = "";
  25. private string SLGxname = "";
  26. private string heatPlanNo = "";
  27. private string resultNo = "";
  28. public string reslNo = "";
  29. public string groudno = "";
  30. public string cutnum = "";
  31. private string StorageNo = "";
  32. private string save = "0";
  33. private string Linenum = "";
  34. private string PlineName = "";
  35. HttCrackDetectionEtEntity result1 = new HttCrackDetectionEtEntity();//探伤
  36. public FrmScrapNumCrack(HttCrackDetectionEtEntity result, string heatNo, string slgx, string slgxname, string batchgroudno, string outnumcut, string storageNo, string pline_Code, string ResultNo, string linenum, string plineName, OpeBase ob)
  37. {
  38. InitializeComponent();
  39. //list = arr;
  40. this.ob = ob;
  41. plineCode = pline_Code;
  42. SLGx = slgx;
  43. SLGxname = slgxname;
  44. groudno = batchgroudno;
  45. cutnum = outnumcut;
  46. StorageNo = storageNo;
  47. heatPlanNo = heatNo;
  48. resultNo = ResultNo;
  49. result1 = result;
  50. Linenum = linenum;
  51. PlineName = plineName;
  52. }
  53. /// <summary>
  54. /// 查询所有合格管序号
  55. /// </summary>
  56. //private void QuerySeq(ArrayList list)
  57. //{
  58. // DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.EddyCurrentTestingResult.doQuerySeq", new object[] { list }, ob);
  59. // GridHelper.CopyDataToDatatable(ref ds, ref dataTable4, true);
  60. //}
  61. public string alamNum = "";
  62. public string scrapNum = "";
  63. public string testOfflineNum = "";
  64. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  65. {
  66. switch (e.Tool.Key)
  67. {
  68. case "Save":
  69. Save();
  70. break;
  71. case "Close":
  72. CloseFrm();
  73. break;
  74. }
  75. }
  76. int alarmTotalNum = 0;//可疑总支数
  77. int scarpTotalNum = 0;//废品总支数
  78. int offlineTotalNum = 0;//下线总支数
  79. private void CloseFrm()
  80. {
  81. alamNum = alarmTotalNum.ToString();
  82. scrapNum = scarpTotalNum.ToString();
  83. testOfflineNum = offlineTotalNum.ToString();
  84. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  85. this.Close();
  86. }
  87. /// <summary>
  88. /// 保存离线
  89. /// </summary>
  90. private void Save()
  91. {
  92. this.ultraGridDetailDes1.UpdateData();
  93. alarmTotalNum = 0;
  94. scarpTotalNum = 0;
  95. offlineTotalNum = 0;
  96. IQueryable<UltraGridRow> checkAlarmRows = this.ultraGridDetailDes1.Rows.AsQueryable().Where(" CHK = 'True'");
  97. // IQueryable<UltraGridRow> checkOffineRow = this.ultraGridDetailDes3.Rows.AsQueryable().Where(" CHK = 'True'");
  98. ArrayList alarmlist = new ArrayList();
  99. ArrayList scraplist = new ArrayList();
  100. UltraGridRow row1 = this.ultraGridDetailDes1.ActiveRow;
  101. if (row1 == null) return;
  102. int num = 0;
  103. foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows)
  104. {
  105. num = num + int.Parse(urrg.Cells["OFFLINE_NUM"].Text.ToString());
  106. }
  107. string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  108. ArrayList list = new ArrayList();
  109. list.Add(heatPlanNo);
  110. list.Add(SLGx);
  111. list.Add(SLGxname);
  112. list.Add(this.UserInfo.GetUserName());
  113. list.Add(time);
  114. list.Add(this.UserInfo.GetUserOrder());
  115. list.Add(this.UserInfo.GetUserGroup());
  116. list.Add(num.ToString());
  117. if (MessageUtil.ShowYesNoAndQuestion("是否离线?") == DialogResult.No) return;
  118. foreach (UltraGridRow uRow in checkAlarmRows)
  119. {
  120. ArrayList list1 = new ArrayList();
  121. if (uRow.Cells["GOWHERE_NAME"].Value.ToString() == "")
  122. {
  123. MessageUtil.ShowTips("去向不能为空,请选择!");
  124. return;
  125. }
  126. if (uRow.Cells["OFFLINE_NUM"].Value.ToString() == "" || uRow.Cells["OFFLINE_NUM"].Value.ToString() == "0")
  127. {
  128. MessageUtil.ShowTips("支数不能为空或者为零支,请输入!");
  129. return;
  130. }
  131. if (!uRow.Cells["OFFLINE_NUM"].Value.ToString().TryParseInt())
  132. {
  133. MessageUtil.ShowTips("支数请输入整数!");
  134. return;
  135. }
  136. if(Convert.ToInt32(Linenum)<=Convert.ToInt32(uRow.Cells["OFFLINE_NUM"].Value.ToString()))
  137. {
  138. MessageUtil.ShowTips("离线支数不允许大于加工支数!");
  139. return;
  140. }
  141. //alarmTotalNum = alarmTotalNum + int.Parse(uRow.Cells["FAIL_NUM"].Value.ToString3());
  142. //list1.Add(uRow.Cells["FAIL_TYPE_NAME"].Text.Trim());
  143. //list1.Add(uRow.Cells["FAIL_NUM"].Value.ToString3());
  144. //list1.Add(alarmTotalNum.ToString());
  145. //alarmlist.Add(list1);
  146. HttOfflineResultDentity resultD = getRowData(uRow);
  147. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  148. resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim();
  149. resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  150. alarmlist.Add(resultD);
  151. }
  152. CoreClientParam ccp = new CoreClientParam();
  153. try
  154. {
  155. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  156. if (Constant.WaitingForm == null)
  157. {
  158. Constant.WaitingForm = new WaitingForm();
  159. }
  160. Constant.WaitingForm.ShowToUser = true;
  161. Constant.WaitingForm.Show();
  162. Constant.WaitingForm.Update();
  163. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult";
  164. ccp.MethodName = "offLineExpandResult";
  165. ccp.ServerParams = new Object[] { alarmlist,result1, list, plineCode, StorageNo,groudno };
  166. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  167. this.Cursor = Cursors.Default;
  168. Constant.WaitingForm.ShowToUser = false;
  169. Constant.WaitingForm.Close();
  170. Constant.WaitingForm = null;
  171. }
  172. catch (Exception ex)
  173. {
  174. this.Cursor = Cursors.Default;
  175. Constant.WaitingForm.ShowToUser = false;
  176. Constant.WaitingForm.Close();
  177. Constant.WaitingForm = null;
  178. }
  179. if (ccp.ReturnCode != -1)
  180. {
  181. MessageUtil.ShowTips(ccp.ReturnInfo);
  182. if (ccp.ReturnInfo.Equals("离线成功!"))
  183. {
  184. save = "1";
  185. alamNum = alarmTotalNum.ToString();
  186. scrapNum = scarpTotalNum.ToString();
  187. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  188. }
  189. else
  190. {
  191. MessageUtil.ShowTips(ccp.ReturnInfo);
  192. }
  193. }
  194. }
  195. public HttOfflineResultDentity getRowData(UltraGridRow checkrow)
  196. {
  197. HttOfflineResultDentity resultD = new HttOfflineResultDentity();
  198. resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim();
  199. resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  200. return resultD;
  201. }
  202. /// <summary>
  203. /// 查询仓库信息
  204. /// </summary>
  205. /// <param name="plineCode"></param>
  206. /// <returns></returns>
  207. private DataTable getStoreNo(string plineCode)
  208. {
  209. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  210. if (ds.Rows.Count > 0)
  211. {
  212. return ds;
  213. }
  214. else
  215. {
  216. return null;
  217. }
  218. }
  219. private void FrmScrap_Load(object sender, EventArgs e)
  220. {
  221. doQuery();
  222. }
  223. /// <summary>
  224. /// 查询离线去向
  225. /// </summary>
  226. public void doQuery()
  227. {
  228. dataTable1.Clear();
  229. dataTable2.Clear();
  230. dataTable3.Clear();
  231. ////下拉选离线去向
  232. //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirect", new object[] { "G", "002001006" }, this.ob);
  233. ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  234. //kreason.DataSource = dt2;
  235. //kreason.DisplayMember = "PLINE_NAME";
  236. //kreason.ValueMember = "PLINE_CODE";
  237. //YdmBaseClass.SetComboItemHeight(kreason);
  238. //下拉选离线去向
  239. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { plineCode }, this.ob);
  240. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  241. kreason.DataSource = dt2;
  242. kreason.DisplayMember = "PLINE_NAME";
  243. kreason.ValueMember = "PLINE_CODE";
  244. YdmBaseClass.SetComboItemHeight(kreason);
  245. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  246. {
  247. GridEdite(urg);
  248. }
  249. }
  250. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  251. {
  252. UltraGrid ug = (UltraGrid)sender;
  253. this.ultraGridDetailDes1.UpdateData();
  254. GridEdite(e.Cell.Row);
  255. if (e.Cell.Column.Key == "REASON")
  256. {
  257. if (e.Cell.Value == "")
  258. {
  259. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  260. return;
  261. }
  262. int temp = 0;
  263. for (int i = 0; i < ug.Rows.Count(); i++)
  264. {
  265. UltraGridRow ugr = ug.Rows[i];
  266. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  267. {
  268. temp = temp + 1;
  269. }
  270. }
  271. if (temp > 1)
  272. {
  273. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  274. e.Cell.Row.Cells["REASON"].Value = "";
  275. }
  276. }
  277. }
  278. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  279. {
  280. UltraGrid ug = (UltraGrid)sender;
  281. if (e.Cell.Column.Key == "REASON")
  282. {
  283. if (e.Cell.Value == "")
  284. {
  285. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  286. return;
  287. }
  288. int temp = 0;
  289. for (int i = 0; i < ug.Rows.Count(); i++)
  290. {
  291. UltraGridRow ugr = ug.Rows[i];
  292. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  293. {
  294. temp = temp + 1;
  295. }
  296. }
  297. if (temp > 1)
  298. {
  299. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  300. e.Cell.Row.Cells["REASON"].Value = "";
  301. }
  302. }
  303. if (e.Cell.Column.Key == "REASON1")
  304. {
  305. if (e.Cell.Value == "")
  306. {
  307. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  308. return;
  309. }
  310. int temp1 = 0;
  311. for (int i = 0; i < ug.Rows.Count(); i++)
  312. {
  313. UltraGridRow ugr = ug.Rows[i];
  314. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  315. {
  316. temp1 = temp1 + 1;
  317. }
  318. }
  319. if (temp1 > 1)
  320. {
  321. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  322. e.Cell.Row.Cells["REASON"].Value = "";
  323. }
  324. }
  325. }
  326. private void FrmScrapNum_FormClosing(object sender, FormClosingEventArgs e)
  327. {
  328. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  329. if (urg != null)
  330. {
  331. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "")
  332. {
  333. if (save == "0")
  334. {
  335. MessageUtil.ShowTips("请点保存按钮!");
  336. e.Cancel = true;
  337. }
  338. }
  339. }
  340. }
  341. /// <summary>
  342. ///
  343. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  344. /// </summary>
  345. /// <param name="row"></param>
  346. private void GridEdite(UltraGridRow row)
  347. {
  348. if (row.GetValue("CHK") == "True")
  349. {
  350. foreach (UltraGridCell cell in row.Cells)
  351. {
  352. if (cell.Column.CellActivation == Activation.AllowEdit)
  353. {
  354. cell.Activation = Activation.AllowEdit;
  355. }
  356. }
  357. }
  358. else
  359. {
  360. foreach (UltraGridCell cell in row.Cells)
  361. {
  362. if (cell.Column.Key.Contains("CHK")) continue;
  363. if (cell.Column.CellActivation == Activation.AllowEdit)
  364. {
  365. cell.Activation = Activation.ActivateOnly;
  366. }
  367. }
  368. }
  369. ultraGridDetailDes1.UpdateData();
  370. }
  371. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  372. {
  373. this.ultraGridDetailDes1.UpdateData();
  374. GridEdite(e.Row);
  375. }
  376. }
  377. }