FrmGpApplyDecision.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.YdmStuffManage.Entity;
  5. using CoreFS.CA06;
  6. using Infragistics.Win;
  7. using Infragistics.Win.UltraWinEditors;
  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.Net;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.YdmStuffManage
  20. {
  21. public partial class FrmGpApplyDecision : FrmBase
  22. {
  23. public FrmGpApplyDecision()
  24. {
  25. InitializeComponent();
  26. }
  27. private string plineCode = "";//产线
  28. private string[] arr = null;
  29. private void FrmGpApplyDecision_Load(object sender, EventArgs e)
  30. {
  31. DateTime now = DateTime.Now;
  32. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  33. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  34. this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  35. this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  36. switch(this.CustomInfo)
  37. {
  38. case"LG":
  39. arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob);
  40. this.entityGrid1.DisplayLayout.Bands[0].Columns["SoureName"].Hidden = true;
  41. break;
  42. case"DZ":
  43. arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"C", this.ob);
  44. this.entityGrid1.DisplayLayout.Bands[0].Columns["SoureName"].Hidden = true;
  45. break;
  46. }
  47. plineCode = BaseMethod.GetPCode(UserInfo.GetDepartment(),ob);
  48. }
  49. /// <summary>
  50. /// 重写基类方法
  51. /// </summary>
  52. /// <param name="sender"></param>
  53. /// <param name="ToolbarKey"></param>
  54. public override void ToolBar_Click(object sender, string ToolbarKey)
  55. {
  56. switch (ToolbarKey)
  57. {
  58. case "DoQueryMat":
  59. QueryMat();
  60. break;
  61. case "DoDecision":
  62. DoDecision();
  63. break;
  64. case "cancelDoDecision":
  65. cancelDoDecision();
  66. break;
  67. case"UploadingSuface":
  68. uploadingSuface();
  69. break;
  70. case "insertProssWt":
  71. insertProssWt();
  72. break;
  73. case "Close":
  74. this.Close();
  75. break;
  76. }
  77. }
  78. /// <summary>
  79. /// 回填过磅重量
  80. /// </summary>
  81. private void insertProssWt()
  82. {
  83. this.entityGrid2.UpdateData();
  84. UltraGridRow row = this.entityGrid1.ActiveRow;
  85. string departMentid = UserInfo.GetDeptid();
  86. if (row == null)
  87. {
  88. return;
  89. }
  90. IQueryable<UltraGridRow> checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  91. if (checkMagRows.Count() == 0)
  92. {
  93. MessageUtil.ShowTips("请选择需要申请判定的主信息!");
  94. return;
  95. }
  96. ArrayList parm = new ArrayList();
  97. foreach (UltraGridRow uRow in checkMagRows)
  98. {
  99. foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows)
  100. {
  101. if (Double.Parse(childRow.Cells["PonderGrossWt"].Value.ToString3()) <= 0)
  102. {
  103. MessageUtil.ShowTips("请输入正确的过磅重量!");
  104. return;
  105. }
  106. if (!childRow.Cells["JugdeApplyCode"].Value.ToString().Equals(""))
  107. {
  108. MessageUtil.ShowTips("已送判不能回报过磅重量!");
  109. return;
  110. }
  111. MatGpMEntity matGp = (MatGpMEntity)childRow.ListObject;
  112. string matGpEntity = JSONFormat.Format(matGp);
  113. parm.Add(matGpEntity);
  114. }
  115. }
  116. CoreClientParam ccp = new CoreClientParam();
  117. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision";
  118. ccp.MethodName = "insertProssWt";
  119. ccp.ServerParams = new object[] { parm, departMentid };
  120. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  121. if (ccp.ReturnCode != -1)
  122. {
  123. if (ccp.ReturnInfo.Equals("回报成功!"))
  124. {
  125. QueryMat();
  126. //MatZcMEntity2bindingSource.Clear();
  127. MessageUtil.ShowTips(ccp.ReturnInfo);
  128. }
  129. else
  130. {
  131. MessageUtil.ShowTips(ccp.ReturnInfo);
  132. }
  133. }
  134. }
  135. private void uploadingSuface()
  136. {
  137. this.entityGrid1.UpdateData();
  138. UltraGridRow uRow = this.entityGrid1.ActiveRow;
  139. if (uRow == null)
  140. {
  141. return;
  142. }
  143. string plineCode = uRow.Cells["PlineCode"].Text;
  144. string judgeNo = uRow.Cells["JudgeStoveNo"].Text;
  145. string path = "LgMil/surfcacReprot" + "/" + "C005" + "/" + judgeNo + "/";
  146. string name = plineCode + judgeNo + ".pdf";
  147. List<FileBean> list = new List<FileBean>();
  148. FileBean bean = new FileBean();
  149. OpenFileDialog file = new OpenFileDialog();
  150. file.Multiselect = false;
  151. file.Title = "选择需要上传的文件";
  152. file.Filter = "PDF Document(*.pdf)|*.pdf";
  153. DialogResult drStat;
  154. drStat = file.ShowDialog();
  155. if (drStat == DialogResult.OK)
  156. {
  157. foreach (string fileName in file.FileNames)
  158. {
  159. //string name = System.IO.Path.GetFileName(fileName);
  160. bean = new FileBean();
  161. bean.setFileName(name);
  162. bean.setPathName(path);
  163. bean.setFile(FileHelper.FileToArray(fileName));
  164. list.Add(bean);
  165. }
  166. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  167. if (isSuccess)
  168. {
  169. int count = ServerHelper.SetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.updateSurfaceDz", new object[] { path, judgeNo }, ob);
  170. if (count > 0)
  171. {
  172. MessageUtil.ShowTips("上传成功!");
  173. }
  174. else
  175. {
  176. MessageUtil.ShowTips("上传失败,请重试!");
  177. }
  178. }
  179. else
  180. {
  181. MessageUtil.ShowTips("上传失败,请重试!");
  182. }
  183. }
  184. }
  185. /// <summary>
  186. /// 查询炉计划信息
  187. /// </summary>
  188. private void QueryMat()
  189. {
  190. string plinCode = "";
  191. string stoveNo = "";
  192. string jugeNo = "";
  193. string startTim = "";
  194. string endTim = "";
  195. ArrayList list = new ArrayList();
  196. //string departId = this.UserInfo.GetDeptid();
  197. if (this.chkStove.Checked && this.txtStoveNo.Text.Trim() != "")
  198. {
  199. stoveNo = this.txtStoveNo.Text.Trim();
  200. }
  201. if (this.chkJudgeStoveNo.Checked && this.txtJudgeStoveNo.Text.Trim() != "")
  202. {
  203. jugeNo = this.txtJudgeStoveNo.Text.Trim();
  204. }
  205. if (chkTim2.Checked)
  206. {
  207. if (DateTime.Parse(this.StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  208. {
  209. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  210. return;
  211. }
  212. else
  213. {
  214. startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  215. endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  216. }
  217. }
  218. list.Add(stoveNo);
  219. list.Add(jugeNo);
  220. MatGpEntitybindingSource.Clear();
  221. List<MatGpMEntity> listSource = null;
  222. switch(this.CustomInfo)
  223. {
  224. case"LG":
  225. listSource = EntityHelper.GetData<MatGpMEntity>(
  226. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMat", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), arr,this.ValidDataPurviewIds }, this.ob);
  227. break;
  228. case"DZ":
  229. listSource = EntityHelper.GetData<MatGpMEntity>(
  230. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMat", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), arr,this.ValidDataPurviewIds }, this.ob);
  231. break;
  232. case"WG":
  233. listSource = EntityHelper.GetData<MatGpMEntity>(
  234. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatWG", new object[] { list, startTim, endTim, this.ultraOptionSet1.CheckedItem.DataValue.ToString(), this.UserInfo.GetDeptid() }, this.ob);
  235. break;
  236. }
  237. matGpMEntityBindingSource.DataSource = listSource;
  238. }
  239. /// <summary>
  240. /// 申请判定
  241. /// </summary>
  242. private void DoDecision()
  243. {
  244. this.entityGrid2.UpdateData();
  245. string cic = "";
  246. UltraGridRow row = this.entityGrid1.ActiveRow;
  247. MatGpMEntity matGpInfo = (MatGpMEntity)row.ListObject;
  248. string matGpinfoEntity = JSONFormat.Format(matGpInfo);
  249. if (row == null)
  250. {
  251. return;
  252. }
  253. IQueryable<UltraGridRow> checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  254. if (checkMagRows.Count() == 0)
  255. {
  256. MessageUtil.ShowTips("请选择需要申请判定的主信息!");
  257. return;
  258. }
  259. if(this.cicChk.Checked)
  260. {
  261. cic = this.txtCic.Text;
  262. }
  263. //if (!doQueryNode(row.Cells["StoveNo"].Text))
  264. //{
  265. // MessageUtil.ShowTips("交库点存在未结炉,不允许申请判定!");
  266. // return;
  267. //}
  268. ArrayList parm = new ArrayList();
  269. foreach (UltraGridRow uRow in checkMagRows)
  270. {
  271. foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows)
  272. {
  273. MatGpMEntity matGp = (MatGpMEntity)childRow.ListObject;
  274. string matGpEntity = JSONFormat.Format(matGp);
  275. parm.Add(matGpEntity);
  276. }
  277. }
  278. CoreClientParam ccp = new CoreClientParam();
  279. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision";
  280. ccp.MethodName = "doDecision";
  281. ccp.ServerParams = new object[] { parm, row.Cells["StoveNo"].Text, plineCode, UserInfo.GetUserName(), this.CustomInfo, UserInfo.GetUserOrder(), UserInfo.GetUserGroup(), this.txtMemo.Text.Trim(), cic, matGpinfoEntity };
  282. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  283. if (ccp.ReturnCode != -1)
  284. {
  285. if (ccp.ReturnInfo.Equals("申请判定成功!"))
  286. {
  287. QueryMat();
  288. MessageUtil.ShowTips(ccp.ReturnInfo);
  289. }
  290. else
  291. {
  292. MessageUtil.ShowTips(ccp.ReturnInfo);
  293. }
  294. }
  295. }
  296. /// <summary>
  297. /// 查询是否该炉已交库结炉
  298. /// </summary>
  299. /// <param name="jugeNo"></param>
  300. /// <param name="plineCode"></param>
  301. /// <returns></returns>
  302. private Boolean doQueryNode(string stoveNo)
  303. {
  304. bool node = false;
  305. DataTable ds = new DataTable();
  306. switch (this.CustomInfo)
  307. {
  308. case"LG":
  309. ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryNode", new object[] { stoveNo }, ob);
  310. break;
  311. case"DZ":
  312. ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryNode", new object[] { stoveNo }, ob);
  313. break;
  314. }
  315. if (int.Parse(ds.Rows[0][0].ToString()) > 0)
  316. {
  317. node = true;
  318. }
  319. return node;
  320. }
  321. /// <summary>
  322. /// 撤销申请判定
  323. /// </summary>
  324. private void cancelDoDecision()
  325. {
  326. this.entityGrid2.UpdateData();
  327. IQueryable<UltraGridRow> checkMagRows = this.entityGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  328. if (checkMagRows.Count() == 0)
  329. {
  330. MessageUtil.ShowTips("请选择需要撤销申请判定的主信息!");
  331. return;
  332. }
  333. ArrayList parm = new ArrayList();
  334. foreach (UltraGridRow uRow in checkMagRows)
  335. {
  336. foreach (UltraGridRow childRow in uRow.ChildBands[0].Rows)
  337. {
  338. MatGpMEntity matZcTity = (MatGpMEntity)childRow.ListObject;
  339. string matTity = JSONFormat.Format(matZcTity);
  340. parm.Add(matTity);
  341. }
  342. }
  343. if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return;
  344. CoreClientParam ccp = new CoreClientParam();
  345. ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision";
  346. ccp.MethodName = "cancelDoDecision";
  347. ccp.ServerParams = new object[] { parm };
  348. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  349. if (ccp.ReturnCode != -1)
  350. {
  351. if (ccp.ReturnInfo.Equals("撤销成功!"))
  352. {
  353. QueryMat();
  354. MessageUtil.ShowTips(ccp.ReturnInfo);
  355. }
  356. else
  357. {
  358. MessageUtil.ShowTips(ccp.ReturnInfo);
  359. }
  360. }
  361. }
  362. private void entityGrid1_AfterRowActivate(object sender, EventArgs e)
  363. {
  364. UltraGridRow uRow = this.entityGrid1.ActiveRow;
  365. string[] L1 = null;
  366. string[] L2 = null;
  367. List<MatGpMEntity1> listSource = null;
  368. List<MatGpMEntity> listSource1 = null;
  369. MatGpEntitybindingSource.Clear();
  370. if (this.CustomInfo.Equals("WG"))
  371. {
  372. L1 = new string[] { "StoveNo", "JudgeStoveNo","FixLen" };
  373. L2 = new string[] { "StoveNo", "JudgeStoveNo","FixLen" };
  374. listSource = EntityHelper.GetData<MatGpMEntity1>(
  375. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataWG", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob);
  376. listSource1 = EntityHelper.GetData<MatGpMEntity>(
  377. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataFixNumWG", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob);
  378. }
  379. else
  380. {
  381. L1 = new string[] { "Furnaceno", "StoveNo", "JudgeStoveNo" };
  382. L2 = new string[] { "Furnaceno", "StoveNo", "JudgeStoveNo" };
  383. listSource = EntityHelper.GetData<MatGpMEntity1>(
  384. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatData", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["Furnaceno"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob);
  385. listSource1 = EntityHelper.GetData<MatGpMEntity>(
  386. "Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryMatDataFixNum", new object[] { uRow.Cells["StoveNo"].Text, uRow.Cells["JudgeStoveNo"].Text, uRow.Cells["Furnaceno"].Text,uRow.Cells["FixLen"].Text, this.ultraOptionSet1.CheckedItem.DataValue.ToString() }, this.ob);
  387. }
  388. EntityHelper.AddEntityRelation(listSource, listSource1, L1, L2);
  389. MatGpEntitybindingSource.DataSource = listSource;
  390. foreach (UltraGridRow ugr in this.entityGrid2.Rows)
  391. {
  392. ugr.Cells["CHK"].Value = true;
  393. }
  394. }
  395. private void chkTim2_CheckedChanged(object sender, EventArgs e)
  396. {
  397. this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim2.Checked;
  398. }
  399. private void txtStoveNo_KeyDown(object sender, KeyEventArgs e)
  400. {
  401. if(e.KeyValue == 13)
  402. {
  403. QueryMat();
  404. }
  405. }
  406. private void FrmGpApplyDecision_Shown(object sender, EventArgs e)
  407. {
  408. if (toolMenu == null) return;
  409. if (this.CustomInfo.Equals("WG") || this.CustomInfo.Equals("LG"))
  410. {
  411. if (toolMenu.Toolbars[0].Tools.Exists("UploadingSuface"))
  412. {
  413. toolMenu.Toolbars[0].Tools["UploadingSuface"].InstanceProps.Visible = DefaultableBoolean.False;
  414. }
  415. }
  416. }
  417. private void txtMemo_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  418. {
  419. UltraTextEditor textEditor = (UltraTextEditor)sender;
  420. PopupTextBox popupText = new PopupTextBox(textEditor.Text, 500);
  421. if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  422. {
  423. textEditor.Text = popupText.TextInfo.Trim();
  424. }
  425. }
  426. private void txtCic_EditorButtonClick(object sender, EditorButtonEventArgs e)
  427. {
  428. this.entityGrid1.UpdateData();
  429. UltraGridRow uRow = this.entityGrid1.ActiveRow;
  430. if (uRow == null)
  431. {
  432. return;
  433. }
  434. DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGpApplyDecision.doQueryCic",
  435. new object[] { uRow.Cells["Gradename"].Text }, ob);
  436. dt.Columns["BASENAME"].Caption = "CIC";
  437. BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "BASENAME", "BASECODE");
  438. baseInfo.Shown += new EventHandler((a, b) =>
  439. {
  440. var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where(
  441. c => c.GetValue("BASECODE") == this.txtCic.Tag.ToString2()).FirstOrDefault();
  442. if (actRow != null) actRow.Activate();
  443. });
  444. if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  445. {
  446. txtCic.Tag = baseInfo.ChoicedRow.GetValue("BASECODE");
  447. txtCic.Text = baseInfo.ChoicedRow.GetValue("BASENAME");
  448. }
  449. }
  450. private void chkStove_CheckedChanged(object sender, EventArgs e)
  451. {
  452. this.txtStoveNo.Enabled = this.chkStove.Checked;
  453. }
  454. private void chkJudgeStoveNo_CheckedChanged(object sender, EventArgs e)
  455. {
  456. this.txtJudgeStoveNo.Enabled = this.chkJudgeStoveNo.Checked;
  457. }
  458. }
  459. }