FrmScrapNumCham.cs 13 KB

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