FrmScrapNumOnline.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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.Mch
  19. {
  20. public partial class FrmScrapNumOnline : 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. private string MatStart = "";
  36. private string IsSamp = "";
  37. public FrmScrapNumOnline(string heatNo, string slgx, string slgxname, string batchgroudno, string outnumcut, string storageNo, string pline_Code,string linenum,string plineName,string matStart,string isSamp, 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. Linenum = linenum;
  50. PlineName = plineName;
  51. MatStart = matStart;
  52. IsSamp = isSamp;
  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"].Value.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. list.Add(MatStart);
  117. list.Add(IsSamp);
  118. if (MessageUtil.ShowYesNoAndQuestion("是否离线?") == DialogResult.No) return;
  119. foreach (UltraGridRow uRow in checkAlarmRows)
  120. {
  121. ArrayList list1 = new ArrayList();
  122. if (uRow.Cells["GOWHERE_NAME"].Value.ToString() == "")
  123. {
  124. MessageUtil.ShowTips("去向不能为空,请选择!");
  125. return;
  126. }
  127. if (uRow.Cells["OFFLINE_NUM"].Value.ToString() == "" || uRow.Cells["OFFLINE_NUM"].Value.ToString() == "0")
  128. {
  129. MessageUtil.ShowTips("支数不能为空或者为零支,请输入!");
  130. return;
  131. }
  132. if (!uRow.Cells["OFFLINE_NUM"].Value.ToString().TryParseInt())
  133. {
  134. MessageUtil.ShowTips("支数请输入整数!");
  135. return;
  136. }
  137. if (Convert.ToInt32(Linenum) <= Convert.ToInt32(uRow.Cells["OFFLINE_NUM"].Text.ToString()))
  138. {
  139. MessageUtil.ShowTips("离线支数不允许大于加工支数!");
  140. return;
  141. }
  142. MchOfflineResultDentity resultD = getRowData(uRow);
  143. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  144. resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim();
  145. resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  146. alarmlist.Add(resultD);
  147. }
  148. CoreClientParam ccp = new CoreClientParam();
  149. try
  150. {
  151. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  152. if (Constant.WaitingForm == null)
  153. {
  154. Constant.WaitingForm = new WaitingForm();
  155. }
  156. Constant.WaitingForm.ShowToUser = true;
  157. Constant.WaitingForm.Show();
  158. Constant.WaitingForm.Update();
  159. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMchInOnlineStore";
  160. ccp.MethodName = "offLineExpandResult";
  161. ccp.ServerParams = new Object[] { alarmlist, list, plineCode, StorageNo };
  162. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  163. this.Cursor = Cursors.Default;
  164. Constant.WaitingForm.ShowToUser = false;
  165. Constant.WaitingForm.Close();
  166. Constant.WaitingForm = null;
  167. }
  168. catch (Exception ex)
  169. {
  170. this.Cursor = Cursors.Default;
  171. Constant.WaitingForm.ShowToUser = false;
  172. Constant.WaitingForm.Close();
  173. Constant.WaitingForm = null;
  174. }
  175. if (ccp.ReturnCode != -1)
  176. {
  177. MessageUtil.ShowTips(ccp.ReturnInfo);
  178. if (ccp.ReturnInfo.Equals("离线成功!"))
  179. {
  180. save = "1";
  181. alamNum = alarmTotalNum.ToString();
  182. scrapNum = scarpTotalNum.ToString();
  183. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  184. }
  185. else
  186. {
  187. MessageUtil.ShowTips(ccp.ReturnInfo);
  188. }
  189. }
  190. }
  191. public MchOfflineResultDentity getRowData(UltraGridRow checkrow)
  192. {
  193. MchOfflineResultDentity resultD = new MchOfflineResultDentity();
  194. resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim();
  195. resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  196. return resultD;
  197. }
  198. /// <summary>
  199. /// 查询仓库信息
  200. /// </summary>
  201. /// <param name="plineCode"></param>
  202. /// <returns></returns>
  203. private DataTable getStoreNo(string plineCode)
  204. {
  205. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  206. if (ds.Rows.Count > 0)
  207. {
  208. return ds;
  209. }
  210. else
  211. {
  212. return null;
  213. }
  214. }
  215. private void FrmScrap_Load(object sender, EventArgs e)
  216. {
  217. doQuery();
  218. }
  219. /// <summary>
  220. /// 查询离线去向
  221. /// </summary>
  222. public void doQuery()
  223. {
  224. dataTable1.Clear();
  225. dataTable2.Clear();
  226. dataTable3.Clear();
  227. ////下拉选离线去向
  228. //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { "G", "002001006" }, this.ob);
  229. ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  230. //kreason.DataSource = dt2;
  231. //kreason.DisplayMember = "PLINE_NAME";
  232. //kreason.ValueMember = "PLINE_CODE";
  233. //YdmBaseClass.SetComboItemHeight(kreason);
  234. //下拉选离线去向
  235. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { PlineName }, this.ob);
  236. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  237. kreason.DataSource = dt2;
  238. kreason.DisplayMember = "PLINE_NAME";
  239. kreason.ValueMember = "PLINE_CODE";
  240. YdmBaseClass.SetComboItemHeight(kreason);
  241. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  242. {
  243. GridEdite(urg);
  244. }
  245. }
  246. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  247. {
  248. UltraGrid ug = (UltraGrid)sender;
  249. this.ultraGridDetailDes1.UpdateData();
  250. GridEdite(e.Cell.Row);
  251. if (e.Cell.Column.Key == "REASON")
  252. {
  253. if (e.Cell.Value == "")
  254. {
  255. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  256. return;
  257. }
  258. int temp = 0;
  259. for (int i = 0; i < ug.Rows.Count(); i++)
  260. {
  261. UltraGridRow ugr = ug.Rows[i];
  262. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  263. {
  264. temp = temp + 1;
  265. }
  266. }
  267. if (temp > 1)
  268. {
  269. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  270. e.Cell.Row.Cells["REASON"].Value = "";
  271. }
  272. }
  273. }
  274. private void ultraGridDetailDes2_CellChange(object sender, CellEventArgs e)
  275. {
  276. UltraGrid ug = (UltraGrid)sender;
  277. if (e.Cell.Column.Key == "REASON")
  278. {
  279. if (e.Cell.Value == "")
  280. {
  281. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  282. return;
  283. }
  284. int temp = 0;
  285. for (int i = 0; i < ug.Rows.Count(); i++)
  286. {
  287. UltraGridRow ugr = ug.Rows[i];
  288. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()) && e.Cell.Row.Cells["REASON1"].Value.ToString2().Equals(ugr.Cells["REASON1"].Value.ToString2()))
  289. {
  290. temp = temp + 1;
  291. }
  292. }
  293. if (temp > 1)
  294. {
  295. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  296. e.Cell.Row.Cells["REASON"].Value = "";
  297. }
  298. }
  299. if (e.Cell.Column.Key == "REASON1")
  300. {
  301. if (e.Cell.Value == "")
  302. {
  303. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  304. return;
  305. }
  306. int temp1 = 0;
  307. for (int i = 0; i < ug.Rows.Count(); i++)
  308. {
  309. UltraGridRow ugr = ug.Rows[i];
  310. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON1"].Value.ToString()) && e.Cell.Row.Cells["REASON"].Value.ToString2().Equals(ugr.Cells["REASON"].Value.ToString2()))
  311. {
  312. temp1 = temp1 + 1;
  313. }
  314. }
  315. if (temp1 > 1)
  316. {
  317. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  318. e.Cell.Row.Cells["REASON"].Value = "";
  319. }
  320. }
  321. }
  322. private void FrmScrapNumOnline_FormClosing(object sender, FormClosingEventArgs e)
  323. {
  324. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  325. if (urg != null)
  326. {
  327. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "")
  328. {
  329. if (save == "0")
  330. {
  331. MessageUtil.ShowTips("请点保存按钮!");
  332. e.Cancel = true;
  333. }
  334. }
  335. }
  336. }
  337. /// <summary>
  338. ///
  339. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  340. /// </summary>
  341. /// <param name="row"></param>
  342. private void GridEdite(UltraGridRow row)
  343. {
  344. if (row.GetValue("CHK") == "True")
  345. {
  346. foreach (UltraGridCell cell in row.Cells)
  347. {
  348. if (cell.Column.CellActivation == Activation.AllowEdit)
  349. {
  350. cell.Activation = Activation.AllowEdit;
  351. }
  352. }
  353. }
  354. else
  355. {
  356. foreach (UltraGridCell cell in row.Cells)
  357. {
  358. if (cell.Column.Key.Contains("CHK")) continue;
  359. if (cell.Column.CellActivation == Activation.AllowEdit)
  360. {
  361. cell.Activation = Activation.ActivateOnly;
  362. }
  363. }
  364. }
  365. ultraGridDetailDes1.UpdateData();
  366. }
  367. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  368. {
  369. this.ultraGridDetailDes1.UpdateData();
  370. GridEdite(e.Row);
  371. }
  372. }
  373. }