FrmMilReSample.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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.ZGMil.Common;
  5. using Core.StlMes.Client.ZGMil.Entity;
  6. using Core.StlMes.Client.ZGMil.ResultConrtrol;
  7. using Core.StlMes.Client.ZGMil.Signature;
  8. using CoreFS.CA06;
  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.Linq;
  17. using System.Text;
  18. using System.Windows.Forms;
  19. namespace Core.StlMes.Client.ZGMil.Result
  20. {
  21. public partial class FrmMilReSample : FrmBase
  22. {
  23. private string departm = "";
  24. private string plineCode = "";
  25. private string userName = "";
  26. private string proPlanId = null;//轧管订单编号
  27. private string gxPlanNo = null;//工序排产序号
  28. public FrmMilReSample()
  29. {
  30. InitializeComponent();
  31. this.IsLoadUserView = true;
  32. }
  33. /// <summary>
  34. /// 重写基类方法
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="ToolbarKey"></param>
  38. public override void ToolBar_Click(object sender, string ToolbarKey)
  39. {
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. doQuery();
  44. break;
  45. case "Node":
  46. doNode();
  47. break;
  48. case "DoNodeBack":
  49. doNodeBack();
  50. break;
  51. //case "Export":
  52. // ExportData();
  53. // break;
  54. case "Close":
  55. this.Close();
  56. break;
  57. }
  58. }
  59. /// <summary>
  60. /// 结炉回退
  61. /// </summary>
  62. private void doNodeBack()
  63. {
  64. if (this.dataTable1.Rows.Count > 0 && this.dataTable2.Rows.Count > 0)
  65. {
  66. UltraGridRow ugr = ultraGrid1.ActiveRow;
  67. UltraGridRow ugr2 = ultraGrid2.ActiveRow;
  68. string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态
  69. string JudgeStoveNo = BaseMethod.getJudgeStoveNo(ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString());
  70. string LotNo = ugr2.Cells["LOT_NO"].Value.ToString();
  71. string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString();
  72. string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态
  73. if (APPLY_FLAG != "未送判")
  74. {
  75. MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  76. return;
  77. }
  78. if (reSampleSatus == "0")
  79. {
  80. MessageBox.Show("该炉没有结炉,不可结炉回退,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  81. return;
  82. }
  83. if (MessageUtil.ShowYesNoAndQuestion("确认炉号【" + JudgeStoveNo + "】结炉回退?") == DialogResult.No)
  84. {
  85. return;
  86. }
  87. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.doNodeBack", new object[] { JudgeStoveNo, LotNo, PlineCode, userName, proPlanId, gxPlanNo }, this.ob);
  88. }
  89. doQuery();
  90. }
  91. /// <summary>
  92. /// 结炉
  93. /// </summary>
  94. private void doNode()
  95. {
  96. if (this.dataTable1.Rows.Count > 0 && this.dataTable2.Rows.Count >0)
  97. {
  98. UltraGridRow ugr = ultraGrid1.ActiveRow;
  99. UltraGridRow ugr2 = ultraGrid2.ActiveRow;
  100. string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态
  101. string JudgeStoveNo = ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString().Substring(0,6);
  102. string LotNo = ugr2.Cells["LOT_NO"].Value.ToString();
  103. string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString();
  104. string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态
  105. if (APPLY_FLAG != "未送判")
  106. {
  107. MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  108. return;
  109. }
  110. if (reSampleSatus == "1")
  111. {
  112. MessageBox.Show("该炉已结炉,不可再结炉,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  113. return;
  114. }
  115. if (MessageUtil.ShowYesNoAndQuestion("确认炉号【" + JudgeStoveNo + "】结炉?") == DialogResult.No)
  116. {
  117. return;
  118. }
  119. CoreClientParam ccp = new CoreClientParam();
  120. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmMilReSample";
  121. ccp.MethodName = "doNode";
  122. ccp.ServerParams = new object[] { JudgeStoveNo, LotNo, PlineCode, userName, proPlanId, gxPlanNo };
  123. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  124. if (ccp.ReturnCode != -1)
  125. {
  126. if (ccp.ReturnInfo.Equals("结炉成功!"))
  127. {
  128. doQuery();
  129. MessageUtil.ShowTips(ccp.ReturnInfo);
  130. }
  131. else
  132. {
  133. MessageUtil.ShowTips(ccp.ReturnInfo);
  134. }
  135. }
  136. }
  137. }
  138. /// <summary>
  139. /// 查询
  140. /// </summary>
  141. private void doQuery()
  142. {
  143. string date = "";
  144. string endDate = "";
  145. string JudgeStoveNo = "";
  146. string LotNo = "";
  147. string ChkReSample = "0";
  148. if (chkDate.Checked)
  149. {
  150. if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
  151. {
  152. MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
  153. return;
  154. }
  155. else
  156. {
  157. date = cmbDate.Value.ToString();
  158. endDate = cmbEndDate.Value.ToString();
  159. }
  160. }
  161. if (chkJudgeStoveNo.Checked)
  162. {
  163. if (uteJudgeStoveNo.Text.Trim() == "")
  164. {
  165. JudgeStoveNo = "";
  166. }
  167. else
  168. {
  169. JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
  170. }
  171. }
  172. if (chkLotNo.Checked)
  173. {
  174. if (uteLotNo.Text.Trim() == "")
  175. {
  176. LotNo = "";
  177. }
  178. else
  179. {
  180. LotNo = uteLotNo.Value.ToString();
  181. }
  182. }
  183. if (chkReSample.Checked)
  184. {
  185. ChkReSample = "1";
  186. }
  187. WaitingForm2 wf = new WaitingForm2("正在加载,请稍候....");
  188. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmMilReSample.getFrmMilReSample", new Object[] { date, endDate, JudgeStoveNo, LotNo, ChkReSample, getPlineCode() }, this.ob);
  189. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  190. GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  191. foreach(UltraGridRow ugr in ultraGrid1.Rows)
  192. {
  193. if (ugr.Cells["APPLY_FLAG"].Value.ToString() == "")
  194. {
  195. ugr.Cells["APPLY_FLAG"].Value = "未送判";
  196. }
  197. if (ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString() == "1")
  198. {
  199. ugr.Appearance.BackColor = Color.YellowGreen;
  200. }
  201. }
  202. if (dt.Rows.Count == 0)
  203. {
  204. this.dataTable2.Clear();
  205. }
  206. wf.Close();
  207. }
  208. /// <summary>
  209. /// 打印
  210. /// </summary>
  211. //private void doExport()
  212. //{
  213. // string date = "";
  214. // string endDate = "";
  215. // string JudgeStoveNo = "";
  216. // string LotNo = "";
  217. // string ContractNo = "";
  218. // if (chkDate.Checked)
  219. // {
  220. // if (DataTimeUtil.JudgeTime(DateTime.Parse(cmbDate.Value.ToString()), DateTime.Parse(cmbEndDate.Value.ToString())) == 0)
  221. // {
  222. // MessageUtil.ShowTips("您所选择的日期区域不对,请重新选择!");
  223. // return;
  224. // }
  225. // else
  226. // {
  227. // date = cmbDate.Value.ToString();
  228. // endDate = cmbEndDate.Value.ToString();
  229. // }
  230. // }
  231. // if (chkJudgeStoveNo.Checked)
  232. // {
  233. // if (uteJudgeStoveNo.Text.Trim() == "")
  234. // {
  235. // JudgeStoveNo = "";
  236. // }
  237. // else
  238. // {
  239. // JudgeStoveNo = uteJudgeStoveNo.Value.ToString();
  240. // }
  241. // }
  242. // if (chkLotNo.Checked)
  243. // {
  244. // if (uteLotNo.Text.Trim() == "")
  245. // {
  246. // LotNo = "";
  247. // }
  248. // else
  249. // {
  250. // LotNo = uteLotNo.Value.ToString();
  251. // }
  252. // }
  253. // if (chkReSample.Checked)
  254. // {
  255. // if (uteContractNo.Text.Trim() == "")
  256. // {
  257. // ContractNo = "";
  258. // }
  259. // else
  260. // {
  261. // ContractNo = uteContractNo.Value.ToString();
  262. // }
  263. // }
  264. // doQuery();
  265. // string url = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilDateStatistics.cpt&__bypagesize__=false&LOT_NO=" + LotNo + "&JUDGE_STOVE_NO=" + JudgeStoveNo + "&DATE=" + date + "&DATE2=" + endDate + "&PLINE_CODE=" + plineCode + "&CONTRACT_NO=" + ContractNo;
  266. // FrmRepExcel fre = new FrmRepExcel(this.ob, url);
  267. // //fre.AutoSize = true;
  268. // fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  269. // fre.Text = "轧管生产数据统计";
  270. // fre.ShowDialog();
  271. //}
  272. /// <summary>
  273. /// 查询条件
  274. /// </summary>
  275. /// <param name="sender"></param>
  276. /// <param name="e"></param>
  277. private void chkDate_CheckedChanged(object sender, EventArgs e)
  278. {
  279. if (chkDate.Checked) { cmbDate.Enabled = true; } else { cmbDate.Enabled = false; }
  280. if (chkDate.Checked) { cmbEndDate.Enabled = true; } else { cmbEndDate.Enabled = false; }
  281. if (chkLotNo.Checked) { uteLotNo.Enabled = true; } else { uteLotNo.Enabled = false; }
  282. if (chkJudgeStoveNo.Checked) { uteJudgeStoveNo.Enabled = true; } else { uteJudgeStoveNo.Enabled = false; }
  283. //if (chkReSample.Checked) { uteContractNo.Enabled = true; } else { uteContractNo.Enabled = false; }
  284. }
  285. private void FrmMilReSample_Load(object sender, EventArgs e)
  286. {
  287. cmbDate.Value = DateTime.Parse(DateTime.Today.ToString());
  288. NativeMethodNew na = new NativeMethodNew(this.ob);
  289. userName = UserInfo.GetUserName();
  290. departm = UserInfo.GetDepartment();
  291. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  292. EntityHelper.ShowGridCaption<PortMilBatchSampleResultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
  293. DateTime now = DateTime.Now;
  294. DateTime date = new DateTime(now.Year, now.Month, 1);
  295. cmbDate.Value = DateTime.Parse(date.ToString("yyyy-MM-dd"));
  296. cmbEndDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  297. //cmbEndDate.Value = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 06:59:59"));
  298. //cmbDate.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 07:00:00"));
  299. //TubeRoll.SetComboItemHeight(uteLotNo);
  300. //TubeRoll.SetComboItemHeight(cmbBz);
  301. }
  302. /// <summary>
  303. /// 导出
  304. /// </summary>
  305. private void ExportData()
  306. {
  307. GridHelper.ulGridToExcel(ultraGrid1, "轧管生产数据统计");
  308. }
  309. /// <summary>
  310. /// 非250、258、168、460的产线代码都为空
  311. /// </summary>
  312. /// <returns></returns>
  313. private string getPlineCode()
  314. {
  315. if (plineCode.Equals("C008") || plineCode.Equals("C009") || plineCode.Equals("C010") || plineCode.Equals("C017"))
  316. {
  317. return plineCode;
  318. }
  319. else
  320. {
  321. return "";
  322. }
  323. }
  324. private void bindingSource1_CurrentChanged(object sender, EventArgs e)
  325. {
  326. }
  327. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  328. {
  329. queryultraGrid2();
  330. }
  331. /// <summary>
  332. /// 刷新ultraGrid2的数据
  333. /// </summary>
  334. private void queryultraGrid2()
  335. {
  336. if (this.dataTable1.Rows.Count > 0)
  337. {
  338. UltraGridRow ugr = ultraGrid1.ActiveRow;
  339. if (ugr != null)
  340. {
  341. string JudgeStoveNo = ugr.Cells["JUDGE_STOVE_NO"].Value.ToString();
  342. string LotNo = ugr.Cells["LOT_NO"].Value.ToString();
  343. string PlineCode = ugr.Cells["PLINE_CODE"].Value.ToString();
  344. proPlanId = ugr.Cells["PRO_PLAN_ID"].Value.ToString();
  345. gxPlanNo = ugr.Cells["GX_PLAN_NO"].Value.ToString();
  346. // List<PortMilBatchSampleResultEntity> listSource = EntityHelper.GetData<PortMilBatchSampleResultEntity>(
  347. //"com.steering.mes.zgmil.coup.FrmMilReSample.getPortMilBatchSampleResult", new object[] { JudgeStoveNo,LotNo, PlineCode }, this.ob);
  348. // bindingSource1.DataSource = listSource;
  349. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmMilReSample.getPortMilBatchSampleResult", new Object[] { JudgeStoveNo, LotNo, getPlineCode(), proPlanId, gxPlanNo }, this.ob);
  350. GridHelper.CopyDataToDatatable(dt, this.dataTable2, true);
  351. GridHelper.RefreshAndAutoSize(this.ultraGrid2);
  352. }
  353. changeColor();
  354. }
  355. }
  356. /// <summary>
  357. /// 更改剔除样管行颜色
  358. /// </summary>
  359. private void changeColor()
  360. {
  361. foreach (UltraGridRow ugr in ultraGrid2.Rows )
  362. {
  363. if (ugr.Cells["STATUS"].Value.ToString() == "复取样废")
  364. {
  365. ugr.Appearance.BackColor = Color.Yellow;
  366. }
  367. }
  368. }
  369. private void ultraGrid2_ClickCellButton(object sender, CellEventArgs e)
  370. {
  371. UltraGridRow ugr = ultraGrid1.ActiveRow;
  372. UltraGridRow ugr2 = ultraGrid2.ActiveRow;
  373. string reSampleSatus = ugr.Cells["RE_GET_SAMPLE_STATUS"].Value.ToString();//复取样完成状态
  374. string JudgeStoveNo = ugr2.Cells["JUDGE_STOVE_NO"].Value.ToString();
  375. string LotNo = ugr2.Cells["LOT_NO"].Value.ToString();
  376. string PlineCode = ugr2.Cells["PLINE_CODE"].Value.ToString();
  377. string matNo = ugr2.Cells["MAT_NO"].Value.ToString();//材料号
  378. string IS_SAMPLE_PIPE = ugr2.Cells["IS_SAMPLE_PIPE"].Value.ToString(); //是否样管
  379. string STATUS = ugr2.Cells["STATUS"].Value.ToString();//状态,是否废
  380. string APPLY_FLAG = ugr.Cells["APPLY_FLAG"].Value.ToString(); //送判状态
  381. string NODE_FUR_FLAG = ugr2.Cells["NODE_FUR_FLAG"].Value.ToString(); //结炉标识(0-未结炉,1-结炉)
  382. string BATCH_NO = ugr2.Cells["BATCH_NO"].Value.ToString(); //批号
  383. if (APPLY_FLAG != "未送判")
  384. {
  385. MessageBox.Show("该炉已送判,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  386. return;
  387. }
  388. if (NODE_FUR_FLAG == "0")
  389. {
  390. MessageBox.Show("该炉未结炉,不能操作复取样!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  391. return;
  392. }
  393. //标记样管
  394. if (e.Cell.Column.Key == "sample1")
  395. {
  396. if (reSampleSatus == "1")
  397. {
  398. MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  399. return;
  400. }
  401. if (IS_SAMPLE_PIPE == "样管")
  402. {
  403. MessageBox.Show("该管已是样管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  404. return;
  405. }
  406. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.changeSampleState", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName }, this.ob);
  407. }
  408. //标记样管回退
  409. if (e.Cell.Column.Key == "noSample")
  410. {
  411. if (reSampleSatus == "1")
  412. {
  413. MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  414. return;
  415. }
  416. if (IS_SAMPLE_PIPE == "非样管")
  417. {
  418. MessageBox.Show("该管已是非样管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  419. return;
  420. }
  421. if (STATUS == "复取样废")
  422. {
  423. MessageBox.Show("该管已是废管,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  424. return;
  425. }
  426. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.changeSampleStateBack", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName }, this.ob);
  427. }
  428. //复取样废
  429. if (e.Cell.Column.Key == "fei")
  430. {
  431. if (reSampleSatus == "1")
  432. {
  433. MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  434. return;
  435. }
  436. if (STATUS == "复取样废")
  437. {
  438. MessageBox.Show("该管已是废管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  439. return;
  440. }
  441. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.scrapSample", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName, BATCH_NO }, this.ob);
  442. }
  443. //复取样废回退
  444. if (e.Cell.Column.Key == "noFei")
  445. {
  446. if (reSampleSatus == "1")
  447. {
  448. MessageBox.Show("该炉已完成复取样,状态不可变,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  449. return;
  450. }
  451. if (STATUS == "正常")
  452. {
  453. MessageBox.Show("该管是正常管,请确认!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  454. return;
  455. }
  456. int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FrmMilReSample.scrapSampleBack", new object[] { JudgeStoveNo, LotNo, PlineCode, matNo, userName, BATCH_NO }, this.ob);
  457. }
  458. queryultraGrid2();
  459. }
  460. }
  461. }