FrmScrapNumStore.cs 15 KB

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