FrmScrapNumSiz.cs 15 KB

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