MchSignature.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Mcp.Mch;
  6. using Core.StlMes.Client.Mcp.Mch.Entity;
  7. using CoreFS.CA06;
  8. using Infragistics.Win;
  9. using Infragistics.Win.UltraWinGrid;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.IO;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Windows.Forms;
  20. namespace Core.StlMes.Client.Mcp.Mch
  21. {
  22. public partial class MchSignature : FrmBase
  23. {
  24. public MchSignature()
  25. {
  26. InitializeComponent();
  27. }
  28. private string[] plineCode = null;
  29. private string fileName = "";//路径
  30. private void MchSignature_Load(object sender, EventArgs e)
  31. {
  32. EntityHelper.ShowGridCaption<HttSignatureEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  33. plineCode = comm.GetPlineCode(ValidDataPurviewIds, "G",this.CustomInfo, ob);
  34. comm.InitDropPlinePower("G", txtPline, this.ValidDataPurviewIds,this.CustomInfo, this.ob);
  35. }
  36. /// <summary>
  37. /// 重写基类方法
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="ToolbarKey"></param>
  41. public override void ToolBar_Click(object sender, string ToolbarKey)
  42. {
  43. switch (ToolbarKey)
  44. {
  45. case "DoQuery":
  46. QuerySinglePlan();
  47. break;
  48. //case "DoQueryInList":
  49. // doQueryInList();
  50. // break;
  51. case "DoSave":
  52. doSave();
  53. break;
  54. case "DoUpdate":
  55. doUpdate();
  56. break;
  57. case "CancelSignature":
  58. cancelSignature();
  59. break;
  60. //case "CancelPipe":
  61. // cancelPipe();
  62. // break;
  63. case "Close":
  64. this.Close();
  65. break;
  66. }
  67. }
  68. private void QuerySinglePlan()
  69. {
  70. List<HttSignatureEntity> listSource = EntityHelper.GetData<HttSignatureEntity>(
  71. "com.steering.mes.mcp.Mch.MchSignature.doQuery", new object[] { plineCode }, this.ob);
  72. HttSignatureEntitybindingSource1.DataSource = listSource;
  73. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  74. {
  75. ugr.Cells["PlineCode"].Appearance.BackColor = Color.Transparent;
  76. ugr.Cells["PlineCode"].Appearance.BackHatchStyle = BackHatchStyle.Default;
  77. ugr.Cells["PlineCode"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  78. ugr.Cells["ColGroup"].Appearance.BackColor = Color.Transparent;
  79. ugr.Cells["ColGroup"].Appearance.BackHatchStyle = BackHatchStyle.Default;
  80. ugr.Cells["ColGroup"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  81. }
  82. }
  83. private void doSave()
  84. {
  85. this.ultraGrid1.UpdateData();
  86. ArrayList list = new ArrayList();
  87. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  88. if(checkRows.Count()==0)
  89. {
  90. MessageUtil.ShowTips("请勾选要新增的信息");
  91. return;
  92. }
  93. foreach(UltraGridRow row in checkRows)
  94. {
  95. HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject;
  96. if(hsEntity.PlineCode.Equals(""))
  97. {
  98. MessageUtil.ShowTips("产线不能为空");
  99. return;
  100. }
  101. if(hsEntity.ColGroup.Equals(""))
  102. {
  103. MessageUtil.ShowTips("班组不能为空");
  104. return;
  105. }else if(hsEntity.ColGroup.Equals("甲"))
  106. {
  107. hsEntity.ColGroup = "1";
  108. }else if(hsEntity.ColGroup.Equals("乙"))
  109. {
  110. hsEntity.ColGroup = "2";
  111. }else if(hsEntity.ColGroup.Equals("丙"))
  112. {
  113. hsEntity.ColGroup = "3";
  114. }else if(hsEntity.ColGroup.Equals("丁"))
  115. {
  116. hsEntity.ColGroup = "4";
  117. }
  118. if(hsEntity.UserName.Equals(""))
  119. {
  120. MessageUtil.ShowTips("姓名不能为空");
  121. return;
  122. }
  123. if(hsEntity.ProcessNo.Equals(""))
  124. {
  125. MessageUtil.ShowTips("工序不能为空");
  126. return;
  127. }else if(hsEntity.ProcessNo.Equals("上料"))
  128. {
  129. hsEntity.ProcessNo = "0";
  130. }else if(hsEntity.ProcessNo.Equals("热处理"))
  131. {
  132. hsEntity.ProcessNo = "1";
  133. }else if(hsEntity.ProcessNo.Equals("定径热矫冷矫"))
  134. {
  135. hsEntity.ProcessNo = "2";
  136. }else if(hsEntity.ProcessNo.Equals("表面检验"))
  137. {
  138. hsEntity.ProcessNo = "3";
  139. }else if(hsEntity.ProcessNo.Equals("探伤"))
  140. {
  141. hsEntity.ProcessNo = "4";
  142. }else if(hsEntity.ProcessNo.Equals("下线"))
  143. {
  144. hsEntity.ProcessNo = "5";
  145. }
  146. //hsEntity.SignRoute = FileHelper.FileToArray(row.Cells["SignRoute"].Text.ToString()).ToString();
  147. hsEntity.UserId = this.UserInfo.GetUserID();
  148. string httEntity = JSONFormat.Format(hsEntity);
  149. list.Add(httEntity);
  150. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Mch.MchSignature.getSameData", new object[] { hsEntity.PlineCode, hsEntity.ProcessNo, hsEntity.UserName, hsEntity.ColGroup }, ob);
  151. if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; }
  152. }
  153. CoreClientParam ccp = new CoreClientParam();
  154. ccp.ServerName = "com.steering.mes.mcp.Mch.MchSignature";
  155. ccp.MethodName = "doSave";
  156. ccp.ServerParams = new object[] { list };
  157. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  158. if (ccp.ReturnCode != -1)
  159. {
  160. if (ccp.ReturnInfo.Equals("新增成功!"))
  161. {
  162. QuerySinglePlan();
  163. MessageUtil.ShowTips(ccp.ReturnInfo);
  164. }
  165. else
  166. {
  167. MessageUtil.ShowTips(ccp.ReturnInfo);
  168. }
  169. }
  170. }
  171. private void doUpdate()
  172. {
  173. this.ultraGrid1.UpdateData();
  174. ArrayList list = new ArrayList();
  175. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  176. if (checkRows.Count() == 0)
  177. {
  178. MessageUtil.ShowTips("请勾选要修改的信息");
  179. return;
  180. }
  181. foreach (UltraGridRow row in checkRows)
  182. {
  183. HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject;
  184. if (hsEntity.PlineCode.Equals(""))
  185. {
  186. MessageUtil.ShowTips("产线不能为空");
  187. return;
  188. }
  189. if (hsEntity.ColGroup.Equals(""))
  190. {
  191. MessageUtil.ShowTips("班组不能为空");
  192. return;
  193. }
  194. else if (hsEntity.ColGroup.Equals("甲"))
  195. {
  196. hsEntity.ColGroup = "1";
  197. }
  198. else if (hsEntity.ColGroup.Equals("乙"))
  199. {
  200. hsEntity.ColGroup = "2";
  201. }
  202. else if (hsEntity.ColGroup.Equals("丙"))
  203. {
  204. hsEntity.ColGroup = "3";
  205. }
  206. else if (hsEntity.ColGroup.Equals("丁"))
  207. {
  208. hsEntity.ColGroup = "4";
  209. }
  210. if (hsEntity.UserName.Equals(""))
  211. {
  212. MessageUtil.ShowTips("姓名不能为空");
  213. return;
  214. }
  215. if (hsEntity.ProcessNo.Equals(""))
  216. {
  217. MessageUtil.ShowTips("工序不能为空");
  218. return;
  219. }
  220. else if (hsEntity.ProcessNo.Equals("上料"))
  221. {
  222. hsEntity.ProcessNo = "0";
  223. }
  224. else if (hsEntity.ProcessNo.Equals("热处理"))
  225. {
  226. hsEntity.ProcessNo = "1";
  227. }
  228. else if (hsEntity.ProcessNo.Equals("定径热矫冷矫"))
  229. {
  230. hsEntity.ProcessNo = "2";
  231. }
  232. else if (hsEntity.ProcessNo.Equals("表面检验"))
  233. {
  234. hsEntity.ProcessNo = "3";
  235. }
  236. else if (hsEntity.ProcessNo.Equals("探伤"))
  237. {
  238. hsEntity.ProcessNo = "4";
  239. }
  240. else if (hsEntity.ProcessNo.Equals("下线"))
  241. {
  242. hsEntity.ProcessNo = "5";
  243. }
  244. string httEntity = JSONFormat.Format(hsEntity);
  245. list.Add(httEntity);
  246. //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttSignature.getSameData", new object[] { hsEntity.PlineCode, hsEntity.ProcessNo,hsEntity.UserName,hsEntity.ColGroup }, ob);
  247. //if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; }
  248. }
  249. CoreClientParam ccp = new CoreClientParam();
  250. ccp.ServerName = "com.steering.mes.mcp.Mch.MchSignature";
  251. ccp.MethodName = "doUpdate";
  252. ccp.ServerParams = new object[] { list };
  253. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  254. if (ccp.ReturnCode != -1)
  255. {
  256. if (ccp.ReturnInfo.Equals("修改成功!"))
  257. {
  258. QuerySinglePlan();
  259. MessageUtil.ShowTips(ccp.ReturnInfo);
  260. }
  261. else
  262. {
  263. MessageUtil.ShowTips(ccp.ReturnInfo);
  264. }
  265. }
  266. }
  267. private void cancelSignature()
  268. {
  269. this.ultraGrid1.UpdateData();
  270. ArrayList list = new ArrayList();
  271. IQueryable<UltraGridRow> checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  272. if (checkRows.Count() == 0)
  273. {
  274. MessageUtil.ShowTips("请勾选要修改的信息");
  275. return;
  276. }
  277. foreach (UltraGridRow row in checkRows)
  278. {
  279. HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject;
  280. if (hsEntity.PlineCode.Equals(""))
  281. {
  282. MessageUtil.ShowTips("产线不能为空");
  283. return;
  284. }
  285. if (hsEntity.ColGroup.Equals(""))
  286. {
  287. MessageUtil.ShowTips("班组不能为空");
  288. return;
  289. }
  290. else if (hsEntity.ColGroup.Equals("甲"))
  291. {
  292. hsEntity.ColGroup = "1";
  293. }
  294. else if (hsEntity.ColGroup.Equals("乙"))
  295. {
  296. hsEntity.ColGroup = "2";
  297. }
  298. else if (hsEntity.ColGroup.Equals("丙"))
  299. {
  300. hsEntity.ColGroup = "3";
  301. }
  302. else if (hsEntity.ColGroup.Equals("丁"))
  303. {
  304. hsEntity.ColGroup = "4";
  305. }
  306. if (hsEntity.UserName.Equals(""))
  307. {
  308. MessageUtil.ShowTips("姓名不能为空");
  309. return;
  310. }
  311. if (hsEntity.ProcessNo.Equals(""))
  312. {
  313. MessageUtil.ShowTips("工序不能为空");
  314. return;
  315. }
  316. else if (hsEntity.ProcessNo.Equals("上料"))
  317. {
  318. hsEntity.ProcessNo = "0";
  319. }
  320. else if (hsEntity.ProcessNo.Equals("热处理"))
  321. {
  322. hsEntity.ProcessNo = "1";
  323. }
  324. else if (hsEntity.ProcessNo.Equals("定径热矫冷矫"))
  325. {
  326. hsEntity.ProcessNo = "2";
  327. }
  328. else if (hsEntity.ProcessNo.Equals("表面检验"))
  329. {
  330. hsEntity.ProcessNo = "3";
  331. }
  332. else if (hsEntity.ProcessNo.Equals("探伤"))
  333. {
  334. hsEntity.ProcessNo = "4";
  335. }
  336. else if (hsEntity.ProcessNo.Equals("下线"))
  337. {
  338. hsEntity.ProcessNo = "5";
  339. }
  340. string httEntity = JSONFormat.Format(hsEntity);
  341. list.Add(httEntity);
  342. }
  343. CoreClientParam ccp = new CoreClientParam();
  344. ccp.ServerName = "com.steering.mes.mcp.Mch.MchSignature";
  345. ccp.MethodName = "doDelete";
  346. ccp.ServerParams = new object[] { list };
  347. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  348. if (ccp.ReturnCode != -1)
  349. {
  350. if (ccp.ReturnInfo.Equals("删除成功!"))
  351. {
  352. QuerySinglePlan();
  353. MessageUtil.ShowTips(ccp.ReturnInfo);
  354. }
  355. else
  356. {
  357. MessageUtil.ShowTips(ccp.ReturnInfo);
  358. }
  359. }
  360. }
  361. /// <summary>
  362. ///
  363. /// 上传
  364. /// </summary>
  365. /// <param name="sender"></param>
  366. /// <param name="e"></param>
  367. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  368. {
  369. UltraGridRow row = ultraGrid1.ActiveRow;
  370. string askSubItem = row.GetValue("PlineCode");
  371. string bz = row.GetValue("ColGroup");
  372. string filePath = "ZGMil/Signature/" + askSubItem + "/" + bz + "/";
  373. if (e.Button.Key.ToLower().Equals("select"))
  374. {
  375. FormFileDown down = new FormFileDown(this.ob, row.Cells["SignRoute"].Text);
  376. down.CtrlFileDown1.Button3.Visible = false;
  377. down.ShowDialog();
  378. }
  379. if (e.Button.Key.ToLower().Equals("insert"))
  380. {
  381. if (askSubItem.Equals("") || bz.Equals(""))
  382. {
  383. MessageUtil.ShowTips("没有产线或班组不允许上传!");
  384. return;
  385. }
  386. FormFileDown down = new FormFileDown(this.ob, filePath);
  387. down.CtrlFileDown1.FilePath = filePath;
  388. //if (down.CtrlFileDown1.List.Count > 0)
  389. //{
  390. // MessageUtil.ShowWarning("只能上传一份文件!");
  391. // return;
  392. //}
  393. List<FileBean> list = new List<FileBean>();
  394. FileBean bean = new FileBean();
  395. OpenFileDialog file = new OpenFileDialog();
  396. file.Multiselect = false;
  397. DialogResult drStat;
  398. drStat = file.ShowDialog();
  399. if (drStat == DialogResult.OK)
  400. {
  401. fileName = file.FileName;
  402. FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  403. long s = fs.Length;
  404. if (s / 1024.0 > 20)
  405. {
  406. MessageUtil.ShowTips("图片大于20KB,请重新上传!");
  407. return;
  408. }
  409. string filena = System.IO.Path.GetFileName(fileName);
  410. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttSignature.getSameData", new object[] { row.Cells["PlineCode"].Text, row.Cells["ProcessNo"].Text, row.Cells["UserName"].Text, row.Cells["ColGroup"].Text }, ob);
  411. if (dt.Rows.Count > 0)
  412. {
  413. string seturl = dt.Rows[0]["SignRoute"].ToString();
  414. bool isdelete = Core.Mes.Client.Comm.Server.FileHelper.Delete(seturl);
  415. //ServerHelper.SetData("com.steering.mes.signature.FrmTubeRollFileManage.updateMinStgnature1", new object[] { filePath + filena, fileName, row.Cells["USER_ID"].Value.ToString() }, ob);
  416. CoreClientParam ccp = new CoreClientParam();
  417. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttSignature";
  418. ccp.MethodName = "updateScoure";
  419. //ccp.ServerParams = new object[] { filePath + filena, FileHelper.FileToArray(fileName), row.Cells["USER_ID"].Value.ToString() };
  420. ccp.ServerParams = new object[] { filePath + filena, row.Cells["PlineCode"].Value.ToString() };
  421. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  422. if (ccp.ReturnCode == -1) { MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); return; }
  423. }
  424. bean = new FileBean();
  425. bean.setFileName(filena);
  426. bean.setPathName(filePath);
  427. bean.setFile(FileHelper.FileToArray(fileName));
  428. list.Add(bean);
  429. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  430. if (isSuccess)
  431. {
  432. CoreClientParam ccp = new CoreClientParam();
  433. ccp.ServerName = "com.steering.mes.mcp.Mch.HttSignature";
  434. ccp.MethodName = "updateScoure";
  435. //ccp.ServerParams = new object[] { filePath + filena, FileHelper.FileToArray(fileName), row.Cells["USER_ID"].Value.ToString() };
  436. ccp.ServerParams = new object[] { filePath + filena, row.Cells["PlineCode"].Value.ToString() };
  437. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  438. MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  439. }
  440. else
  441. {
  442. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  443. }
  444. //ultraGrid1.ActiveCell.Value = filena;
  445. //ultraGrid1.ActiveRow.Cells["URL"].Value = filePath + filena;
  446. //ultraGrid1.ActiveRow.Cells["PIR"].Value = fileName;
  447. }
  448. }
  449. }
  450. }
  451. }