frmDesignFallBack.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Server;
  11. using Infragistics.Win.UltraWinTree;
  12. using System.Collections;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Core.StlMes.Client.SaleOrder.BLL;
  15. using Core.StlMes.Client.Qcm;
  16. namespace Core.StlMes.Client.SaleOrder.Dialog
  17. {
  18. public partial class frmDesignFallBack : FrmBase
  19. {
  20. private string _ordLnPk;
  21. private string _craftSeq;
  22. private bool _isCraft = false;
  23. public frmDesignFallBack(string ordLnPk, string craftSeq, bool isCraft, OpeBase ob)
  24. {
  25. InitializeComponent();
  26. this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  27. _ordLnPk = ordLnPk;
  28. _isCraft = isCraft;
  29. if (_isCraft)
  30. {
  31. this.Text = "工艺评审回退";
  32. }
  33. _craftSeq = craftSeq;
  34. this.ob = ob;
  35. }
  36. private void frmDesignFallBack_Load(object sender, EventArgs e)
  37. {
  38. DoQuery();
  39. }
  40. /// <summary>
  41. /// 生成树
  42. /// </summary>
  43. /// <param name="dt">DataTable</param>
  44. /// <param name="key">key</param>
  45. /// <param name="showValue">显示值</param>
  46. private void CreateTree(DataTable dt, string hideValue, string showValue)
  47. {
  48. if (dt == null || dt.Rows.Count == 0)
  49. {
  50. return;
  51. }
  52. UltraTreeNode utn = null;
  53. for (int i = 0; i < dt.Rows.Count; i++)
  54. {
  55. utn = new UltraTreeNode(dt.Rows[i][hideValue].ToString(), dt.Rows[i][showValue].ToString());
  56. utn.Override.NodeStyle = NodeStyle.OptionButton;
  57. utn.Tag = dt.Rows[i];
  58. ultraTree.Nodes.Add(utn);
  59. }
  60. }
  61. private void DoQuery()
  62. {
  63. DataTable dt = null;
  64. if (_isCraft)
  65. {
  66. dt = GetCraftItemByOrdLnPk(_ordLnPk);
  67. CreateTree(dt, "LST_ITEM", "LST_ITEM");
  68. }
  69. else
  70. {
  71. dt = ServerHelper.GetData("com.steering.pss.sale.order.qualityDesign.QualityDesignFallback.getItems",
  72. new Object[] { _ordLnPk }, this.ob);
  73. CreateTree(dt, "SEQ_INDEX", "LST_ITEM");
  74. }
  75. if (ultraTree.Nodes.Count > 0)
  76. {
  77. ultraTree.Nodes[0].CheckedState = CheckState.Checked;
  78. }
  79. }
  80. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  81. {
  82. switch (e.Tool.Key)
  83. {
  84. case "FallBack":
  85. if (_isCraft)
  86. {
  87. DoCraftFallBack();
  88. }
  89. else
  90. {
  91. DoFallBack();
  92. }
  93. break;
  94. case "Cancel":
  95. this.Close();
  96. break;
  97. default:
  98. break;
  99. }
  100. }
  101. private void DoCraftFallBack()
  102. {
  103. //...
  104. ultraTree.Update();
  105. if (ultraTree.ActiveNode == null)
  106. {
  107. MessageUtil.ShowWarning("请选择回退节点");
  108. return;
  109. }
  110. CraftOrdDesignBLL craftOrdDesignBLL = new CraftOrdDesignBLL(ob);
  111. CraftOrdDesignEntity craftOrdDesign = craftOrdDesignBLL.QueryByPk(new CraftOrdDesignEntity()
  112. {
  113. OrdLnPk = _ordLnPk,
  114. CraftSeq = decimal.Parse(_craftSeq == "" ? "0" : _craftSeq)
  115. });
  116. if (craftOrdDesign == null)
  117. {
  118. MessageUtil.ShowWarning("当前合同行不存在工艺设计结果,不能回退!");
  119. return;
  120. }
  121. //if (craftOrdDesign.LockFlag != "1" || craftOrdDesign.Validflag != "2")
  122. //{
  123. // MessageUtil.ShowWarning("当前合同行已经生成工艺文件,不能回退!");
  124. // return;
  125. //}
  126. DataTable dtCraftItem = GetCraftItemByOrdLnPk(_ordLnPk);
  127. DataRow[] drs = dtCraftItem.Select("DESIGN_STS = 'F'");
  128. if (drs.Length > 0)
  129. {
  130. DataRow dr = (DataRow)ultraTree.ActiveNode.Tag;
  131. if (decimal.Parse(dr["SEQ_INDEX"].ToString()) > decimal.Parse(drs[0]["SEQ_INDEX"].ToString()))
  132. {
  133. MessageUtil.ShowWarning("不能回退到失败项之后的节点!");
  134. return;
  135. }
  136. }
  137. string item = ultraTree.ActiveNode.Text.Trim();
  138. string mscPline = "";
  139. string processCode = "";
  140. string dimater = "";
  141. string height = "";
  142. string pic = "";
  143. if (item == "试样码(内控)")
  144. {
  145. DataTable dtBackLogProcess = ServerHelper.GetData("com.steering.pss.sale.order.qualityDesign.QualityDesignFallback.getCraftBackLogProcess",
  146. new object[]{ _ordLnPk, _craftSeq }, ob);
  147. dtBackLogProcess.Columns["MSC_PLINE"].Caption = "制程号";
  148. dtBackLogProcess.Columns["WHOLE_BACKLOG"].Caption = "全程途径码";
  149. dtBackLogProcess.Columns["WHOLE_BACKLOG_DESC"].Caption = "全程途径描述";
  150. dtBackLogProcess.Columns["PROCESS_DESC"].Caption = "工序";
  151. dtBackLogProcess.Columns["DIMATER"].Caption = "外径";
  152. dtBackLogProcess.Columns["HEIGHT"].Caption = "壁厚";
  153. BaseInfoPopup popup = new BaseInfoPopup(dtBackLogProcess, "MSC_PLINE", "PROCESS_CODE");
  154. popup.Text = "选择要回退的记录!";
  155. if (popup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  156. {
  157. mscPline = popup.ChoicedRow.GetValue("MSC_PLINE");
  158. processCode = popup.ChoicedRow.GetValue("PROCESS_CODE");
  159. dimater = popup.ChoicedRow.GetValue("DIMATER");
  160. height = popup.ChoicedRow.GetValue("HEIGHT");
  161. pic = popup.ChoicedRow.GetValue("PIC");
  162. }
  163. else
  164. {
  165. return;
  166. }
  167. }
  168. dlgReviewMemo dlg = new dlgReviewMemo();
  169. dlg.ReviewFlag = 0;
  170. dlg.ReviewSatus = "工艺评审回退";
  171. dlg.ShowDialog();
  172. string backReason = dlg.ReviewMemo;
  173. if (backReason.Trim().Length == 0)
  174. {
  175. return;
  176. }
  177. backReason = UserInfo.ParentDepartment + "-" + (UserInfo.GetDepartment()) + ":" + UserInfo.GetUserName() + " 退回说明:" + backReason;
  178. ServerHelper.SetData("com.steering.pss.sale.order.qualityDesign.QualityDesignFallback.craftFallBack",
  179. new object[] { _ordLnPk, item, backReason, mscPline, processCode, dimater, height, pic }, ob);
  180. MessageUtil.ShowTips("回退成功!");
  181. this.Close();
  182. }
  183. private DataTable GetCraftItemByOrdLnPk(string ordLnPk)
  184. {
  185. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.qualityDesign.QualityDesignFallback.getCraftItems",
  186. new object[] { ordLnPk }, ob);
  187. return dt;
  188. }
  189. private void DoFallBack()
  190. {
  191. ultraTree.Update();
  192. if (ultraTree.ActiveNode == null)
  193. {
  194. MessageUtil.ShowWarning("请选择回退节点");
  195. return;
  196. }
  197. String item = ultraTree.ActiveNode.Text.Trim();
  198. if (item.Equals("MSC(n)") || item.Equals("产品技术要求") || item.Equals(
  199. "合同附加要求"))
  200. {
  201. MessageUtil.ShowWarning("MSC(n)管理科室、产品技术要求、MSC(n)、合同附加要求 暂不提供回退功能");
  202. return;
  203. }
  204. if (item.Equals("生产周期"))
  205. {
  206. MessageUtil.ShowWarning("生产周期无需回退");
  207. return;
  208. }
  209. String retrunMessage = checkOrdLine(ultraTree.ActiveNode.Text.Trim());
  210. if (!retrunMessage.Equals(""))
  211. {
  212. MessageUtil.ShowWarning(retrunMessage);
  213. return;
  214. }
  215. dlgReviewMemo dlg = new dlgReviewMemo();
  216. dlg.ReviewFlag = 0;
  217. dlg.ReviewSatus = "技术评审回退";
  218. dlg.ShowDialog();
  219. string backReason = dlg.ReviewMemo;
  220. if (backReason.Trim().Length == 0)
  221. {
  222. return;
  223. }
  224. backReason = UserInfo.ParentDepartment + "-" + (UserInfo.GetDepartment()) + ":" + UserInfo.GetUserName() + " 退回说明:" + backReason;
  225. ArrayList list = new ArrayList();
  226. list.Add(_ordLnPk);
  227. list.Add(ultraTree.ActiveNode.Text.Trim());
  228. list.Add(backReason);
  229. list.Add(UserInfo.GetDeptid());
  230. list.Add(UserInfo.GetDepartment());
  231. list.Add(UserInfo.GetUserName());
  232. list.Add(UserInfo.GetUserID());
  233. CoreClientParam ccp = new CoreClientParam();
  234. ccp.ServerName = "com.steering.pss.sale.order.qualityDesign.QualityDesignFallback";
  235. ccp.MethodName = "fallBack";
  236. ccp.ServerParams = new object[] { list };
  237. ccp = this.ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  238. if (ccp.ReturnCode != -1)
  239. {
  240. MessageUtil.ShowTips(ccp.ReturnInfo);
  241. if (Boolean.Parse(ccp.ReturnObject.ToString()))
  242. {
  243. this.Close();
  244. }
  245. }
  246. }
  247. private void ultraTree_AfterActivate(object sender, NodeEventArgs e)
  248. {
  249. //e.TreeNode.Selected = true;
  250. // e.TreeNode.Nodes.Override.NodeStyle = NodeStyle.OptionButton;
  251. e.TreeNode.CheckedState = CheckState.Checked;
  252. }
  253. private void ultraTree_AfterCheck(object sender, NodeEventArgs e)
  254. {
  255. e.TreeNode.Selected = true;
  256. ultraTree.ActiveNode = e.TreeNode;
  257. }
  258. private String checkOrdLine(String item)
  259. {
  260. List<SlmOrderLineEntityFallBack> listSource = EntityHelper.GetData<SlmOrderLineEntityFallBack>(
  261. "com.steering.pss.sale.order.qualityDesign.QualityDesignFallback.getOrdLineInfo", new object[] { _ordLnPk }, this.ob);
  262. if (listSource != null && listSource.Count > 0)
  263. {
  264. SlmOrderLineEntityFallBack orderLine = listSource[0];
  265. // A:钢管(管坯)(交付、制程)
  266. //B:钢管+接箍(交付、制程、接箍码)
  267. //C:短节+附件 (制程、接箍码、备料码)
  268. //D:接箍 (制程、接箍)
  269. //E:双公短节(交付、制程、备料码)
  270. if (orderLine.MscStyle.Equals("A"))
  271. {
  272. if (item.Equals("接箍") || item.Equals("备料"))
  273. {
  274. return "钢管/管坯产品没有接箍、备料要求,不能回退至:" + item;
  275. }
  276. }
  277. else if (orderLine.MscStyle.Equals("B"))
  278. {
  279. if (item.Equals("备料"))
  280. {
  281. return "钢管+接箍产品没有备料要求,不能回退至:" + item;
  282. }
  283. }
  284. else if (orderLine.MscStyle.Equals("C"))
  285. {
  286. if (item.Equals("成分标准") || item.Equals("理化标准") || item.Equals("公差标准") || item.Equals("探伤标准") || item.Equals("水压标准") || item.Equals("加工标准"))
  287. {
  288. return "短节+附件产品没有交付标准,不能回退至:" + item;
  289. }
  290. }
  291. else if (orderLine.MscStyle.Equals("D"))
  292. {
  293. if (item.Equals("备料") || item.Equals("成分标准") || item.Equals("理化标准") || item.Equals("公差标准") || item.Equals("探伤标准") || item.Equals("水压标准") || item.Equals("加工标准"))
  294. {
  295. return "接箍产品没有交付标准与备料要求,不能回退至:" + item;
  296. }
  297. }
  298. else
  299. {
  300. if (item.Equals("接箍"))
  301. {
  302. return "双公短节产品没有接箍要求,不能回退至:" + item;
  303. }
  304. }
  305. if (orderLine.MpsFl.Equals("0") && item.Equals("MPS"))
  306. {
  307. return "合同对MPS 没有要求,不能回退至" + item;
  308. }
  309. }
  310. return "";
  311. }
  312. }
  313. }