F_PM_2407.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_0302.cs
  5. * 2.功能描述:新建标准、坯库计件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/23 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls.FormCommon;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  21. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  22. using Dongke.IBOSS.PRD.Client.DataModels;
  23. using Dongke.IBOSS.PRD.Basics.Library;
  24. namespace Dongke.IBOSS.PRD.Client.PMModule
  25. {
  26. public partial class F_PM_2407 : FormBase
  27. {
  28. #region 成员变量
  29. // 数据源Table
  30. private DataTable _dataSourceTable = null;
  31. // 是否有商标
  32. private int? _isLogo = null;
  33. // 是否有商标编码
  34. private string _isLogoCode = "";
  35. // 是否有商标名称
  36. private string _isLogoName = "";
  37. // 1.产成品交接是否限制同商标
  38. private string _isEnable_S_PM_011 = "0";
  39. // 2.产成品交接是否限制同型号
  40. private string _isEnable_S_PM_012 = "0";
  41. // 3.产成品交接是否限制每板装板数量(必须先启用限制同型号);
  42. private string _isEnable_S_PM_013 = "0";
  43. // 最大限制数量
  44. private int _maxPlateLimitNum = 0;
  45. // 产品型号
  46. private string _goodsModel = string.Empty;
  47. // 商标ID
  48. private int? _logoID = null;
  49. // 商标ID
  50. private string _logoName = string.Empty;
  51. #endregion
  52. #region 属性
  53. /// <summary>
  54. /// 绑定GridView数据源
  55. /// </summary>
  56. public DataTable DataSourceTable
  57. {
  58. set
  59. {
  60. _dataSourceTable = value;
  61. }
  62. get
  63. {
  64. if (_dataSourceTable == null)
  65. {
  66. _dataSourceTable = new DataTable("dataSourceTable");
  67. _dataSourceTable.Columns.Add("BarCode");
  68. _dataSourceTable.Columns.Add("FinishedBarCode");
  69. _dataSourceTable.Columns.Add("logoid");
  70. _dataSourceTable.Columns.Add("logocode");
  71. _dataSourceTable.Columns.Add("logoname");
  72. _dataSourceTable.Columns.Add("goodscode");
  73. _dataSourceTable.Columns.Add("UserID");
  74. _dataSourceTable.Columns.Add("GroutingUserCode");
  75. _dataSourceTable.Columns.Add("MouldCode");
  76. _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime));
  77. _dataSourceTable.Columns.Add("DeliverTime", typeof(DateTime));
  78. _dataSourceTable.Columns.Add("GoodsModel");
  79. _dataSourceTable.Columns.Add("PlateLimitNum");
  80. _dataSourceTable.Columns.Add("OrderNo");
  81. _dataSourceTable.Columns.Add("FHTime", typeof(DateTime));
  82. _dataSourceTable.Columns.Add("FHUserCode");
  83. return _dataSourceTable;
  84. }
  85. else
  86. {
  87. return _dataSourceTable;
  88. }
  89. }
  90. }
  91. #endregion
  92. #region 构造函数
  93. public F_PM_2407()
  94. {
  95. InitializeComponent();
  96. }
  97. #endregion
  98. #region 事件
  99. /// <summary>
  100. /// 窗体关闭事件
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void btnClose_Click(object sender, EventArgs e)
  105. {
  106. this.Close();
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void tsbtnClose_Click(object sender, EventArgs e)
  114. {
  115. this.Close();
  116. }
  117. /// <summary>
  118. /// 条形码按键事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
  123. {
  124. try
  125. {
  126. if (this.txtBarcode.ReadOnly)
  127. {
  128. return;
  129. }
  130. if ((int)e.KeyChar == 13) // 按了回车键
  131. {
  132. if (this.txtBarcode.Text.Trim() == string.Empty)
  133. {
  134. this.txtBarcode.Focus();
  135. return;
  136. }
  137. DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "' or FinishedBarCode='" + this.txtBarcode.Text.Trim() + "'");
  138. if (drRows.Length == Constant.INT_IS_ZERO)
  139. {
  140. // 异步处理
  141. ClientRequestEntity cre = new ClientRequestEntity();
  142. cre.NameSpace = "F_PM_2407";
  143. cre.Name = "BackFinishedHandoverCheck";
  144. cre.Properties["Barcode"] = this.txtBarcode.Text;
  145. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(()
  146. => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  147. if (sre.Status == Constant.ServiceResultStatus.Success
  148. && sre.Data != null && sre.Data.Tables.Count > 0)
  149. {
  150. foreach (DataRow item in sre.Data.Tables[0].Rows)
  151. {
  152. // 添加产到列表
  153. DataRow dr = this.DataSourceTable.NewRow();
  154. dr["BarCode"] = item["BarCode"].ToString();
  155. dr["FinishedBarCode"] = item["FinishedBarCode"].ToString();
  156. dr["goodscode"] = item["goodscode"].ToString();
  157. dr["logoid"] = item["logoid"].ToString();
  158. dr["logoname"] = item["logoname"].ToString();
  159. dr["GroutingUserCode"] = item["GroutingUserCode"].ToString();
  160. dr["MouldCode"] = item["MouldCode"].ToString();
  161. dr["GroutingDate"] = item["GroutingDate"].ToString();
  162. if (!string.IsNullOrEmpty(item["DeliverTime"].ToString()))
  163. {
  164. dr["DeliverTime"] = item["DeliverTime"].ToString();
  165. }
  166. dr["FHTime"] = DateTime.Now;
  167. dr["FHUserCode"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  168. this.DataSourceTable.Rows.Add(dr);
  169. }
  170. this.dgvProduction.CurrentCell = null;
  171. this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true;
  172. this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0];
  173. this.txtBarcode.Focus();
  174. this.txtBarcode.SelectAll();
  175. this.txtBarcode.Text = "";
  176. this.btnSave.Visible = true;
  177. this.btnSave.Enabled = true;
  178. }
  179. else
  180. {
  181. if (sre.OtherStatus >0)
  182. {
  183. S_CMN_020 frmscmn020 = new S_CMN_020(sre.OtherStatus, sre.Message);
  184. frmscmn020.ShowDialog();
  185. }
  186. else
  187. {
  188. // 表示有错误
  189. MessageBox.Show(string.Format(sre.Message, this.txtBarcode.Text.Trim(), "产品条码"),
  190. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  191. }
  192. this.txtBarcode.Focus();
  193. this.txtBarcode.SelectAll();
  194. return;
  195. }
  196. }
  197. else
  198. {
  199. this.txtBarcode.Text = "";
  200. }
  201. }
  202. }
  203. catch (Exception ex)
  204. {
  205. // 对异常进行共通处理
  206. ExceptionManager.HandleEventException(this.ToString(),
  207. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  208. }
  209. }
  210. /// <summary>
  211. /// 窗体加载事件
  212. /// </summary>
  213. /// <param name="sender"></param>
  214. /// <param name="e"></param>
  215. private void F_PM_2407_Load(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. this.dgvProduction.AutoGenerateColumns = false;
  220. this.dgvProduction.DataSource = DataSourceTable;
  221. // 加载权限
  222. FormPermissionManager.FormPermissionControl(this.Name, this,
  223. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  224. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  225. this.btnSave.Enabled = false;
  226. }
  227. catch (Exception ex)
  228. {
  229. // 对异常进行共通处理
  230. ExceptionManager.HandleEventException(this.ToString(),
  231. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  232. }
  233. }
  234. /// <summary>
  235. /// 删除按钮事件
  236. /// </summary>
  237. /// <param name="sender"></param>
  238. /// <param name="e"></param>
  239. private void tsbtnDelete_Click(object sender, EventArgs e)
  240. {
  241. if (this.dgvProduction.CurrentCell != null)
  242. {
  243. this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete();
  244. if (this.DataSourceTable.Rows.Count == 0)
  245. {
  246. // 最大限制数量
  247. this._maxPlateLimitNum = 0;
  248. // 产品型号
  249. this._goodsModel = string.Empty;
  250. // 商标ID
  251. this._logoID = null;
  252. // 商标ID
  253. this._logoName = string.Empty;
  254. this.btnSave.Visible = false;
  255. this.btnSave.Enabled = false;
  256. }
  257. }
  258. }
  259. /// <summary>
  260. /// 保存按钮事件
  261. /// </summary>
  262. /// <param name="sender"></param>
  263. /// <param name="e"></param>
  264. private void btnSave_Click(object sender, EventArgs e)
  265. {
  266. try
  267. {
  268. this.DataSourceTable.AcceptChanges();
  269. DataSet ds = new DataSet();
  270. ds.Tables.Add(DataSourceTable.Copy());
  271. // 异步处理
  272. ClientRequestEntity cre = new ClientRequestEntity();
  273. cre.NameSpace = "F_PM_2407";
  274. cre.Name = "BackFinishedHandover";
  275. cre.Data = ds;
  276. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(()
  277. => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  278. if (sre.Result.ToNullableInt32() < 0)
  279. {
  280. MessageBox.Show(sre.Message,
  281. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  282. return;
  283. }
  284. else
  285. {
  286. // 提示信息
  287. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"),
  288. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  289. this.txtBarcode.Text = string.Empty;
  290. this.DataSourceTable.Rows.Clear();
  291. this.btnSave.Visible = false;
  292. this.btnSave.Enabled = false;
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. // 对异常进行共通处理
  298. ExceptionManager.HandleEventException(this.ToString(),
  299. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  300. }
  301. }
  302. /// <summary>
  303. /// 自动适应列宽
  304. /// </summary>
  305. /// <param name="sender"></param>
  306. /// <param name="e"></param>
  307. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  308. {
  309. this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  310. }
  311. /// <summary>
  312. /// 窗体关闭时事件
  313. /// </summary>
  314. /// <param name="sender"></param>
  315. /// <param name="e"></param>
  316. private void F_PM_0302_FormClosing(object sender, FormClosingEventArgs e)
  317. {
  318. if (this.btnSave.Visible)
  319. {
  320. try
  321. {
  322. this.DataSourceTable.AcceptChanges();
  323. if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO)
  324. {
  325. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  326. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  327. if (result == DialogResult.Yes)
  328. {
  329. // 保存数据
  330. btnSave_Click(sender, e);
  331. }
  332. else if (result == DialogResult.Cancel)
  333. {
  334. e.Cancel = true;
  335. }
  336. }
  337. }
  338. catch (Exception ex)
  339. {
  340. // 对异常进行共通处理
  341. ExceptionManager.HandleEventException(this.ToString(),
  342. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  343. }
  344. }
  345. }
  346. #endregion
  347. #region 私有方法
  348. /// <summary>
  349. /// 获取系统参数
  350. /// </summary>
  351. /// <returns></returns>
  352. private object GetSystemData()
  353. {
  354. try
  355. {
  356. return SystemModuleProxy.Service.GetSystemData();
  357. }
  358. catch (Exception ex)
  359. {
  360. throw ex;
  361. }
  362. }
  363. #endregion
  364. }
  365. }