HttSignature.cs 17 KB

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