F_PM_2405.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_2405.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_2405 : 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_2405()
  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_2405_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 SystemModuleProxy.Service.GetLogoInfo();
  97. }));
  98. if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
  99. {
  100. DataTable dtNew = dsResultLogo.Tables[0];
  101. DataRow dr = dtNew.NewRow();
  102. dr["LogoID"] = -1;
  103. dr["LogoNameCode"] = string.Empty;
  104. dtNew.Rows.InsertAt(dr, 0);
  105. this.cmbLogo.DataSource = dtNew;
  106. this.cmbLogo.ValueMember = "LogoID";
  107. this.cmbLogo.DisplayMember = "LogoNameCode";
  108. }
  109. this.btnSave.Enabled = false;
  110. }
  111. catch (Exception ex)
  112. {
  113. // 对异常进行共通处理
  114. ExceptionManager.HandleEventException(this.ToString(),
  115. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  116. }
  117. }
  118. /// <summary>
  119. /// 条形码按键事件
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  124. {
  125. try
  126. {
  127. if (this.txtBarcode.ReadOnly)
  128. {
  129. return;
  130. }
  131. if ((int)e.KeyChar == 13) // 按了回车键
  132. {
  133. this.btnSave.Visible = false;
  134. if (this.txtBarcode.Text.Trim() == "")
  135. {
  136. MessageBox.Show("产品条码不能为空", this.Text,
  137. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  138. this.txtBarcode.Focus();
  139. return;
  140. }
  141. // 异步处理,获取信息
  142. ClientRequestEntity cre = new ClientRequestEntity();
  143. cre.NameSpace = "F_PM_2405";
  144. cre.Name = "FinishedHandoverBarcode";
  145. cre.Properties["Barcode"] = this.txtBarcode.Text.Trim();
  146. cre.Properties["HandoverFlag"] = 2;
  147. // 调用服务器端获取数据集
  148. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  149. {
  150. return PMModuleProxyNew.Service.HandleRequest(cre);
  151. }));
  152. if (!(sre.Status == Constant.ServiceResultStatus.Success))
  153. {
  154. // 提示未查找到数据
  155. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  156. MessageBoxButtons.OK, MessageBoxIcon.Information);
  157. }
  158. if (Convert.ToInt32(sre.Result) > 0 && sre.Data.Tables[0].Rows.Count > 0)
  159. {
  160. this.dgvProduction.DataSource = sre.Data.Tables[0];
  161. _dataSourceTable = sre.Data.Tables[0];
  162. this.btnSave.Visible = true;
  163. this.btnSave.Enabled = true;
  164. }
  165. else
  166. {
  167. MessageBox.Show(sre.Message, this.Text,
  168. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  169. this.txtBarcode.SelectAll();
  170. return;
  171. }
  172. }
  173. }
  174. catch (Exception ex)
  175. {
  176. // 对异常进行共通处理
  177. ExceptionManager.HandleEventException(this.ToString(),
  178. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  179. }
  180. }
  181. /// <summary>
  182. /// 商标回车事件
  183. /// </summary>
  184. /// <param name="sender"></param>
  185. /// <param name="e"></param>
  186. private void txtOrderNo_KeyPress(object sender, KeyPressEventArgs e)
  187. {
  188. try
  189. {
  190. if (this.txtOrderNo.ReadOnly)
  191. {
  192. return;
  193. }
  194. if ((int)e.KeyChar == 13) // 按了回车键
  195. {
  196. DataTable dt = this.cmbLogo.DataSource as DataTable;
  197. if (dt != null && dt.Rows.Count > 0)
  198. {
  199. DataRow[] dr = dt.Select("LogoNameCode='" + this.txtOrderNo.Text.Trim() + "'");
  200. if (dr.Length > 0)
  201. {
  202. this.cmbLogo.SelectedValue = Convert.ToInt32(dr[0]["LogoID"]);
  203. }
  204. else
  205. {
  206. this.cmbLogo.SelectedIndex = 0;
  207. }
  208. this.txtOrderNo.Text = string.Empty;
  209. }
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. // 对异常进行共通处理
  215. ExceptionManager.HandleEventException(this.ToString(),
  216. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  217. }
  218. }
  219. /// <summary>
  220. /// 保存按钮事件
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void btnSave_Click(object sender, EventArgs e)
  225. {
  226. try
  227. {
  228. this.DataSourceTable.AcceptChanges();
  229. if (this.cmbLogo.SelectedValue.ToString() == "-1")
  230. {
  231. MessageBox.Show("请选择商标",
  232. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  233. this.cmbLogo.Focus();
  234. return;
  235. }
  236. ClientRequestEntity cre = new ClientRequestEntity();
  237. cre.NameSpace = "F_PM_2405";
  238. cre.Name = "SetFinishedLogo";
  239. string barcodes = string.Empty;
  240. foreach (DataGridViewRow row in this.dgvProduction.Rows)
  241. {
  242. barcodes += row.Cells["BarCode"].Value +",";
  243. }
  244. cre.Properties["Barcodes"] = barcodes.Substring(0, barcodes.Length-1);
  245. cre.Properties["LogoID"] = Convert.ToInt32(this.cmbLogo.SelectedValue);
  246. // 异步处理
  247. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
  248. {
  249. return PMModuleProxyNew.Service.HandleRequest(cre);
  250. }));
  251. if (Convert.ToInt32(sre.Result) < 0)
  252. {
  253. MessageBox.Show(sre.Message,
  254. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  255. return;
  256. }
  257. else
  258. {
  259. // 提示信息
  260. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  261. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  262. this.txtBarcode.Text = string.Empty;
  263. this.DataSourceTable.Rows.Clear();
  264. this.cmbLogo.SelectedValue = -1;
  265. this.txtOrderNo.Text = string.Empty;
  266. this.btnSave.Visible = false;
  267. this.btnSave.Enabled = false;
  268. }
  269. }
  270. catch (Exception ex)
  271. {
  272. // 对异常进行共通处理
  273. ExceptionManager.HandleEventException(this.ToString(),
  274. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  275. }
  276. }
  277. /// <summary>
  278. /// 自动适应列宽
  279. /// </summary>
  280. /// <param name="sender"></param>
  281. /// <param name="e"></param>
  282. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  283. {
  284. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  285. }
  286. /// <summary>
  287. /// 窗体关闭事件
  288. /// </summary>
  289. /// <param name="sender"></param>
  290. /// <param name="e"></param>
  291. private void btnClose_Click(object sender, EventArgs e)
  292. {
  293. this.Close();
  294. }
  295. /// <summary>
  296. /// 窗体关闭时事件
  297. /// </summary>
  298. /// <param name="sender"></param>
  299. /// <param name="e"></param>
  300. private void F_PM_0302_FormClosing(object sender, FormClosingEventArgs e)
  301. {
  302. if (this.btnSave.Visible)
  303. {
  304. try
  305. {
  306. this.DataSourceTable.AcceptChanges();
  307. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO && !"-1".Equals(this.cmbLogo.SelectedValue + ""))
  308. {
  309. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  310. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  311. if (result == DialogResult.Yes)
  312. {
  313. // 保存数据
  314. btnSave_Click(sender, e);
  315. }
  316. else if (result == DialogResult.Cancel)
  317. {
  318. e.Cancel = true;
  319. }
  320. }
  321. }
  322. catch (Exception ex)
  323. {
  324. // 对异常进行共通处理
  325. ExceptionManager.HandleEventException(this.ToString(),
  326. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  327. }
  328. }
  329. }
  330. #endregion
  331. }
  332. }