F_PM_2406.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2406.cs
  5. * 2.功能描述:变更单号整板
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2018/08/06 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. namespace Dongke.IBOSS.PRD.Client.PMModule
  19. {
  20. public partial class F_PM_2406 : FormBase
  21. {
  22. #region 成员变量
  23. private DataTable _dataSourceTable; // 数据源Table
  24. #endregion
  25. #region 属性
  26. /// <summary>
  27. /// 绑定GridView数据源
  28. /// </summary>
  29. public DataTable DataSourceTable
  30. {
  31. set
  32. {
  33. _dataSourceTable = value;
  34. }
  35. get
  36. {
  37. if (_dataSourceTable == null)
  38. {
  39. _dataSourceTable = new DataTable("dataSourceTable");
  40. _dataSourceTable.Columns.Add("BarCode");
  41. _dataSourceTable.Columns.Add("FinishedBarCode");
  42. _dataSourceTable.Columns.Add("logoid");
  43. _dataSourceTable.Columns.Add("logocode");
  44. _dataSourceTable.Columns.Add("logoname");
  45. _dataSourceTable.Columns.Add("goodscode");
  46. _dataSourceTable.Columns.Add("UserID");
  47. _dataSourceTable.Columns.Add("GroutingUserCode");
  48. _dataSourceTable.Columns.Add("MouldCode");
  49. _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
  50. _dataSourceTable.Columns.Add("DeliverTime", typeof(DateTime));
  51. _dataSourceTable.Columns.Add("GoodsModel");
  52. _dataSourceTable.Columns.Add("PlateLimitNum");
  53. _dataSourceTable.Columns.Add("OrderNo");
  54. _dataSourceTable.Columns.Add("FHTime", typeof(DateTime));
  55. _dataSourceTable.Columns.Add("FHUserCode");
  56. return _dataSourceTable;
  57. }
  58. else
  59. {
  60. return _dataSourceTable;
  61. }
  62. }
  63. }
  64. #endregion
  65. #region 构造函数
  66. /// <summary>
  67. /// 构造函数
  68. /// </summary>
  69. public F_PM_2406()
  70. {
  71. InitializeComponent();
  72. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  73. this.btnSave.Text = ButtonText.BTN_SAVE;
  74. this.btnCancel.Text = ButtonText.BTN_CANCEL;
  75. }
  76. #endregion
  77. #region 事件
  78. /// <summary>
  79. /// 窗体加载事件
  80. /// </summary>
  81. /// <param name="sender"></param>
  82. /// <param name="e"></param>
  83. private void F_PM_2406_Load(object sender, EventArgs e)
  84. {
  85. try
  86. {
  87. this.dgvProduction.AutoGenerateColumns = false;
  88. this.dgvProduction.DataSource = DataSourceTable;
  89. // 加载权限
  90. FormPermissionManager.FormPermissionControl(this.Name, this,
  91. DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  92. DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  93. // 加载订单数据源
  94. DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  95. {
  96. return PMModuleProxy.Service.GetOrderList(new OrderEntity());
  97. }));
  98. if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
  99. {
  100. DataView dv = dsResultLogo.Tables[0].DefaultView;
  101. dv.RowFilter = "ValueFlag=1";
  102. DataTable dtNew = dv.ToTable();
  103. DataRow dr = dtNew.NewRow();
  104. dr["OrderID"] = -1;
  105. dr["OrderNo"] = string.Empty;
  106. dtNew.Rows.InsertAt(dr, 0);
  107. this.cmbLogo.DataSource = dtNew;
  108. this.cmbLogo.ValueMember = "OrderID";
  109. this.cmbLogo.DisplayMember = "OrderNo";
  110. }
  111. this.btnSave.Enabled = false;
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. /// <summary>
  121. /// 条形码按键事件
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  126. {
  127. try
  128. {
  129. if (this.txtBarcode.ReadOnly)
  130. {
  131. return;
  132. }
  133. if ((int)e.KeyChar == 13) // 按了回车键
  134. {
  135. this.btnSave.Visible = false;
  136. if (this.txtBarcode.Text.Trim() == "")
  137. {
  138. MessageBox.Show("产品条码不能为空", this.Text,
  139. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  140. this.txtBarcode.Focus();
  141. return;
  142. }
  143. // 异步处理,获取信息
  144. ClientRequestEntity cre = new ClientRequestEntity();
  145. cre.NameSpace = "F_PM_2406";
  146. cre.Name = "FinishedHandoverBarcode";
  147. cre.Properties["Barcode"] = this.txtBarcode.Text.Trim();
  148. cre.Properties["HandoverFlag"] = 1;
  149. // 调用服务器端获取数据集
  150. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  151. {
  152. return PMModuleProxyNew.Service.HandleRequest(cre);
  153. }));
  154. if (!(sre.Status == Constant.ServiceResultStatus.Success))
  155. {
  156. // 提示未查找到数据
  157. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  158. MessageBoxButtons.OK, MessageBoxIcon.Information);
  159. return;
  160. }
  161. if (sre.Result + "" == "-1")
  162. {
  163. // 提示未查找到数据
  164. MessageBox.Show(sre.Message, this.Text,
  165. MessageBoxButtons.OK, MessageBoxIcon.Information);
  166. return;
  167. }
  168. if (Convert.ToInt32(sre.Result) > 0 && sre.Data.Tables[0].Rows.Count > 0)
  169. {
  170. this.dgvProduction.DataSource = sre.Data.Tables[0];
  171. _dataSourceTable = sre.Data.Tables[0];
  172. this.btnSave.Visible = true;
  173. this.btnSave.Enabled = true;
  174. }
  175. else
  176. {
  177. MessageBox.Show(sre.Message, this.Text,
  178. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  179. this.txtBarcode.SelectAll();
  180. return;
  181. }
  182. }
  183. }
  184. catch (Exception ex)
  185. {
  186. // 对异常进行共通处理
  187. ExceptionManager.HandleEventException(this.ToString(),
  188. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  189. }
  190. }
  191. /// <summary>
  192. /// 生产订单号回车事件
  193. /// </summary>
  194. /// <param name="sender"></param>
  195. /// <param name="e"></param>
  196. private void txtOrderNo_KeyPress(object sender, KeyPressEventArgs e)
  197. {
  198. try
  199. {
  200. if (this.txtOrderNo.ReadOnly)
  201. {
  202. return;
  203. }
  204. if ((int)e.KeyChar == 13) // 按了回车键
  205. {
  206. DataTable dt = this.cmbLogo.DataSource as DataTable;
  207. if (dt != null && dt.Rows.Count > 0)
  208. {
  209. DataRow[] dr = dt.Select("OrderNo='" + this.txtOrderNo.Text.Trim() + "'");
  210. if (dr.Length > 0)
  211. {
  212. this.cmbLogo.SelectedValue = Convert.ToInt32(dr[0]["OrderID"]);
  213. }
  214. else
  215. {
  216. this.cmbLogo.SelectedIndex = 0;
  217. }
  218. this.txtOrderNo.Text = string.Empty;
  219. }
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. // 对异常进行共通处理
  225. ExceptionManager.HandleEventException(this.ToString(),
  226. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  227. }
  228. }
  229. /// <summary>
  230. /// 保存按钮事件
  231. /// </summary>
  232. /// <param name="sender"></param>
  233. /// <param name="e"></param>
  234. private void btnSave_Click(object sender, EventArgs e)
  235. {
  236. try
  237. {
  238. this.DataSourceTable.AcceptChanges();
  239. if (this.cmbLogo.SelectedValue.ToString() == "-1")
  240. {
  241. MessageBox.Show("请选择生产订单",
  242. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  243. this.cmbLogo.Focus();
  244. return;
  245. }
  246. ClientRequestEntity cre = new ClientRequestEntity();
  247. cre.NameSpace = "F_PM_2406";
  248. cre.Name = "SetHandoveredOrder";
  249. string barcodes = string.Empty;
  250. foreach (DataGridViewRow row in this.dgvProduction.Rows)
  251. {
  252. barcodes += row.Cells["BarCode"].Value +",";
  253. }
  254. cre.Properties["Barcodes"] = barcodes.Substring(0, barcodes.Length-1);
  255. cre.Properties["OrderID"] = Convert.ToInt32(this.cmbLogo.SelectedValue);
  256. // 异步处理
  257. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  258. {
  259. return PMModuleProxyNew.Service.HandleRequest(cre);
  260. }));
  261. if (Convert.ToInt32(sre.Result) < 0)
  262. {
  263. MessageBox.Show(sre.Message,
  264. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  265. return;
  266. }
  267. else
  268. {
  269. // 提示信息
  270. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  271. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  272. this.txtBarcode.Text = string.Empty;
  273. this.DataSourceTable.Rows.Clear();
  274. this.cmbLogo.SelectedValue = -1;
  275. this.txtOrderNo.Text = string.Empty;
  276. this.btnSave.Visible = false;
  277. this.btnSave.Enabled = false;
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. // 对异常进行共通处理
  283. ExceptionManager.HandleEventException(this.ToString(),
  284. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  285. }
  286. }
  287. /// <summary>
  288. /// 自动适应列宽
  289. /// </summary>
  290. /// <param name="sender"></param>
  291. /// <param name="e"></param>
  292. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  293. {
  294. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  295. }
  296. /// <summary>
  297. /// 窗体关闭事件
  298. /// </summary>
  299. /// <param name="sender"></param>
  300. /// <param name="e"></param>
  301. private void btnClose_Click(object sender, EventArgs e)
  302. {
  303. this.Close();
  304. }
  305. /// <summary>
  306. /// 窗体关闭时事件
  307. /// </summary>
  308. /// <param name="sender"></param>
  309. /// <param name="e"></param>
  310. private void F_PM_0302_FormClosing(object sender, FormClosingEventArgs e)
  311. {
  312. if (this.btnSave.Visible)
  313. {
  314. try
  315. {
  316. this.DataSourceTable.AcceptChanges();
  317. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO && !"-1".Equals(this.cmbLogo.SelectedValue + ""))
  318. {
  319. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  320. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  321. if (result == DialogResult.Yes)
  322. {
  323. // 保存数据
  324. btnSave_Click(sender, e);
  325. }
  326. else if (result == DialogResult.Cancel)
  327. {
  328. e.Cancel = true;
  329. }
  330. }
  331. }
  332. catch (Exception ex)
  333. {
  334. // 对异常进行共通处理
  335. ExceptionManager.HandleEventException(this.ToString(),
  336. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  337. }
  338. }
  339. }
  340. #endregion
  341. }
  342. }