FrmOffLineOperation.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. using com.steering.mes.zgmil.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.ZGMil.Entity;
  7. using CoreFS.CA06;
  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.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.ZGMil.NodeResultQuery
  19. {
  20. public partial class FrmOffLineOperation : FrmBase
  21. {
  22. private OpeBase ob;
  23. public OpeBase Ob
  24. {
  25. get { return ob; }
  26. set { ob = value; }
  27. }
  28. //工序状态:01-矫直1#,02-矫直2#,03-矫直3#,11-ET探伤,12-MT探伤,13-UT探伤
  29. private string node="";
  30. private string test = "";
  31. private string colno = "0";//探伤台号
  32. //可下线支数
  33. private int ScrapNumBefore = 0;
  34. //剔除支数
  35. private int DelNum = 0;
  36. //产线代码
  37. string PlineCod = "";
  38. //点击主计划的炉号
  39. private string heatno = "";
  40. private string stoveno = "";
  41. private string lotno = "";
  42. private string proPlanId = "";//轧管订单编号
  43. private string gxPlanNo = "";//工序排产序号
  44. //工序
  45. private string process = "";
  46. private string labtext = "";
  47. private string qualifiedNum = "";//上倒工序合格支数
  48. //下线实绩表实体类
  49. MilOfflineReslutEntity2 milofflineresult = new MilOfflineReslutEntity2();
  50. /// <summary>
  51. /// 构造函数
  52. /// </summary>
  53. public FrmOffLineOperation()
  54. {
  55. }
  56. public FrmOffLineOperation(string node, OpeBase _ob, string PlineCode, string stoveno, string lotno, string qualifiedNumS, string proPlanId, string gxPlanNo)
  57. {
  58. InitializeComponent();
  59. EntityHelper.ShowGridCaption<MilPlanEntity3>(this.ultraRack.DisplayLayout.Bands[0]);
  60. //if (node.Length == 2)
  61. //{
  62. // this.node = node.Substring(0, 1);
  63. // this.test = node.Substring(1, 1);
  64. //}
  65. //if (node.Length == 3)
  66. //{
  67. // this.node = node.Substring(0, 1);
  68. // this.test = node.Substring(1, 1);
  69. // this.colno = node.Substring(2, 1);
  70. //}
  71. process = node;
  72. this.Ob = _ob;
  73. this.PlineCod = PlineCode;
  74. this.stoveno = stoveno;
  75. this.lotno = lotno;
  76. this.proPlanId = proPlanId;
  77. this.gxPlanNo = gxPlanNo;
  78. qualifiedNum = qualifiedNumS;
  79. //foreach (UltraGridColumn ugc in ultraRack.DisplayLayout.Bands[0].Columns)
  80. //{
  81. // ugc.CellActivation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  82. //}
  83. Query();
  84. }
  85. private void Query()
  86. {
  87. string jugeNo = this.TxtHeatNo.Text.Trim();
  88. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.GetMILPlan", new object[] { PlineCod,process }, this.ob);
  89. List<MilPlanEntity3> listSource = EntityHelper.GetData<MilPlanEntity3>(
  90. "com.steering.mes.zgmil.coup.FrmOffLine.GetMILPlan", new object[] { PlineCod, process, stoveno, proPlanId, gxPlanNo }, this.ob);
  91. MilPlanEntity3bindingSource.DataSource = listSource;
  92. if (listSource ==null)
  93. {
  94. dtPlan.Rows.Clear();
  95. MessageBox.Show("未查询到可下线计划", "提示:", MessageBoxButtons.OK);
  96. this.TxtHeatNo.Text = "";
  97. //this.TxtHeatNo.Enabled = false;
  98. this.TxtTotalNum.Text = "0";
  99. this.TxtTotalNum.Enabled = false;
  100. this.TxtOfflineNumhas.Text = "0";
  101. this.TxtOfflineNumhas.Enabled = false;
  102. this.TxtOfflinNum.Text = "0";
  103. this.Dispose();
  104. this.Close();
  105. }
  106. }
  107. /// <summary>
  108. /// 表格单击事件
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. private void ultraRack_AfterRowActivate(object sender, EventArgs e)
  113. {
  114. UltraGridRow ugr = this.ultraRack.ActiveRow;
  115. this.TxtTotalNum.Text = "0";
  116. this.TxtOfflinNumBack.Text = "0";
  117. heatno = ugr.Cells["JudgeStoveNo"].Value.ToString();
  118. this.TxtHeatNo.Text = heatno;
  119. //this.TxtHeatNo.Enabled = false;
  120. string s = "";
  121. DataTable ds = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.getOffineCount", new object[] { heatno, PlineCod, proPlanId, gxPlanNo }, ob);
  122. if (ds.Rows.Count > 0)
  123. {
  124. s = ds.Rows[0]["OFFLINE_COUNT"].ToString();
  125. }
  126. this.TxtTotalNum.Text = s;
  127. this.TxtTotalNum.Enabled = false;
  128. DataTable dthas = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.GetCountHAS", new object[] { heatno,process , proPlanId, gxPlanNo}, this.ob);
  129. if (dthas.Rows.Count > 0)
  130. {
  131. this.TxtOfflineNumhas.Text = dthas.Rows[0]["OFFLINE_NUM"].ToString();
  132. this.TxtOfflineNumhas.Enabled = false;
  133. }
  134. else
  135. {
  136. this.TxtOfflineNumhas.Text = "0";
  137. this.TxtOfflineNumhas.Enabled = false;
  138. }
  139. }
  140. /// <summary>
  141. /// 下线操作
  142. /// </summary>
  143. public void Offline()
  144. {
  145. string strInbound = "800707";//入库类型
  146. string strInMemo = "";
  147. NativeMethodNew na = new NativeMethodNew(this.ob);
  148. string plinCode = na.GetPCode(this.UserInfo.GetDepartment());
  149. UltraGridRow ugr1 = this.ultraRack.ActiveRow;
  150. heatno = ugr1.Cells["JudgeStoveNo"].Value.ToString();
  151. int xxOfflineNum = 0; //交库点离线的支数
  152. int hgNum = 0; //合格品支数
  153. if (string.IsNullOrEmpty(heatno)||ultraRack.ActiveRow==null)
  154. {
  155. MessageBox.Show("未选择计划行,不允许进行下线操作","提示:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
  156. return;
  157. }
  158. if (!string.IsNullOrEmpty(TxtOfflinNum.Text.ToString().Replace("_","")))
  159. {
  160. if (int.Parse(this.TxtOfflinNum.Text.ToString().Replace("_", "")) - int.Parse(this.TxtTotalNum.Text.Trim()) > 0)
  161. {
  162. MessageBox.Show("输入的下线支数超过了可下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  163. return;
  164. }
  165. if (int.Parse(TxtOfflinNum.Text.ToString3().Replace("_", "")) <= 0)
  166. {
  167. MessageBox.Show("下线支数不能为零支,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  168. return;
  169. }
  170. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryXxOfflinNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob);
  171. DataTable dt2 = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryHgNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob); //合格品支数
  172. if (dt.Rows.Count > 0)
  173. {
  174. xxOfflineNum = int.Parse(dt.Rows[0]["OFFLINE_NUM"].ToString3());
  175. hgNum =int.Parse(dt2.Rows[0]["ACOUNT"].ToString3());
  176. if (xxOfflineNum + int.Parse(this.TxtOfflinNum.Text.ToString().Replace("_", "")) - hgNum > 0)
  177. {
  178. MessageBox.Show("交库点已交库和离线了" + xxOfflineNum + "支,请确认数据再做离线!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  179. return;
  180. }
  181. }
  182. }
  183. else
  184. {
  185. MessageBox.Show("未输入下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  186. return;
  187. }
  188. DataTable dtMemo = PipeManageClass.getComTypeInfo(strInbound, ob);
  189. if (dtMemo.Rows.Count >= 1)
  190. {
  191. strInMemo = dtMemo.Rows[0]["MEMO"].ToString();
  192. }
  193. ArrayList list = new ArrayList();
  194. DataTable ds = getStoreNo(plinCode);
  195. if (ds == null)
  196. {
  197. MessageUtil.ShowTips("无轧管在线库基础信息,请维护!");
  198. return;
  199. }
  200. list.Add(ds.Rows[0]["STORAGE_NO"].ToString());
  201. list.Add(ds.Rows[0]["STORAGE_NO"].ToString() + "10101");
  202. list.Add(ds.Rows[0]["STORAGE_TYPE_NO"].ToString());
  203. list.Add(ds.Rows[0]["STORAGE_TYPE_NAME"].ToString());
  204. list.Add(this.UserInfo.GetUserName());
  205. list.Add(this.UserInfo.GetDeptid());
  206. list.Add(this.UserInfo.GetDepartment());
  207. list.Add(this.UserInfo.GetDeptid());
  208. list.Add(this.UserInfo.GetDepartment());
  209. //list.Add(PipeManageClass.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
  210. //list.Add(PipeManageClass.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
  211. list.Add(UserInfo.GetUserOrder());
  212. list.Add(UserInfo.GetUserGroup());
  213. UltraGridRow uRow = this.ultraRack.ActiveRow;
  214. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryResult", new object[] { uRow.Cells["JudgeStoveNo"].Value.ToString2() }, this.ob);
  215. //if (int.Parse(dt.Rows[0]["ACOUNT"].ToString2()) < 1)
  216. //{
  217. // MessageUtil.ShowTips("部分下线之前,请先录入实绩!");
  218. // return;
  219. //}
  220. MilPlanEntity3 milPlan = (MilPlanEntity3)uRow.ListObject;
  221. String milPlanTity = JSONFormat.Format(milPlan);
  222. CoreClientParam ccp = new CoreClientParam();
  223. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  224. ccp.MethodName = "offLineTS";
  225. ccp.ServerParams = new object[] { milPlanTity, TxtOfflinNum.Text.ToString().Replace("_", ""), this.UserInfo.GetUserName(), this.UserInfo.GetUserGroup(), this.UserInfo.GetUserOrder(), "0", list, strInbound, strInMemo, plinCode, proPlanId, gxPlanNo };
  226. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  227. if (ccp.ReturnCode != -1)
  228. {
  229. if (ccp.ReturnInfo.Equals("离线成功!"))
  230. {
  231. Query();
  232. MessageUtil.ShowTips(ccp.ReturnInfo);
  233. }
  234. else
  235. {
  236. MessageUtil.ShowTips(ccp.ReturnInfo);
  237. }
  238. }
  239. foreach (UltraGridRow ugr in ultraRack.Rows)
  240. {
  241. if (ugr.Cells["JudgeStoveNo"].Value.ToString().Equals(heatno))
  242. {
  243. ultraRack.ActiveRow = ugr;
  244. }
  245. }
  246. }
  247. /// <summary>
  248. /// 查询仓库信息
  249. /// </summary>
  250. /// <param name="plineCode"></param>
  251. /// <returns></returns>
  252. private DataTable getStoreNo(string plineCode)
  253. {
  254. DataTable ds = ServerHelper.GetData("com.steering.mes.signature.FrmInOnlineStore.doQueryStoreNo", new object[] { plineCode }, ob);
  255. if (ds.Rows.Count > 0)
  256. {
  257. return ds;
  258. }
  259. else
  260. {
  261. return null;
  262. }
  263. }
  264. /// <summary>
  265. /// 整台离线
  266. /// </summary>
  267. public void offlineAll()
  268. {
  269. string strInbound = "800707";//入库类型
  270. string strInMemo = "";
  271. NativeMethodNew na = new NativeMethodNew(this.ob);
  272. string plinCode = na.GetPCode(this.UserInfo.GetDepartment());
  273. int xxOfflineNum = 0; //交库点离线的支数
  274. int hgNum = 0; //合格品支数
  275. if (string.IsNullOrEmpty(heatno) || ultraRack.ActiveRow == null)
  276. {
  277. MessageBox.Show("未选择计划行,不允许进行下线操作。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  278. return;
  279. }
  280. UltraGridRow uRow = this.ultraRack.ActiveRow;
  281. //DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryResult", new object[] { uRow.Cells["JudgeStoveNo"].Value.ToString2() }, this.ob);
  282. //if (int.Parse(dt.Rows[0]["ACOUNT"].ToString2()) < 1)
  283. //{
  284. // MessageUtil.ShowTips("部分下线之前,请先录入实绩!");
  285. // return;
  286. //}
  287. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryXxOfflinNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob);
  288. DataTable dt2 = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.doQueryHgNum", new object[] { heatno, plinCode, proPlanId, gxPlanNo }, ob); //合格品支数
  289. if (dt.Rows.Count > 0)
  290. {
  291. xxOfflineNum = int.Parse(dt.Rows[0]["OFFLINE_NUM"].ToString3());
  292. hgNum = int.Parse(dt2.Rows[0]["ACOUNT"].ToString3());
  293. if (xxOfflineNum + int.Parse(this.TxtTotalNum.Text.ToString().Replace("_", "")) - hgNum > 0)
  294. {
  295. MessageBox.Show("交库点已交库和离线了" + xxOfflineNum + "支,请确认数据再做离线!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  296. return;
  297. }
  298. }
  299. DataTable dtMemo = PipeManageClass.getComTypeInfo(strInbound, ob);
  300. if (dtMemo.Rows.Count >= 1)
  301. {
  302. strInMemo = dtMemo.Rows[0]["MEMO"].ToString();
  303. }
  304. ArrayList list = new ArrayList();
  305. DataTable ds = getStoreNo(plinCode);
  306. if (ds == null)
  307. {
  308. MessageUtil.ShowTips("无轧管在线库基础信息,请维护!");
  309. return;
  310. }
  311. list.Add(ds.Rows[0]["STORAGE_NO"].ToString());
  312. list.Add(ds.Rows[0]["STORAGE_NO"].ToString() + "10101");
  313. list.Add(ds.Rows[0]["STORAGE_TYPE_NO"].ToString());
  314. list.Add(ds.Rows[0]["STORAGE_TYPE_NAME"].ToString());
  315. list.Add(this.UserInfo.GetUserName());
  316. list.Add(this.UserInfo.GetDeptid());
  317. list.Add(this.UserInfo.GetDepartment());
  318. list.Add(PipeManageClass.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
  319. list.Add(PipeManageClass.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
  320. list.Add(UserInfo.GetUserOrder());
  321. list.Add(UserInfo.GetUserGroup());
  322. MilPlanEntity3 milPlan = (MilPlanEntity3)uRow.ListObject;
  323. String milPlanTity = JSONFormat.Format(milPlan);
  324. CoreClientParam ccp = new CoreClientParam();
  325. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  326. ccp.MethodName = "offLineTS";
  327. ccp.ServerParams = new object[] { milPlanTity, TxtTotalNum.Text.ToString().Replace("_", ""), this.UserInfo.GetUserName(), this.UserInfo.GetUserGroup(), this.UserInfo.GetUserOrder(), "1", list, strInbound, strInMemo, plinCode, proPlanId, gxPlanNo };
  328. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  329. if (ccp.ReturnCode != -1)
  330. {
  331. if (ccp.ReturnInfo.Equals("离线成功!"))
  332. {
  333. Query();
  334. MessageUtil.ShowTips(ccp.ReturnInfo);
  335. }
  336. else
  337. {
  338. MessageUtil.ShowTips(ccp.ReturnInfo);
  339. }
  340. }
  341. }
  342. public void offlineBack()
  343. {
  344. if (string.IsNullOrEmpty(heatno) || ultraRack.ActiveRow == null)
  345. {
  346. MessageBox.Show("未选择计划行,不允许进行下线回退操作", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  347. return;
  348. }
  349. if (!string.IsNullOrEmpty(this.TxtOfflineNumhas.Text.ToString().Replace("_", "")))
  350. {
  351. if (int.Parse(this.TxtOfflineNumhas.Text.ToString().Replace("_","")) == 0)
  352. {
  353. MessageBox.Show("已下线支数为0,不允许进行下线回退操作", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  354. return;
  355. }
  356. }
  357. else
  358. {
  359. MessageBox.Show("未进行下线操作,不允许进行下线回退", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  360. return;
  361. }
  362. int offlinehas=int.Parse(this.TxtOfflineNumhas.Text.ToString().Replace("_",""));
  363. if (!string.IsNullOrEmpty(this.TxtOfflinNumBack.Text.ToString().Replace("_", "")))
  364. {
  365. if (int.Parse(this.TxtOfflinNumBack.Text.ToString().Replace("_", "")) - offlinehas > 0)
  366. {
  367. MessageBox.Show("输入的下线回退支数超过了已下线支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  368. return;
  369. }
  370. }
  371. else
  372. {
  373. MessageBox.Show("未输入下线回退支数,请重新输入", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  374. return;
  375. }
  376. UltraGridRow uRow = this.ultraRack.ActiveRow;
  377. MilPlanEntity3 milPlan = (MilPlanEntity3)uRow.ListObject;
  378. String milPlanTity = JSONFormat.Format(milPlan);
  379. CoreClientParam ccp = new CoreClientParam();
  380. ccp.ServerName = "com.steering.mes.zgmil.coup.FrmOffLine";
  381. ccp.MethodName = "newOfflineBack";
  382. ccp.ServerParams = new object[] { milPlanTity,this.TxtOfflinNumBack.Text.ToString().Replace("_", ""),"TS" };
  383. ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal);
  384. if (ccp.ReturnCode != -1)
  385. {
  386. if (ccp.ReturnInfo.Equals("回退成功!"))
  387. {
  388. Query();
  389. MessageUtil.ShowTips(ccp.ReturnInfo);
  390. }
  391. else
  392. {
  393. MessageUtil.ShowTips(ccp.ReturnInfo);
  394. }
  395. }
  396. }
  397. /// <summary>
  398. /// 是否要插入下线实绩表
  399. /// </summary>
  400. /// <returns></returns>
  401. public bool isInsert()
  402. {
  403. bool result = true;
  404. DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmOffLine.isInsertOfflineResult", new object[] { heatno, process, proPlanId, gxPlanNo }, this.ob);
  405. if (dt.Rows.Count > 0)
  406. {
  407. result = false;
  408. }
  409. return result;
  410. }
  411. //查询
  412. private void FrmOffLineOperation_Load(object sender, EventArgs e)
  413. {
  414. Query();
  415. }
  416. private void FrmOffLineOperation_FormClosed(object sender, FormClosedEventArgs e)
  417. {
  418. this.DialogResult = DialogResult.OK;
  419. }
  420. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  421. {
  422. switch (e.Tool.Key)
  423. {
  424. case "doquery":
  425. Query();
  426. break;
  427. case "offline":
  428. Offline();
  429. break;
  430. case "offlineall":
  431. offlineAll();
  432. break;
  433. case "OfflineBack":
  434. offlineBack();
  435. break;
  436. case "Close":
  437. this.Close();
  438. break;
  439. }
  440. }
  441. private void TxtOfflineNumhas_TextChanged(object sender, EventArgs e)
  442. {
  443. if (int.Parse(TxtOfflineNumhas.Text.ToString()) > 0)
  444. {
  445. this.TxtOfflinNumBack.Enabled = true;
  446. }
  447. else
  448. {
  449. this.TxtOfflinNumBack.Enabled = false;
  450. }
  451. }
  452. }
  453. }