FrmCraftJgNoSecond.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.PlnSaleOrd.Controls;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinEditors;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Net;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.PlnSaleOrd.JGGXPln
  19. {
  20. public partial class FrmCraftJgNoSecond : FrmBase
  21. {
  22. private string _key = "";
  23. private string _userName = "";
  24. private OpeBase _ob = null;
  25. private string _orderNo = "";
  26. private string _codeJg = "";
  27. private string _orderNoJg = "";
  28. private string _jgKey = "";
  29. public FrmCraftJgNoSecond(string key, string userName, OpeBase ob, string orderNo, string codeJg, string orderNoJg, string jgKey)
  30. {
  31. InitializeComponent();
  32. _key = key;
  33. _userName = userName;
  34. _ob = ob;
  35. _orderNo = orderNo;
  36. _codeJg = codeJg;
  37. _orderNoJg = orderNoJg;
  38. _jgKey = jgKey;
  39. }
  40. private void FrmCraftJgNoSecond_Load(object sender, EventArgs e)
  41. {
  42. DoQuery();
  43. DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.initMemo", null, _ob);
  44. ultraComboEditor1.DataSource = dt1;
  45. ultraComboEditor1.DisplayMember = "BASENAME";
  46. ultraComboEditor1.ValueMember = "BASECODE";
  47. }
  48. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  49. {
  50. switch (e.Tool.Key)
  51. {
  52. case "AddCraft": // 新增
  53. doAddCraft();
  54. break;
  55. case "Update": //修改
  56. doUpdate();
  57. break;
  58. case "Delete": //作废
  59. doDelete("0");
  60. break;
  61. case "Restore": //恢复
  62. doDelete("1");
  63. break;
  64. case "SpecCraft": // 指定工艺
  65. doSpecCraft();
  66. break;
  67. case "Generate": // 生成工艺
  68. doGenerate();
  69. break;
  70. case "Close": // 关闭
  71. this.Close();
  72. break;
  73. default:
  74. break;
  75. }
  76. }
  77. private void DoQuery()
  78. {
  79. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryCraftSeconed", new object[] { _key, "" }, _ob);
  80. GridHelper.CopyDataToDatatable(dt, dataTable1, true);
  81. }
  82. /// <summary>
  83. /// 保存
  84. /// </summary>
  85. private void doAddCraft()
  86. {
  87. UltraGridRow row = ultraGrid1.ActiveRow;
  88. if (row == null) return;
  89. ArrayList list = new ArrayList();
  90. int count = 0;
  91. foreach (UltraGridRow urg in ultraGrid1.Rows)
  92. {
  93. if (Convert.ToBoolean(row.Cells["CHC"].Text) == true)
  94. {
  95. if (row.Cells["CRAFT_NO_JG2"].Text.Equals(""))
  96. {
  97. MessageUtil.ShowTips("二级工艺文件为空,不能新增!");
  98. return;
  99. }
  100. if (!row.Cells["PK"].Text.Equals(""))
  101. {
  102. MessageUtil.ShowTips("系统已存在该条工艺数据,不能新增!");
  103. return;
  104. }
  105. count++;
  106. ArrayList list1 = new ArrayList();
  107. list1.Add(_key);
  108. list1.Add(row.Cells["CRAFT_NO_JG2"].Text.ToString());
  109. list1.Add(row.Cells["CRAFT_SEQ2"].Text.ToString());
  110. list1.Add(row.Cells["CRAFT_PATH"].Text.ToString());
  111. list1.Add(row.Cells["MEMO"].Text.ToString());
  112. list1.Add(row.Cells["MEMO1"].Text.ToString());
  113. list1.Add(row.Cells["CONTENT"].Text.ToString());
  114. list1.Add(row.Cells["MEMO2"].Text.ToString());
  115. list1.Add(row.Cells["NUMBERS"].Text.ToString());
  116. list.Add(list1);
  117. }
  118. }
  119. if (count == 0)
  120. {
  121. MessageUtil.ShowTips("请勾选需要新增的二级工艺!");
  122. return;
  123. }
  124. PlanComm.WaitFromOpen(this.Cursor);
  125. CoreClientParam ccp = new CoreClientParam();
  126. ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess";
  127. ccp.MethodName = "doAddCraft";
  128. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() };
  129. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  130. PlanComm.WaitFromColse(this.Cursor);
  131. if (ccp.ReturnCode == -1) return;
  132. MessageUtil.ShowTips(ccp.ReturnInfo);
  133. if (ccp.ReturnInfo.Equals("新增成功!"))
  134. {
  135. DoQuery();
  136. }
  137. }
  138. /// <summary>
  139. /// 修改
  140. /// </summary>
  141. private void doUpdate()
  142. {
  143. UltraGridRow row = ultraGrid1.ActiveRow;
  144. if (row == null) return;
  145. ArrayList list = new ArrayList();
  146. int count = 0;
  147. foreach (UltraGridRow urg in ultraGrid1.Rows)
  148. {
  149. if (Convert.ToBoolean(row.Cells["CHC"].Text) == true)
  150. {
  151. if (row.Cells["CRAFT_NO_JG2"].Text.Equals(""))
  152. {
  153. MessageUtil.ShowTips("二级工艺文件为空,不能修改!");
  154. return;
  155. }
  156. if (row.Cells["PK"].Text.Equals(""))
  157. {
  158. MessageUtil.ShowTips("选择的该条工艺数据未新增不能修改!");
  159. return;
  160. }
  161. count++;
  162. ArrayList list1 = new ArrayList();
  163. list1.Add(row.Cells["CRAFT_NO_JG2"].Text.ToString());
  164. list1.Add(row.Cells["CRAFT_PATH"].Text.ToString());
  165. list1.Add(row.Cells["MEMO"].Text.ToString());
  166. list1.Add(row.Cells["MEMO1"].Text.ToString());
  167. list1.Add(row.Cells["CONTENT"].Text.ToString());
  168. list1.Add(row.Cells["PK"].Text.ToString());
  169. list1.Add(row.Cells["MEMO2"].Text.ToString());
  170. list1.Add(row.Cells["NUMBERS"].Text.ToString());
  171. list.Add(list1);
  172. }
  173. }
  174. if (count == 0)
  175. {
  176. MessageUtil.ShowTips("请勾选需要修改的二级工艺!");
  177. return;
  178. }
  179. PlanComm.WaitFromOpen(this.Cursor);
  180. CoreClientParam ccp = new CoreClientParam();
  181. ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess";
  182. ccp.MethodName = "doUpdate";
  183. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() };
  184. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  185. PlanComm.WaitFromColse(this.Cursor);
  186. if (ccp.ReturnCode == -1) return;
  187. MessageUtil.ShowTips(ccp.ReturnInfo);
  188. if (ccp.ReturnInfo.Equals("修改成功!"))
  189. {
  190. DoQuery();
  191. }
  192. }
  193. /// <summary>
  194. /// 作废/恢复
  195. /// </summary>
  196. private void doDelete(string falg)
  197. {
  198. UltraGridRow row = ultraGrid1.ActiveRow;
  199. if (row == null) return;
  200. ArrayList list = new ArrayList();
  201. int count = 0;
  202. foreach (UltraGridRow urg in ultraGrid1.Rows)
  203. {
  204. if (Convert.ToBoolean(row.Cells["CHC"].Text) == true)
  205. {
  206. if (row.Cells["PK"].Text.Equals(""))
  207. {
  208. MessageUtil.ShowTips("选择的该条工艺数据未新增不能作废或恢复!");
  209. return;
  210. }
  211. count++;
  212. ArrayList list1 = new ArrayList();
  213. list1.Add(row.Cells["PK"].Text.ToString());
  214. list.Add(list1);
  215. }
  216. }
  217. if (count == 0)
  218. {
  219. MessageUtil.ShowTips("请勾选需要作废或恢复的二级工艺!");
  220. return;
  221. }
  222. PlanComm.WaitFromOpen(this.Cursor);
  223. CoreClientParam ccp = new CoreClientParam();
  224. ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess";
  225. ccp.MethodName = "doDelete";
  226. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(),falg };
  227. ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  228. PlanComm.WaitFromColse(this.Cursor);
  229. if (ccp.ReturnCode == -1) return;
  230. MessageUtil.ShowTips(ccp.ReturnInfo);
  231. if (ccp.ReturnInfo.Equals("成功!"))
  232. {
  233. DoQuery();
  234. }
  235. }
  236. /// <summary>
  237. /// 指定工艺
  238. /// </summary>
  239. private void doSpecCraft()
  240. {
  241. //UltraGridRow row=
  242. }
  243. /// <summary>
  244. /// 生成工艺
  245. /// </summary>
  246. private void doGenerate()
  247. {//&format=pdf
  248. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess2.cpt"
  249. + "&ORDER_NO=" + _orderNo;
  250. FrmRepExcel down = new FrmRepExcel(ob, strurl);
  251. down.Text = "接箍二级工艺";
  252. down.Visible = false;
  253. down.Size = new Size(740, this.Height);
  254. down.WindowState = FormWindowState.Maximized;
  255. down.ShowDialog();
  256. }
  257. private void craftImg1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  258. {
  259. UltraGridRow row = ultraGrid1.ActiveRow;
  260. if (row == null) return;
  261. if (e.Button.Key.ToLower().Equals("upload"))
  262. {
  263. string pdfName = _codeJg + _jgKey;
  264. ////CreatePdfToFtp(_codeJg + _jgKey);
  265. //WebClient webClient = new WebClient();
  266. //List<FileBean> listPdf = new List<FileBean>();
  267. string craftSeq = row.Cells["CRAFT_SEQ2"].Value.ToString();
  268. //////查询最大工艺序号
  269. ////DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doMaxCraftSeq", new object[] { _key }, _ob);
  270. ////if (dt.Rows.Count > 0)
  271. ////{
  272. //// craftSeq = int.Parse(dt.Rows[0]["CRAFT_SEQ2"].ToString()) + 1;
  273. ////}
  274. string filePathNew = "Mcp/CraftLv2/" + _orderNoJg + "/" + craftSeq + "/";
  275. //string craftPath = filePathNew + pdfName + ".pdf";
  276. //string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess2.cpt&format=pdf"
  277. // + "&ORDER_NO=" + _orderNo;
  278. //byte[] pdf = webClient.DownloadData(strurl);
  279. //if (pdf.Length <= 10000)
  280. //{
  281. // MessageUtil.ShowError("生成PDF出错,请重新生成!");
  282. // return;
  283. //}
  284. //FileBean fileBean = new FileBean();
  285. //fileBean.setFile(pdf);
  286. //fileBean.setFileName(pdfName + ".pdf");
  287. //fileBean.setPathName(filePathNew);
  288. //listPdf.Add(fileBean);
  289. //webClient.Dispose();
  290. //var a = FileHelper.Upload(listPdf);
  291. //if (a)
  292. //{
  293. // MessageUtil.ShowTips("上传成功!");
  294. // row.Cells["CRAFT_NO_JG2"].Value = pdfName+".pdf";
  295. // row.Cells["CRAFT_PATH"].Value = filePathNew;
  296. // //row.Cells["CRAFT_SEQ2"].Value = craftSeq;
  297. //}
  298. var serverFileList = FileHelper.Download(filePathNew);
  299. //if (serverFileList.Count > 0)
  300. //{
  301. // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
  302. // return;
  303. //}
  304. List<FileBean> list = new List<FileBean>();
  305. FileBean bean = new FileBean();
  306. OpenFileDialog file = new OpenFileDialog();
  307. file.Multiselect = true;
  308. file.Title = "选择需要上传的PDF";
  309. file.Filter = "PDF文件(*.pdf)|*.pdf";
  310. DialogResult drStat;
  311. drStat = file.ShowDialog();
  312. if (drStat == DialogResult.OK)
  313. {
  314. foreach (string fileName in file.FileNames)
  315. {
  316. string name = System.IO.Path.GetFileName(fileName);
  317. if (name.Contains(" "))
  318. {
  319. MessageUtil.ShowWarning("上传的PDF名称不能包含空格!");
  320. return;
  321. }
  322. bean = new FileBean();
  323. bean.setFileName(pdfName+".pdf");
  324. bean.setPathName(filePathNew);
  325. bean.setFile(FileHelper.FileToArray(fileName));
  326. list.Add(bean);
  327. }
  328. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  329. if (isSuccess)
  330. {
  331. //string fileNames = "";
  332. //List<FileBean> fileBeans = FileHelper.Download(filePathNew);
  333. //foreach (var fileBean in fileBeans)
  334. //{
  335. // if (fileNames == "")
  336. // {
  337. // fileNames = filePathNew + fileBean.getFileName();
  338. // }
  339. // else
  340. // {
  341. // fileNames += "#" + filePathNew + fileBean.getFileName();
  342. // }
  343. //}
  344. //UpdatePath(row.GetValue("CODE_JG"), fileNames, UserInfo.GetUserName());
  345. MessageUtil.ShowTips("上传成功!");
  346. row.Cells["CRAFT_NO_JG2"].Value = pdfName + ".pdf";
  347. row.Cells["CRAFT_PATH"].Value = filePathNew;
  348. //var redirectRow = ultraGrid1.Rows.Where(a => a.GetValue("CODE_JG") == codejg).FirstOrDefault();
  349. //if (redirectRow != null)
  350. //{
  351. // redirectRow.Activate();
  352. //}
  353. }
  354. else
  355. {
  356. MessageUtil.ShowTips("上传失败,请重试!");
  357. }
  358. }
  359. }
  360. else
  361. {
  362. //string filePath = row.GetValue("CRAFT_PATH");
  363. //if (filePath.Equals(""))
  364. //{
  365. // MessageUtil.ShowError("二级工艺文件不能为空!");
  366. // return;
  367. //}
  368. //dlgOrderAskDown askDown = new dlgOrderAskDown(_ob, filePath);
  369. //askDown.Show();
  370. string pk =row.Cells["PK"].Text.ToString();
  371. if (pk.Equals(""))
  372. {
  373. MessageUtil.ShowTips("请先保存工艺文件!");
  374. return;
  375. }
  376. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess3.cpt"
  377. + "&ORDER_NO=" + _orderNo;
  378. FrmRepExcel down = new FrmRepExcel(ob, strurl);
  379. down.Text = "接箍二级工艺";
  380. down.Visible = false;
  381. down.Size = new Size(740, this.Height);
  382. down.WindowState = FormWindowState.Maximized;
  383. down.ShowDialog();
  384. }
  385. }
  386. /// <summary>
  387. /// 调用报表服务器生成PDF并上传到FTP服务器。
  388. /// </summary>
  389. /// <param name="craftOrdDesignList"></param>
  390. /// <returns></returns>
  391. public bool CreatePdfToFtp(string pdfName)
  392. {
  393. return true;
  394. }
  395. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  396. {
  397. UltraGridRow row = ultraGrid1.ActiveRow;
  398. string src = DateTime.Now.ToString("yy");
  399. string str = "GY3-J-" + src + "-";
  400. if (row == null)
  401. {
  402. row.Cells["CRAFT_SEQ2"].Value = "1";
  403. }
  404. row.Cells["CRAFT_NO_JG2"].Value = _codeJg + _jgKey;
  405. if (row.Cells["PK"].Text.Equals(""))
  406. {
  407. //查询最大工艺序号
  408. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doMaxCraftSeq", new object[] { _key }, _ob);
  409. if (dt.Rows.Count > 0)
  410. {
  411. row.Cells["CRAFT_SEQ2"].Value = int.Parse(dt.Rows[0]["CRAFT_SEQ2"].ToString()) + 1;
  412. }
  413. else
  414. {
  415. row.Cells["CRAFT_SEQ2"].Value = "1";
  416. }
  417. //查询合同接箍一级备注
  418. DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryOrderJgMemo", new object[] { _orderNo }, _ob);
  419. if (dt1.Rows.Count > 0)
  420. {
  421. row.Cells["MEMO2"].Value = dt1.Rows[0]["MEMO"].ToString();
  422. }
  423. //查询最大编号
  424. DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryNumBeiMax", new object[] { str }, _ob);
  425. if (dt2.Rows.Count > 0)
  426. {
  427. row.Cells["NUMBERS"].Value = dt2.Rows[0]["NUMBERS"].ToString();
  428. }
  429. else
  430. {
  431. row.Cells["NUMBERS"].Value = str + "0001";
  432. }
  433. }
  434. }
  435. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  436. {
  437. //string memo2 = "";
  438. UltraGridRow row = ultraGrid1.ActiveRow;
  439. //if (row == null)
  440. //UltraTextEditor textEditor = (UltraTextEditor)sender;
  441. PopupTextBox popupText = new PopupTextBox(row.Cells["MEMO1"].Text.ToString(), 1000);
  442. if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  443. {
  444. row.Cells["MEMO1"].Value = popupText.TextInfo.Trim();
  445. }
  446. }
  447. private void ultraTextEditor2_EditorButtonClick(object sender, EditorButtonEventArgs e)
  448. {
  449. UltraGridRow row = ultraGrid1.ActiveRow;
  450. //if (row == null)
  451. //UltraTextEditor textEditor = (UltraTextEditor)sender;
  452. PopupTextBox popupText = new PopupTextBox(row.Cells["CONTENT"].Text.ToString(), 1000);
  453. if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  454. {
  455. row.Cells["CONTENT"].Value = popupText.TextInfo.Trim();
  456. }
  457. }
  458. private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  459. {
  460. UltraGridRow row = ultraGrid1.ActiveRow;
  461. PopupTextBox popupText = new PopupTextBox(row.Cells["MEMO2"].Text.ToString(), 1000);
  462. if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  463. {
  464. row.Cells["MEMO2"].Value = popupText.TextInfo.Trim();
  465. }
  466. }
  467. }
  468. }