FrmInPutMpsNo.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using CoreFS.CA06;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.SaleOrder.Dialog
  16. {
  17. public partial class FrmInPutMpsNo : FrmBase
  18. {
  19. public FrmInPutMpsNo()
  20. {
  21. InitializeComponent();
  22. }
  23. private string ordPk;
  24. /// <summary>
  25. /// 构造函数
  26. /// </summary>
  27. /// <param name="_ob">OB对象</param>
  28. /// <param name="_ordPk">合同主键</param>
  29. public FrmInPutMpsNo(OpeBase _ob, string _ordPk)
  30. {
  31. InitializeComponent();
  32. this.ob = _ob;
  33. this.ordPk = _ordPk;
  34. }
  35. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  36. {
  37. switch (e.Tool.Key)
  38. {
  39. case "Query":
  40. InitGridData();
  41. break;
  42. case "Save":
  43. Save();
  44. break;
  45. case "AddMps":
  46. AddMps();
  47. break;
  48. case "Close":
  49. this.Close();
  50. break;
  51. }
  52. }
  53. private void AddMps()
  54. {
  55. gdMpsNo.UpdateData();
  56. UltraGridRow ugr = gdMpsNo.ActiveRow;
  57. if (ugr == null)
  58. {
  59. MessageUtil.ShowWarning("请选择一行合同行!");
  60. return;
  61. }
  62. FrmStableMps fsm = new FrmStableMps(this.ob);
  63. fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  64. fsm.WindowState = FormWindowState.Maximized;
  65. fsm.ShowDialog();
  66. }
  67. private void FrmInPutMpsNo_Load(object sender, EventArgs e)
  68. {
  69. InitGridData();
  70. }
  71. private void InitGridData()
  72. {
  73. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreInPutMpsNo.queryMpsLine", new object[] { ordPk }, this.ob);
  74. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  75. }
  76. /// <summary>
  77. /// 保存
  78. /// </summary>
  79. private void Save()
  80. {
  81. gdMpsNo.UpdateData();
  82. ArrayList parm = new ArrayList();
  83. foreach (UltraGridRow ugr in gdMpsNo.Rows)
  84. {
  85. string inputMpsNo = ugr.Cells["MPS_NO_INPUT"].Value.ToString();
  86. string mpsFile = ugr.Cells["MPS_FILE"].Value.ToString();
  87. if (inputMpsNo == "")
  88. {
  89. MessageUtil.ShowWarning("请输入确认后的MPS编号!");
  90. ugr.Activate();
  91. return;
  92. }
  93. if (mpsFile == "")
  94. {
  95. MessageUtil.ShowWarning("请上传MPS文本文件!");
  96. ugr.Activate();
  97. return;
  98. }
  99. string ordLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  100. ArrayList list = new ArrayList();
  101. list.Add(inputMpsNo);
  102. //list.Add(mpsFile);
  103. list.Add(ordLnPk);
  104. parm.Add(list);
  105. }
  106. if (MessageUtil.ShowYesNoAndQuestion("是否确定保存输入的MPS编号") == DialogResult.No) return;
  107. int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.saveMpsLine", new object[] { parm }, this.ob);
  108. if (count > 0)
  109. {
  110. MessageUtil.ShowTips("确认后的MPS编号保存成功!");
  111. this.Close();
  112. }
  113. }
  114. /// <summary>
  115. /// GRID按钮
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void MpsFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  120. {
  121. if (e.Button.Key.Equals("upload")) // 上传
  122. {
  123. UltraGridRow row = gdMpsNo.ActiveRow;
  124. if (row == null)
  125. return;
  126. string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
  127. string reStr = FlileUpload("Mps/" + ordLnPk);
  128. if (reStr == "F")
  129. {
  130. MessageUtil.ShowWarning("上传失败,尝试重新上传!");
  131. return;
  132. }
  133. else if (reStr == "N")
  134. {
  135. return;
  136. }
  137. row.Cells["MPS_FILE"].Value = reStr;
  138. row.Cells["MPS_NO_FILE"].Value = "最近上传的MPS文本 " + reStr;
  139. if (updateOrderLineMps(reStr, ordLnPk))
  140. {
  141. MessageUtil.ShowTips("上传成功!");
  142. }
  143. else
  144. {
  145. MessageUtil.ShowWarning("上传失败,尝试重新上传!");
  146. }
  147. }
  148. else if (e.Button.Key.Equals("view")) //预览
  149. {
  150. UltraGridRow row = gdMpsNo.ActiveRow;
  151. if (row == null)
  152. return;
  153. string ordLnPk = row.Cells["ORD_LN_PK"].Value.ToString();
  154. string filePath = "Mps/" + ordLnPk;
  155. //引用的地址
  156. string dbFilePath = "";
  157. bool isNull = false;
  158. DataTable dt = ServerHelper.GetData("com.steering.pss.sale.order.CoreInPutMpsNo.selectMpsAddr", new object[] { ordLnPk }, this.ob);
  159. if (dt != null && dt.Rows.Count > 0)
  160. {
  161. dbFilePath = dt.Rows[0][0].ToString();
  162. }
  163. else
  164. {
  165. isNull = true;
  166. }
  167. //引用地址存在 优先显示引用地址的文件
  168. string fpath = filePath;
  169. if (dbFilePath != filePath && isNull == false)
  170. fpath = dbFilePath;
  171. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, fpath);
  172. down.ShowDialog();
  173. if (down.CtrlFileDown1.List.Count == 0)
  174. {
  175. if (dbFilePath == filePath)
  176. updateOrderLineMps("", ordLnPk);
  177. row.Cells["MPS_FILE"].Value = "";
  178. row.Cells["MPS_NO_FILE"].Value = "无MPS文件";
  179. }
  180. }
  181. }
  182. private bool updateOrderLineMps(string mpsFile, string ordLnPk)
  183. {
  184. //更新合同行地址文件信息
  185. int count = ServerHelper.SetData("com.steering.pss.sale.order.CoreInPutMpsNo.updateMpsLine", new object[] { mpsFile, ordLnPk }, this.ob);
  186. if (count > 0)
  187. {
  188. return true;
  189. }
  190. else
  191. {
  192. return false;
  193. }
  194. }
  195. public static string FlileUpload(string sFileName)
  196. {
  197. List<FileBean> list = new List<FileBean>();
  198. FileBean bean = new FileBean();
  199. OpenFileDialog file = new OpenFileDialog();
  200. file.Multiselect = false; // file.Multiselect = true 改为 file.Multiselect = false
  201. DialogResult drStat;
  202. drStat = file.ShowDialog();
  203. string fileList = "";
  204. if (drStat == DialogResult.OK)
  205. {
  206. foreach (string fileName in file.FileNames)
  207. {
  208. bean = new FileBean();
  209. string filena = System.IO.Path.GetFileName(fileName);
  210. bean.setFileName(filena);
  211. bean.setPathName(sFileName);
  212. bean.setFile(FileHelper.FileToArray(fileName));
  213. list.Add(bean);
  214. fileList = filena;
  215. }
  216. bool isSuccess = false;
  217. isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  218. if (isSuccess)
  219. {
  220. return fileList;
  221. }
  222. else
  223. {
  224. return "F";
  225. }
  226. }
  227. else
  228. return "N"; //未选择文件
  229. }
  230. private void stableMps_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  231. {
  232. if (e.Button.Key.Equals("select"))
  233. {
  234. gdMpsNo.UpdateData();
  235. UltraGridRow ugr = gdMpsNo.ActiveRow;
  236. if (ugr == null)
  237. {
  238. MessageUtil.ShowWarning("请选择一行合同行!");
  239. return;
  240. }
  241. FrmStableMps fsm = new FrmStableMps(this.ob);
  242. fsm.OrdLnPk = ugr.Cells["ORD_LN_PK"].Value.ToString();
  243. fsm.WindowState = FormWindowState.Maximized;
  244. fsm.WdType = "2";
  245. fsm.frmClosedRefresh += fsm_frmClosedRefresh;
  246. fsm.ShowDialog();
  247. }
  248. }
  249. void fsm_frmClosedRefresh()
  250. {
  251. InitGridData();
  252. }
  253. }
  254. }