FrmScrapNumCut.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 FrmScrapNumCut : 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. MchCutResultEntity result1 = new MchCutResultEntity();//分切
  36. public FrmScrapNumCut(MchCutResultEntity 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. ArrayList alarmlist = new ArrayList();
  98. ArrayList scraplist = new ArrayList();
  99. int num = 0;
  100. foreach (UltraGridRow urrg in ultraGridDetailDes1.Rows)
  101. {
  102. num = num + int.Parse(urrg.Cells["OFFLINE_NUM"].Value.ToString());
  103. }
  104. string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  105. ArrayList list = new ArrayList();
  106. list.Add(heatPlanNo);
  107. list.Add(SLGx);
  108. list.Add(SLGxname);
  109. list.Add(this.UserInfo.GetUserName());
  110. list.Add(time);
  111. list.Add(this.UserInfo.GetUserOrder());
  112. list.Add(this.UserInfo.GetUserGroup());
  113. list.Add(num.ToString());
  114. if (MessageUtil.ShowYesNoAndQuestion("是否离线?") == DialogResult.No) return;
  115. foreach (UltraGridRow uRow in checkAlarmRows)
  116. {
  117. ArrayList list1 = new ArrayList();
  118. if (uRow.Cells["GOWHERE_NAME"].Value.ToString() == "")
  119. {
  120. MessageUtil.ShowTips("去向不能为空,请选择!");
  121. return;
  122. }
  123. if (uRow.Cells["OFFLINE_NUM"].Value.ToString() == "" || uRow.Cells["OFFLINE_NUM"].Value.ToString() == "0")
  124. {
  125. MessageUtil.ShowTips("支数不能为空或者为零支,请输入!");
  126. return;
  127. }
  128. if (!uRow.Cells["OFFLINE_NUM"].Value.ToString().TryParseInt())
  129. {
  130. MessageUtil.ShowTips("支数请输入整数!");
  131. return;
  132. }
  133. if(Convert.ToInt32(Linenum)<=Convert.ToInt32(uRow.Cells["OFFLINE_NUM"].Value.ToString()))
  134. {
  135. MessageUtil.ShowTips("离线支数不允许大于加工支数!");
  136. return;
  137. }
  138. MchOfflineResultDentity resultD = getRowData(uRow);
  139. resultD.ResultNo = uRow.Cells["FAIL_BILL"].Value.ToString();
  140. resultD.GowhereName = uRow.Cells["GOWHERE_NAME"].Text.ToString().Trim();
  141. resultD.OfflineNum = uRow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  142. alarmlist.Add(resultD);
  143. }
  144. CoreClientParam ccp = new CoreClientParam();
  145. try
  146. {
  147. this.Cursor = Cursors.WaitCursor; //控制鼠标的样式为等待
  148. if (Constant.WaitingForm == null)
  149. {
  150. Constant.WaitingForm = new WaitingForm();
  151. }
  152. Constant.WaitingForm.ShowToUser = true;
  153. Constant.WaitingForm.Show();
  154. Constant.WaitingForm.Update();
  155. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmCutResult";
  156. ccp.MethodName = "offLineExpandResult";
  157. ccp.ServerParams = new Object[] { alarmlist,result1, list, plineCode, StorageNo, groudno, cutnum };
  158. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  159. this.Cursor = Cursors.Default;
  160. Constant.WaitingForm.ShowToUser = false;
  161. Constant.WaitingForm.Close();
  162. Constant.WaitingForm = null;
  163. }
  164. catch (Exception ex)
  165. {
  166. this.Cursor = Cursors.Default;
  167. Constant.WaitingForm.ShowToUser = false;
  168. Constant.WaitingForm.Close();
  169. Constant.WaitingForm = null;
  170. }
  171. if (ccp.ReturnCode != -1)
  172. {
  173. MessageUtil.ShowTips(ccp.ReturnInfo);
  174. if (ccp.ReturnInfo.Equals("离线成功!"))
  175. {
  176. save = "1";
  177. alamNum = alarmTotalNum.ToString();
  178. scrapNum = scarpTotalNum.ToString();
  179. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  180. }
  181. else
  182. {
  183. MessageUtil.ShowTips(ccp.ReturnInfo);
  184. }
  185. }
  186. }
  187. public MchOfflineResultDentity getRowData(UltraGridRow checkrow)
  188. {
  189. MchOfflineResultDentity resultD = new MchOfflineResultDentity();
  190. resultD.GowhereName = checkrow.Cells["GOWHERE_NAME"].Value.ToString().Trim();
  191. resultD.OfflineNum = checkrow.Cells["OFFLINE_NUM"].Value.ToString().Trim();
  192. return resultD;
  193. }
  194. /// <summary>
  195. /// 查询仓库信息
  196. /// </summary>
  197. /// <param name="plineCode"></param>
  198. /// <returns></returns>
  199. private DataTable getStoreNo(string plineCode)
  200. {
  201. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  202. if (ds.Rows.Count > 0)
  203. {
  204. return ds;
  205. }
  206. else
  207. {
  208. return null;
  209. }
  210. }
  211. private void FrmScrap_Load(object sender, EventArgs e)
  212. {
  213. doQuery();
  214. }
  215. /// <summary>
  216. /// 查询离线去向
  217. /// </summary>
  218. public void doQuery()
  219. {
  220. dataTable1.Clear();
  221. dataTable2.Clear();
  222. dataTable3.Clear();
  223. ////下拉选离线去向
  224. //DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirect", new object[] { "G", "002001006" }, this.ob);
  225. ////comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  226. //kreason.DataSource = dt2;
  227. //kreason.DisplayMember = "PLINE_NAME";
  228. //kreason.ValueMember = "PLINE_CODE";
  229. //YdmBaseClass.SetComboItemHeight(kreason);
  230. //下拉选离线去向
  231. DataTable dt2 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmCrackDetectResult.getQuerydirectOffline", new object[] { plineCode }, this.ob);
  232. //comm.FilComboboxAdd(standard, dt2, "BASECODE", "BASENAME", "validflag NOT in ('0')", false, "全部", "");
  233. kreason.DataSource = dt2;
  234. kreason.DisplayMember = "PLINE_NAME";
  235. kreason.ValueMember = "PLINE_CODE";
  236. YdmBaseClass.SetComboItemHeight(kreason);
  237. foreach (UltraGridRow urg in ultraGridDetailDes1.Rows)
  238. {
  239. GridEdite(urg);
  240. }
  241. }
  242. private void ultraGridDetailDes1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  243. {
  244. UltraGrid ug = (UltraGrid)sender;
  245. this.ultraGridDetailDes1.UpdateData();
  246. GridEdite(e.Cell.Row);
  247. if (e.Cell.Column.Key == "REASON")
  248. {
  249. if (e.Cell.Value == "")
  250. {
  251. MessageBox.Show("您未选择任何选项,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  252. return;
  253. }
  254. int temp = 0;
  255. for (int i = 0; i < ug.Rows.Count(); i++)
  256. {
  257. UltraGridRow ugr = ug.Rows[i];
  258. if (e.Cell.Value.ToString().Equals(ugr.Cells["REASON"].Value.ToString()))
  259. {
  260. temp = temp + 1;
  261. }
  262. }
  263. if (temp > 1)
  264. {
  265. MessageBox.Show(e.Cell.Value.ToString() + "选项已被选取,请重新选择", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  266. e.Cell.Row.Cells["REASON"].Value = "";
  267. }
  268. }
  269. }
  270. private void FrmScrapNumCut_FormClosing(object sender, FormClosingEventArgs e)
  271. {
  272. UltraGridRow urg = ultraGridDetailDes1.ActiveRow;
  273. if (urg != null)
  274. {
  275. if (Convert.ToBoolean(urg.Cells["CHK"].Text) == true && urg.Cells["GOWHERE_NAME"].Text != "")
  276. {
  277. if (save == "0")
  278. {
  279. MessageUtil.ShowTips("请点保存按钮!");
  280. e.Cancel = true;
  281. }
  282. }
  283. }
  284. }
  285. /// <summary>
  286. ///
  287. /// ulltragrid控件受勾影响(打钩可编辑,不打勾不能编辑)**
  288. /// </summary>
  289. /// <param name="row"></param>
  290. private void GridEdite(UltraGridRow row)
  291. {
  292. if (row.GetValue("CHK") == "True")
  293. {
  294. foreach (UltraGridCell cell in row.Cells)
  295. {
  296. if (cell.Column.CellActivation == Activation.AllowEdit)
  297. {
  298. cell.Activation = Activation.AllowEdit;
  299. }
  300. }
  301. }
  302. else
  303. {
  304. foreach (UltraGridCell cell in row.Cells)
  305. {
  306. if (cell.Column.Key.Contains("CHK")) continue;
  307. if (cell.Column.CellActivation == Activation.AllowEdit)
  308. {
  309. cell.Activation = Activation.ActivateOnly;
  310. }
  311. }
  312. }
  313. ultraGridDetailDes1.UpdateData();
  314. }
  315. private void ultraGridDetailDes1_AfterRowInsert(object sender, RowEventArgs e)
  316. {
  317. this.ultraGridDetailDes1.UpdateData();
  318. GridEdite(e.Row);
  319. }
  320. }
  321. }