frmOrderMpsUpdate.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 Core.Mes.Client.Comm.Control;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.StlMes.Client.Qcm;
  14. using Core.Mes.Client.Comm.Format;
  15. using System.Collections;
  16. using Core.Mes.Client.Comm.Tool;
  17. using Core.StlMes.Client.SaleOrder.Dialog;
  18. namespace Core.StlMes.Client.SaleOrder
  19. {
  20. public partial class frmOrderMpsUpdate : FrmBase
  21. {
  22. public frmOrderMpsUpdate()
  23. {
  24. InitializeComponent();
  25. this.IsLoadUserView = true;
  26. }
  27. private string[] dataArr = null;
  28. protected override void OnLoad(EventArgs e)
  29. {
  30. base.OnLoad(e);
  31. }
  32. /// <summary>
  33. /// 来自于哪个界面 1交货期评审提报 2 交货期评审 3 合同行变更时的交货期
  34. /// </summary>
  35. private string statusFrom = ""; //
  36. private void frmOrderDeliveryReview_Load(object sender, EventArgs e)
  37. {
  38. uchkDate.Checked = true;
  39. //默认查询当前日期-1月——当前日期数据。
  40. udtEnd.DateTime = DateTime.Now;
  41. udtStart.DateTime = DateTime.Now.AddMonths(-1);
  42. if ("REPORT".Equals(this.CustomInfo)) //交货期评审提报
  43. {
  44. statusFrom = "1";
  45. }
  46. }
  47. /// <summary>
  48. /// 重写基类toolBar方法
  49. /// </summary>
  50. /// <param name="sender"></param>
  51. /// <param name="ToolbarKey"></param>
  52. public override void ToolBar_Click(object sender, string ToolbarKey)
  53. {
  54. switch (ToolbarKey)
  55. {
  56. case "doQuery":
  57. doQuery();
  58. break;
  59. case "doClose":
  60. this.Close();
  61. break;
  62. case "InPutMpsNo":
  63. InPutMpsNo();
  64. break;
  65. case "Save":
  66. Save();
  67. break;
  68. case "AddMps":
  69. AddMps();
  70. break;
  71. }
  72. }
  73. /// <summary>
  74. /// 维护MPS编号
  75. /// </summary>
  76. private void InPutMpsNo()
  77. {
  78. UltraGridRow ugr = ultraGHead.ActiveRow;
  79. if (ugr == null)
  80. {
  81. MessageUtil.ShowWarning("请选择一个需要维护MPS编号的合同!");
  82. return;
  83. }
  84. string ordPk = ugr.Cells["ORD_PK"].Value.ToString();
  85. //判断选择的合同是否需要维护MPS编号
  86. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreDeliveryReview.getMpsFlag", new object[] { ordPk }, this.ob);
  87. if (dt != null && dt.Rows.Count > 0)
  88. {
  89. if (!dt.Rows[0][0].ToString().Contains("1"))
  90. {
  91. MessageUtil.ShowWarning("您选择的合同不需要维护MPS编号!");
  92. return;
  93. }
  94. }
  95. else
  96. {
  97. MessageUtil.ShowWarning("您选择的合同合同行出现异常!");
  98. return;
  99. }
  100. FrmInPutMpsNo pmn = new FrmInPutMpsNo(this.ob, ordPk);
  101. pmn.ShowDialog();
  102. doQuery();
  103. foreach (UltraGridRow uRow in ultraGHead.Rows)
  104. {
  105. if (uRow.Cells["ORD_PK"].Value.ToString() == ordPk)
  106. {
  107. uRow.Activate();
  108. break;
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// 查询出技术评审通过的合同头信息。
  114. /// </summary>
  115. private void doQuery()
  116. {
  117. string orderNo = utxtOrderNo.Text.Trim();
  118. string orderStart = "1000-01-01 00:00:01";
  119. string orderEnd = "9999-12-31 23:59:59";
  120. TimeSpan ts = udtEnd.DateTime.Subtract(udtStart.DateTime);
  121. if (ts.TotalDays < 0)
  122. {
  123. MessageBox.Show("创建开始日期必须小于创建结束日期。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  124. return;
  125. }
  126. if (uchkDate.Checked)
  127. {
  128. orderStart = udtStart.DateTime.ToString("yyyy-MM-dd") + " 00:00:01";
  129. orderEnd = udtEnd.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  130. }
  131. string[] arr = this.ValidDataPurviewIds;
  132. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreDeliveryReview.doQueryMpsUpdate", new Object[] { orderNo, orderStart, orderEnd, arr }, this.ob);
  133. GridHelper.CopyDataToDatatable(ref dt, ref this.orderHeadDt, true);
  134. if (dt.Rows.Count > 0)
  135. {
  136. //列自适应
  137. GridHelper.RefreshAndAutoSizeExceptRows(ultraGHead, new UltraGridColumn[] { });
  138. ultraGHead.UpdateData();
  139. }
  140. else
  141. {
  142. slm_order_line.Rows.Clear();
  143. }
  144. }
  145. private void bindSlmOrderLine(string orderPk)
  146. {
  147. if (ultraGHead.ActiveRow == null)
  148. {
  149. MessageBox.Show("请先选择合同头信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  150. return;
  151. }
  152. this.slm_order_line.Clear();
  153. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.ReviewForm.CoreDeliveryReview.GetOrderLineForMpsUpdate", new Object[] { orderPk, statusFrom }, this.ob);
  154. GridHelper.CopyDataToDatatable(ref dt, ref this.slm_order_line, true);
  155. GridHelper.SetExcludeColumnsActive(ultraGridOrderLine.DisplayLayout.Bands[0], "MPS_NO_INPUT");
  156. //列自适应
  157. UltraGridColumn[] col = new UltraGridColumn[] { ultraGridOrderLine.DisplayLayout.Bands[0].Columns["LEN_DESC"], ultraGridOrderLine.DisplayLayout.Bands[0].Columns["STD_NAME"]
  158. , ultraGridOrderLine.DisplayLayout.Bands[0].Columns["PSC_DESC"] };
  159. GridHelper.RefreshAndAutoSizeExceptColumns(ultraGridOrderLine, col);
  160. ultraGridOrderLine.UpdateData();
  161. }
  162. /// <summary>
  163. /// 带出合同行信息和交货行信息。
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. private void ultraGHead_AfterRowActivate(object sender, EventArgs e)
  168. {
  169. if (ultraGHead.ActiveRow != null)
  170. {
  171. string orderPk = ultraGHead.ActiveRow.Cells["ORD_PK"].Value.ToString();
  172. bindSlmOrderLine(orderPk);
  173. }
  174. }
  175. private void uchkOrderNo_CheckedChanged(object sender, EventArgs e)
  176. {
  177. utxtOrderNo.ReadOnly = !uchkOrderNo.Checked;
  178. }
  179. /// <summary>
  180. /// 创建日期是否有效
  181. /// </summary>
  182. /// <param name="sender"></param>
  183. /// <param name="e"></param>
  184. private void uchkDate_CheckedChanged(object sender, EventArgs e)
  185. {
  186. if (uchkDate.Checked)
  187. {
  188. udtStart.ReadOnly = false;
  189. udtEnd.ReadOnly = false;
  190. }
  191. else
  192. {
  193. udtStart.ReadOnly = true;
  194. udtEnd.ReadOnly = true;
  195. }
  196. }
  197. /// <summary>
  198. /// cellChange事件
  199. /// </summary>
  200. /// <param name="sender"></param>
  201. /// <param name="e"></param>
  202. private void ultraGridOrderLine_CellChange(object sender, CellEventArgs e)
  203. {
  204. if (e.Cell.Column.Key.Equals("DELVRY_EDATE"))
  205. return;
  206. ultraGridOrderLine.UpdateData();
  207. if (e.Cell.Column.Key.Equals("CHK"))
  208. {
  209. if (Convert.ToBoolean(e.Cell.Value))
  210. {
  211. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  212. {
  213. e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
  214. }
  215. }
  216. else
  217. {
  218. for (int i = 0; i < e.Cell.Row.Cells.Count; i++)
  219. {
  220. if (e.Cell.Row.Cells[i].Column.Key.Equals("CHK"))
  221. {
  222. e.Cell.Row.Cells[i].Activation = Activation.AllowEdit;
  223. }
  224. else
  225. e.Cell.Row.Cells[i].Activation = Activation.ActivateOnly;
  226. }
  227. }
  228. }
  229. }
  230. private string deliveryInsertPk = "";
  231. private int deliveryInsertSeq = 0;
  232. private void utxtOrderNo_KeyPress(object sender, KeyPressEventArgs e)
  233. {
  234. if (e.KeyChar == 13)
  235. doQuery();
  236. }
  237. private void AddMps()
  238. {
  239. ultraGridOrderLine.UpdateData();
  240. UltraGridRow ugr = ultraGridOrderLine.ActiveRow;
  241. if (ugr == null)
  242. {
  243. MessageUtil.ShowWarning("请选择一行合同行!");
  244. return;
  245. }
  246. FrmStableMps fsm = new FrmStableMps(this.ob);
  247. fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  248. fsm.WindowState = FormWindowState.Maximized;
  249. fsm.ShowDialog();
  250. }
  251. /// <summary>
  252. /// 保存
  253. /// </summary>
  254. private void Save()
  255. {
  256. ultraGridOrderLine.UpdateData();
  257. ArrayList parm = new ArrayList();
  258. foreach (UltraGridRow ugr in ultraGridOrderLine.Rows)
  259. {
  260. string inputMpsNo = ugr.Cells["MPS_NO_INPUT"].Value.ToString();
  261. string mpsFile = ugr.Cells["MPS_FILE"].Value.ToString();
  262. if (inputMpsNo == "")
  263. {
  264. MessageUtil.ShowWarning("请输入确认后的MPS编号!");
  265. ugr.Activate();
  266. return;
  267. }
  268. if (mpsFile == "")
  269. {
  270. MessageUtil.ShowWarning("请上传MPS文本文件!");
  271. ugr.Activate();
  272. return;
  273. }
  274. string ordLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  275. ArrayList list = new ArrayList();
  276. list.Add(inputMpsNo);
  277. //list.Add(mpsFile);
  278. list.Add(ordLnPk);
  279. parm.Add(list);
  280. }
  281. if (MessageUtil.ShowYesNoAndQuestion("是否确定保存输入的MPS编号") == DialogResult.No) return;
  282. int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.saveMpsLine", new object[] { parm }, this.ob);
  283. if (count > 0)
  284. {
  285. MessageUtil.ShowTips("确认后的MPS编号保存成功!");
  286. //this.Close();
  287. }
  288. }
  289. /// <summary>
  290. /// GRID按钮
  291. /// </summary>
  292. /// <param name="sender"></param>
  293. /// <param name="e"></param>
  294. private void MpsFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  295. {
  296. if (e.Button.Key.Equals("upload")) // 上传
  297. {
  298. UltraGridRow row = ultraGridOrderLine.ActiveRow;
  299. if (row == null)
  300. return;
  301. string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
  302. if ("".Equals(ordLnPk))
  303. return;
  304. Core.Mes.Client.Comm.Server.FileHelper.Delete("Mps/" + ordLnPk);
  305. string reStr = FlileUpload("Mps/" + ordLnPk);
  306. if (reStr == "F")
  307. {
  308. MessageUtil.ShowWarning("上传失败,尝试重新上传!");
  309. return;
  310. }
  311. else if (reStr == "N")
  312. {
  313. return;
  314. }
  315. row.Cells["MPS_FILE"].Value = reStr;
  316. row.Cells["MPS_NO_FILE"].Value = "最近上传的MPS文本 " + reStr;
  317. if (updateOrderLineMps(reStr, ordLnPk))
  318. {
  319. MessageUtil.ShowTips("上传成功!");
  320. }
  321. else
  322. {
  323. MessageUtil.ShowWarning("上传失败,尝试重新上传!");
  324. }
  325. }
  326. else if (e.Button.Key.Equals("view")) //预览
  327. {
  328. UltraGridRow row = ultraGridOrderLine.ActiveRow;
  329. if (row == null)
  330. return;
  331. string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
  332. string filePath = "Mps/" + ordLnPk;
  333. //引用的地址
  334. string dbFilePath = "";
  335. bool isNull = false;
  336. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreInPutMpsNo.selectMpsAddr", new object[] { ordLnPk }, this.ob);
  337. if (dt != null && dt.Rows.Count > 0)
  338. {
  339. dbFilePath = dt.Rows[0][0].ToString();
  340. }
  341. else
  342. {
  343. isNull = true;
  344. }
  345. //引用地址存在 优先显示引用地址的文件
  346. string fpath = filePath;
  347. if (dbFilePath != filePath && isNull == false)
  348. fpath = dbFilePath;
  349. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, fpath);
  350. down.ShowDialog();
  351. if (down.CtrlFileDown1.List.Count == 0)
  352. {
  353. if (dbFilePath == filePath)
  354. updateOrderLineMps("", ordLnPk);
  355. row.Cells["MPS_FILE"].Value = "";
  356. row.Cells["MPS_NO_FILE"].Value = "无MPS文件";
  357. }
  358. }
  359. }
  360. private bool updateOrderLineMps(string mpsFile, string ordLnPk)
  361. {
  362. //更新合同行地址文件信息
  363. int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.updateMpsLine", new object[] { mpsFile, ordLnPk }, this.ob);
  364. if (count > 0)
  365. {
  366. return true;
  367. }
  368. else
  369. {
  370. return false;
  371. }
  372. }
  373. public static string FlileUpload(string sFileName)
  374. {
  375. List<FileBean> list = new List<FileBean>();
  376. FileBean bean = new FileBean();
  377. OpenFileDialog file = new OpenFileDialog();
  378. file.Multiselect = false; // file.Multiselect = true 改为 file.Multiselect = false
  379. DialogResult drStat;
  380. drStat = file.ShowDialog();
  381. string fileList = "";
  382. if (drStat == DialogResult.OK)
  383. {
  384. foreach (string fileName in file.FileNames)
  385. {
  386. bean = new FileBean();
  387. string filena = System.IO.Path.GetFileName(fileName);
  388. bean.setFileName(filena);
  389. bean.setPathName(sFileName);
  390. bean.setFile(FileHelper.FileToArray(fileName));
  391. list.Add(bean);
  392. fileList = filena;
  393. }
  394. bool isSuccess = false;
  395. isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  396. if (isSuccess)
  397. {
  398. return fileList;
  399. }
  400. else
  401. {
  402. return "F";
  403. }
  404. }
  405. else
  406. return "N"; //未选择文件
  407. }
  408. private void stableMps_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  409. {
  410. if (e.Button.Key.Equals("select"))
  411. {
  412. ultraGridOrderLine.UpdateData();
  413. UltraGridRow ugr = ultraGridOrderLine.ActiveRow;
  414. if (ugr == null)
  415. {
  416. MessageUtil.ShowWarning("请选择一行合同行!");
  417. return;
  418. }
  419. FrmStableMps fsm = new FrmStableMps(this.ob);
  420. fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  421. fsm.WindowState = FormWindowState.Maximized;
  422. fsm.WdType = "2";
  423. fsm.frmClosedRefresh += fsm_frmClosedRefresh;
  424. fsm.ShowDialog();
  425. }
  426. }
  427. void fsm_frmClosedRefresh()
  428. {
  429. bindSlmOrderLine(ultraGHead.ActiveRow.Cells["ORD_PK"].Value.ToString());
  430. }
  431. }
  432. }