FrmBcPipeApplPro.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. using com.steering.mes.mcp.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Server;
  5. using Core.Mes.Client.Comm.Tool;
  6. using Core.StlMes.Client.Mcp.BaseMethod;
  7. using Core.StlMes.Client.Mcp.CollarMaterial;
  8. using Core.StlMes.Client.Mcp.Common;
  9. using Core.StlMes.Client.Mcp.Control;
  10. using Core.StlMes.Client.Mcp.Control.Base;
  11. using Core.StlMes.Client.Mcp.Entity;
  12. using CoreFS.CA06;
  13. using Infragistics.Win;
  14. using Infragistics.Win.UltraWinGrid;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Data;
  20. using System.Drawing;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Windows.Forms;
  24. namespace Core.StlMes.Client.Mcp.Coupling
  25. {
  26. public partial class FrmBcPipeApplPro : FrmBase
  27. {
  28. private string[] arr = null;
  29. private string[] starts = { };
  30. private string departm = "";//获取部门ID
  31. private string[] plineCode = null;//获取产线代码
  32. private string cutGx = "";//交库工序
  33. private string num = "";//支数
  34. private string pwt = "";//重量
  35. public FrmBcPipeApplPro()
  36. {
  37. InitializeComponent();
  38. this.IsLoadUserView = true;
  39. }
  40. private void FrmBcPipeApplPro_Load(object sender, EventArgs e)
  41. {
  42. DateTime now = DateTime.Now;
  43. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  44. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  45. this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  46. this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  47. EntityHelper.ShowGridCaption<MatBcMEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  48. EntityHelper.ShowGridCaption<Core.StlMes.Client.Mcp.Entity.PlnSaleordEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  49. EntityHelper.ShowGridCaption<com.steering.mes.mcp.entity.QcmZgJugdeApplyEntity>(ultraGrid3.DisplayLayout.Bands[0]);
  50. this.IsLoadUserView = true;
  51. arr = this.ValidDataPurviewIds;
  52. DataTable dt = TubeRoll.GetComBaseInfo("4100", ob);
  53. cmbDeliveryState.DataSource = dt;
  54. cmbDeliveryState.ValueMember = "BASECODE";
  55. cmbDeliveryState.DisplayMember = "BASENAME";
  56. TubeRoll.SetComboItemHeight(cmbDeliveryState);
  57. QuerySinglePlan();
  58. }
  59. public override void ToolBar_Click(object sender, string ToolbarKey)
  60. {
  61. switch (ToolbarKey)
  62. {
  63. case "Query":
  64. if (ultraTabControl1.SelectedTab.Index == 0)
  65. {
  66. QuerySinglePlan();
  67. }
  68. else if (ultraTabControl1.SelectedTab.Index == 1)
  69. {
  70. QueryZgJugdeApply();
  71. }
  72. break;
  73. case "DoDecision":
  74. DoDecision();//转成品
  75. break;
  76. case "cancelDoDecision":
  77. cancelDoDecision();//撤销申请判定
  78. break;
  79. case "insertProssWt":
  80. insertProssWt();
  81. break;
  82. case "Export":
  83. if (this.ultraTabControl1.Tabs[0].Active)
  84. {
  85. GridHelper.ulGridToExcel(ultraGrid1, "半成品管信息");
  86. }
  87. else if (this.ultraTabControl1.Tabs[1].Active)
  88. {
  89. GridHelper.ulGridToExcel(ultraGrid3, "成品管信息");
  90. }
  91. break;
  92. case "DoClose":
  93. this.Close();
  94. break;
  95. }
  96. }
  97. /// <summary>
  98. /// 查询送判数据
  99. /// </summary>
  100. private void QueryZgJugdeApply()
  101. {
  102. string Woid = "";
  103. string jugeNo = "";
  104. string startTim = "";
  105. string endTim = "";
  106. ArrayList list = new ArrayList();
  107. if (this.chkJuNo.Checked && this.txtJudgeStoveNO.Text.Trim() != "")
  108. {
  109. jugeNo = this.txtJudgeStoveNO.Text.Trim();
  110. }
  111. if (chkTim2.Checked)
  112. {
  113. if (DateTime.Parse(this.StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  114. {
  115. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  116. return;
  117. }
  118. else
  119. {
  120. startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  121. endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  122. }
  123. }
  124. list.Add(startTim);
  125. list.Add(endTim);
  126. list.Add(jugeNo);
  127. list.Add(this.ultraOptionSet1.CheckedItem.DataValue.ToString());
  128. list.Add(Woid);
  129. QcmZgJudgebindingSource1.Clear();
  130. List<Core.StlMes.Client.Mcp.Entity.QcmZgJugdeApplyEntity> listSource = EntityHelper.GetData<Core.StlMes.Client.Mcp.Entity.QcmZgJugdeApplyEntity>(
  131. "com.steering.mes.mcp.coup.FrmBcPipeApplPro.QueryZgJugdeApply", new object[] { list, arr }, this.ob);
  132. QcmZgbindingSource.DataSource = listSource;
  133. // WriteTextToGrid();
  134. }
  135. /// <summary>
  136. /// 撤销转成品
  137. /// </summary>
  138. private void cancelDoDecision()
  139. {
  140. this.ultraGrid3.UpdateData();
  141. UltraGridRow uRow = this.ultraGrid3.ActiveRow;
  142. if (uRow == null) return;
  143. string plinCode = uRow.Cells["PlineCode"].Text.ToString();
  144. IQueryable<UltraGridRow> checkMags = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
  145. if (checkMags.Count() == 0)
  146. {
  147. MessageUtil.ShowTips("请选择需要撤销的成品箍信息!");
  148. return;
  149. }
  150. ArrayList parmList = new ArrayList();
  151. foreach (UltraGridRow row in checkMags)
  152. {
  153. Entity.QcmZgJugdeApplyEntity matBcEntity = (Entity.QcmZgJugdeApplyEntity)row.ListObject;
  154. string matEntity = JSONFormat.Format(matBcEntity);
  155. parmList.Add(matEntity);
  156. }
  157. CoreClientParam ccp = new CoreClientParam();
  158. ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro";
  159. ccp.MethodName = "cancelDoDecision";
  160. ccp.ServerParams = new object[] { parmList };
  161. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  162. if (ccp.ReturnCode != -1)
  163. {
  164. if (ccp.ReturnInfo.Equals("撤销成功!"))
  165. {
  166. string applyCode = ccp.ReturnObject.ToString();
  167. QueryZgJugdeApply();
  168. //this.txtMemo.Text = "";
  169. MessageUtil.ShowTips(ccp.ReturnInfo);
  170. }
  171. else
  172. {
  173. MessageUtil.ShowTips(ccp.ReturnInfo);
  174. }
  175. }
  176. }
  177. /// <summary>
  178. /// 查询
  179. /// </summary>
  180. private void QuerySinglePlan()
  181. {
  182. string Woid = "";
  183. string jugeNo = "";
  184. string startTim = "";
  185. string endTim = "";
  186. ArrayList list = new ArrayList();
  187. if (this.chkJuNo.Checked && this.txtJudgeStoveNO.Text.Trim() != "")
  188. {
  189. jugeNo = this.txtJudgeStoveNO.Text.Trim();
  190. }
  191. if (chkTim2.Checked)
  192. {
  193. if (DateTime.Parse(this.StartTime.Value.ToString()) > DateTime.Parse(EndTime.Value.ToString()))
  194. {
  195. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  196. return;
  197. }
  198. else
  199. {
  200. startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  201. endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  202. }
  203. }
  204. list.Add(startTim);
  205. list.Add(endTim);
  206. list.Add(jugeNo);
  207. bindingSource2.Clear();
  208. List<MatBcMEntity> listSource = EntityHelper.GetData<MatBcMEntity>(
  209. "com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryMat", new object[] { list, arr,this.UserInfo.GetDeptid() }, this.ob);
  210. bindingSource2.DataSource = listSource;
  211. GridHelper.RefreshAndAutoSize(ultraGrid1);
  212. }
  213. /// <summary>
  214. /// 编辑区Gird
  215. /// </summary>
  216. /// <param name="sender"></param>
  217. /// <param name="e"></param>
  218. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  219. {
  220. string woid = "";
  221. string judgeNo = "";
  222. UltraGridRow urg = ultraGrid1.ActiveRow;
  223. if (urg == null)
  224. {
  225. return;
  226. }
  227. else
  228. {
  229. woid = urg.Cells["WoId"].Value.ToString();
  230. judgeNo = urg.Cells["JudgeStoveNo"].Value.ToString();
  231. }
  232. ultraGrid1.UpdateData();
  233. if (e.Cell.Column.Key.Equals("ProNum") && urg.Cells["ProNum"].Text != "")
  234. {
  235. if (num != "")
  236. {
  237. urg.Cells["ProWt"].Value = (Convert.ToDouble(urg.Cells["ProNum"].Text) * (Convert.ToDouble(pwt) / Convert.ToDouble(num))).ToString("f3");
  238. }
  239. else
  240. {
  241. MessageUtil.ShowTips("接箍库存为零,请检查!");
  242. return;
  243. }
  244. }
  245. ArrayList list = new ArrayList();
  246. ArrayList array = new ArrayList();
  247. string spec = "";
  248. IQueryable<UltraGridRow> checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  249. List<string> specs = new List<string>();
  250. foreach (UltraGridRow row in checkMags)
  251. {
  252. CouplingMatMEntity matBcEntity = (CouplingMatMEntity)row.ListObject;
  253. if (matBcEntity.SpecJgDesc == null || matBcEntity.SpecJgDesc.Equals(""))
  254. {
  255. MessageUtil.ShowTips("接箍规格为空请检查!");
  256. return;
  257. }
  258. specs.Add(matBcEntity.SpecJgDesc);
  259. }
  260. //spec = "('" + string.Join("','", specs) + "')";
  261. spec = string.Join("','", specs);
  262. List<PlnSaleordEntity> listSource = EntityHelper.GetData<PlnSaleordEntity>(
  263. "com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryMat", new object[] { spec }, this.ob);
  264. CouplingPlnOrdbindingSource.DataSource = listSource;
  265. }
  266. /// <summary>
  267. /// 半成品转成品
  268. /// </summary>
  269. private void DoDecision()
  270. {
  271. this.ultraGrid1.UpdateData();
  272. this.ultraGrid2.UpdateData();
  273. UltraGridRow sRow = this.ultraGrid1.ActiveRow;
  274. if (sRow == null) return;
  275. string PlinCode = sRow.Cells["PlineCode"].Value.ToString();
  276. string judgeNo = sRow.Cells["JudgeStoveNo"].Value.ToString();
  277. string batchNo = sRow.Cells["BatchNo"].Value.ToString();
  278. IQueryable<UltraGridRow> checkMags = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  279. IQueryable<UltraGridRow> checkMags2 = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'");
  280. if (checkMags.Count() != 1)
  281. {
  282. MessageUtil.ShowTips("请选择一个半成品管信息!");
  283. return;
  284. }
  285. if (checkMags2.Count() != 1)
  286. {
  287. MessageUtil.ShowTips("请选择一个成品合同信息!");
  288. return;
  289. }
  290. ArrayList parmList = new ArrayList();
  291. foreach (UltraGridRow row in checkMags)
  292. {
  293. MatBcMEntity matBcEntity = (MatBcMEntity)row.ListObject;
  294. string matEntity = JSONFormat.Format(matBcEntity);
  295. parmList.Add(matEntity);
  296. }
  297. ArrayList list = new ArrayList();
  298. foreach (UltraGridRow row in checkMags2)
  299. {
  300. PlnSaleordEntity plnSaleEntity = (PlnSaleordEntity)row.ListObject;
  301. plnSaleEntity.DeliveryStateName = row.Cells["DeliveryStateCode"].Text;
  302. string plnEntity = JSONFormat.Format(plnSaleEntity);
  303. list.Add(plnEntity);
  304. }
  305. CoreClientParam ccp = new CoreClientParam();
  306. ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro";
  307. ccp.MethodName = "doDecision";
  308. ccp.ServerParams = new object[] { parmList,UserInfo.GetUserName(),list };
  309. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  310. if (ccp.ReturnCode != -1)
  311. {
  312. if (ccp.ReturnInfo.Equals("转成品管成功!"))
  313. {
  314. QuerySinglePlan();
  315. MessageUtil.ShowTips("转成品管成功!");
  316. }
  317. else
  318. {
  319. MessageUtil.ShowTips(ccp.ReturnInfo);
  320. }
  321. }
  322. }
  323. /// <summary>
  324. /// 回填过磅重量
  325. /// </summary>
  326. private void insertProssWt()
  327. {
  328. this.ultraGrid3.UpdateData();
  329. UltraGridRow uRow = this.ultraGrid3.ActiveRow;
  330. if (uRow == null) return;
  331. IQueryable<UltraGridRow> checkMags = this.ultraGrid3.Rows.AsQueryable().Where(" CHK = 'True'");
  332. if (checkMags.Count() == 0)
  333. {
  334. MessageUtil.ShowTips("请选择需要回报过磅重量的炉信息!");
  335. return;
  336. }
  337. if (Double.Parse(uRow.Cells["ActWeight"].Value.ToString3()) <= 0)
  338. {
  339. MessageUtil.ShowTips("请输入正确的过磅重量!");
  340. return;
  341. }
  342. ArrayList parmList = new ArrayList();
  343. foreach (UltraGridRow row in checkMags)
  344. {
  345. Entity.QcmZgJugdeApplyEntity matBcEntity = (Entity.QcmZgJugdeApplyEntity)row.ListObject;
  346. string matEntity = JSONFormat.Format(matBcEntity);
  347. parmList.Add(matEntity);
  348. }
  349. CoreClientParam ccp = new CoreClientParam();
  350. ccp.ServerName = "com.steering.mes.mcp.coup.FrmBcPipeApplPro";
  351. ccp.MethodName = "insertProssWt";
  352. ccp.ServerParams = new object[] { parmList };
  353. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  354. if (ccp.ReturnCode != -1)
  355. {
  356. if (ccp.ReturnInfo.Equals("回报成功!"))
  357. {
  358. QueryZgJugdeApply();
  359. MessageUtil.ShowTips(ccp.ReturnInfo);
  360. }
  361. else
  362. {
  363. MessageUtil.ShowTips(ccp.ReturnInfo);
  364. }
  365. }
  366. }
  367. private void chkStarts_CheckedChanged(object sender, EventArgs e)
  368. {
  369. if (chkJuNo.Checked) { txtJudgeStoveNO.Enabled = true; } else { txtJudgeStoveNO.Enabled = false; }
  370. // if (chkPlnNo.Checked) { txtPlnNo.Enabled = true; } else { txtPlnNo.Enabled = false; }
  371. //if (chkwoId.Checked) { txtWoId.Enabled = true; } else { txtWoId.Enabled = false; }
  372. }
  373. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  374. {
  375. if (toolMenu == null) return;
  376. if (ultraTabControl1.SelectedTab.Index == 0)
  377. {
  378. chkTim2.Text = "入库日期";
  379. toolMenu.Toolbars[0].Tools["DoDecision"].InstanceProps.Visible = DefaultableBoolean.True;
  380. toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.False;
  381. }
  382. else if (ultraTabControl1.SelectedTab.Index == 1)
  383. {
  384. chkTim2.Text = "送判日期";
  385. toolMenu.Toolbars[0].Tools["DoDecision"].InstanceProps.Visible = DefaultableBoolean.False;
  386. toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.True;
  387. }
  388. }
  389. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  390. {
  391. //规格关联改物料码关联
  392. UltraGridRow urg = ultraGrid1.ActiveRow;
  393. //List<PlnSaleordEntity> listSource = EntityHelper.GetData<PlnSaleordEntity>
  394. // ("com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryplnSaleorder", new object[] { urg.Cells["SpecName"].Value.ToString(), urg.Cells["ProcessCdoe"].Value.ToString() }, this.ob);
  395. List<PlnSaleordEntity> listSource = EntityHelper.GetData<PlnSaleordEntity>
  396. ("com.steering.mes.mcp.coup.FrmBcPipeApplPro.doQueryplnSaleorder2", new object[] { urg.Cells["MaterialName"].Value.ToString(), urg.Cells["ProcessCdoe"].Value.ToString() }, this.ob);
  397. CouplingPlnOrdbindingSource.DataSource = listSource;
  398. GridHelper.RefreshAndAutoSize(ultraGrid2);
  399. }
  400. private void ultraGrid3_ClickCellButton(object sender, CellEventArgs e)
  401. {
  402. this.ultraGrid3.UpdateData();
  403. if (e.Cell.Column.Key == "JugdeApplyCode")
  404. {
  405. string jugdeApplyCode = ultraGrid3.ActiveRow.Cells["JugdeApplyCode"].Value.ToString();
  406. string judgeStoveNo = ultraGrid3.ActiveRow.Cells["JudgeStoveNo"].Value.ToString();
  407. string ordenNo = ultraGrid3.ActiveRow.Cells["ProOrderNo"].Value.ToString();
  408. FrmQcmAddAsk orderZg = new FrmQcmAddAsk(jugdeApplyCode, judgeStoveNo, ordenNo, this.ob);
  409. orderZg.ShowDialog();
  410. }
  411. }
  412. private void FrmBcPipeApplPro_Shown(object sender, EventArgs e)
  413. {
  414. if (toolMenu == null) return;
  415. if (toolMenu.Toolbars[0].Tools.Exists("cancelDoDecision"))
  416. {
  417. toolMenu.Toolbars[0].Tools["cancelDoDecision"].InstanceProps.Visible = DefaultableBoolean.False;
  418. }
  419. }
  420. }
  421. }