F_PC_1002.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PC_1002.cs
  5. * 2.功能描述:新建、编辑模具档案
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Drawing;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.PCModule
  22. {
  23. /// <summary>
  24. /// 新建、编辑模具档案
  25. /// </summary>
  26. public partial class F_PC_1002 : DKFormBase
  27. {
  28. #region 成员变量
  29. /// <summary>
  30. /// 模具ID
  31. /// </summary>
  32. private int _mouldID = 0;
  33. #endregion
  34. #region 构造函数
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PC_1002(int mouldID)
  39. {
  40. InitializeComponent();
  41. //this.txtWeight.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
  42. //this.txtCost.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
  43. //this.txtStandardGroutingNum.Number = new Dongke.WinForm.Controls.DNumber(6, 0);
  44. //txtOutputCount.Number = new Dongke.WinForm.Controls.DNumber(3, 0);
  45. this.txtWeight.Number = new Point(5, 2);
  46. this.txtCost.Number = new Point(5, 2);
  47. this.txtStandardGroutingNum.Number = new Point(6, 0);
  48. txtOutputCount.Number = new Point(3, 0);
  49. this._mouldID = mouldID;
  50. if (this._mouldID > 0)
  51. {
  52. this.Text = "编辑模具档案";
  53. this.txtBarcode.ReadOnly = true;
  54. this.scbGoods.EditReadOnly = true;
  55. this.scbGoods.Enabled = false;
  56. }
  57. else
  58. {
  59. this.Text = "新建模具档案";
  60. }
  61. }
  62. #endregion
  63. #region 事件处理
  64. /// <summary>
  65. /// 画面加载
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void F_PC_1002_Load(object sender, System.EventArgs e)
  70. {
  71. try
  72. {
  73. if (this._mouldID > 0)
  74. {
  75. chkAutoPrint.Checked = false;
  76. chkAutoPrint.Visible = false;
  77. txtMCount.Visible = false;
  78. lblMCount.Visible = false;
  79. }
  80. this.dtpPDate.Value = DateTime.Now;
  81. ClientRequestEntity cre = new ClientRequestEntity();
  82. cre.NameSpace = "FPC1002";
  83. cre.Name = "GetFPC1002LoadData";
  84. cre.Properties["MouldID"] = this._mouldID;
  85. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  86. if (sre == null)
  87. {
  88. this.Close();
  89. return;
  90. }
  91. this.ftcMouldType.DataSource = sre.Data.Tables["MouldType"];
  92. this.ftcSuppliers.DataSource = sre.Data.Tables["Suppliers"];
  93. if (this._mouldID > 0)
  94. {
  95. DataRow item = sre.Data.Tables["InfoData"].Rows[0];
  96. // 编辑
  97. this.txtBarcode.Text = item["MouldBarcode"].ToString();
  98. this.scbGoods.CheckedData = sre.Data.Tables["InfoData"];
  99. this.scbGoods.Text = item["GoodsCode"].ToString();
  100. this.ftcMouldType.InitValue(item["MouldTypeName"].ToString(), item["MouldType"]);
  101. this.ftcSuppliers.InitValue(item["SupplierName"].ToString(), item["materialsupplier"]);
  102. this.dtpPDate.Value = Convert.ToDateTime(item["ProductionDate"]);
  103. this.txtWeight.DataValue = Convert.ToDecimal(item["Weight"]);
  104. this.txtCost.DataValue = Convert.ToDecimal(item["Cost"]);
  105. this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
  106. this.txtOutputCount.DataValue = Convert.ToDecimal(item["OutputCount"]);
  107. this.txtRemarks.Text = item["Remarks"].ToString();
  108. this.dkUserInfo.Text = item["UserCode"].ToString();
  109. this.dkUserInfo.UserCode = item["UserCode"].ToString();
  110. this.dkUserInfo.UserID = Convert.ToInt32(item["UserID"]);
  111. this.txtStandardGroutingNum.ReadOnly = true;
  112. this.txtOutputCount.ReadOnly = true;
  113. }
  114. else
  115. {
  116. //this.txtBarcode.Text = DateTime.Now.ToString("yyMMdd") + "XXXXXX";
  117. this.dkUserInfo.Text = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  118. this.dkUserInfo.UserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
  119. this.dkUserInfo.UserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. // 对异常进行共通处理
  125. ExceptionManager.HandleEventException(this.ToString(),
  126. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  127. }
  128. }
  129. /// <summary>
  130. /// 关闭画面
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void btnCancel_Click(object sender, System.EventArgs e)
  135. {
  136. if (this._mouldID < 0)
  137. {
  138. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  139. }
  140. else
  141. {
  142. this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  143. }
  144. this.Close();
  145. }
  146. /// <summary>
  147. /// 保存
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. private void btnSave_Click(object sender, EventArgs e)
  152. {
  153. try
  154. {
  155. if (!this.CheckInput())
  156. {
  157. return;
  158. }
  159. ClientRequestEntity cre = new ClientRequestEntity();
  160. cre.NameSpace = "FPC1002";
  161. cre.Name = "SetFPC1002Data";
  162. cre.Properties["MouldID"] = (this._mouldID > 0 ? this._mouldID : 0);
  163. //cre.Properties["MouldBarcode"] = this.txtBarcode.Text.Trim();
  164. cre.Properties["GoodsID"] = scbGoods.SearchedPKMember;
  165. cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  166. cre.Properties["MouldType"] = this.ftcMouldType.SelectedValue;
  167. cre.Properties["MaterialSupplier"] = this.ftcSuppliers.SelectedValue;
  168. cre.Properties["ProductionDate"] = this.dtpPDate.Value;
  169. cre.Properties["UserID"] = this.dkUserInfo.UserID;
  170. cre.Properties["UserCode"] = this.dkUserInfo.UserCode;
  171. cre.Properties["Weight"] = this.txtWeight.DataValue;
  172. cre.Properties["Cost"] = this.txtCost.DataValue;
  173. cre.Properties["StandardGroutingNum"] = this.txtStandardGroutingNum.DataValue;
  174. cre.Properties["OutputCount"] = this.txtOutputCount.DataValue;
  175. cre.Properties["Remarks"] = this.txtRemarks.Text;
  176. cre.Properties["MCount"] = this.txtMCount.DataValue;
  177. ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
  178. {
  179. return PCModuleProxyNew.Service.HandleRequest(cre);
  180. });
  181. if (sre != null)
  182. {
  183. if (sre.Status == Constant.ServiceResultStatus.Success)
  184. {
  185. if (this.chkAutoPrint.Checked && sre.Result != null)
  186. {
  187. string[] barcodes = (sre.Result as string).Split(',');
  188. foreach (string item in barcodes)
  189. {
  190. F_MST_013006.PrintBarcode(item, 1, this);
  191. }
  192. }
  193. // 提示信息
  194. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  195. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  196. if (this._mouldID > 0)
  197. {
  198. this.DialogResult = DialogResult.OK;
  199. this.Close();
  200. }
  201. else
  202. {
  203. this._mouldID = -1;
  204. this.ClearData();
  205. this.txtBarcode.Focus();
  206. }
  207. }
  208. else if (!string.IsNullOrWhiteSpace(sre.Message))
  209. {
  210. MessageBox.Show(sre.Message,
  211. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  212. }
  213. }
  214. else
  215. {
  216. // 提示信息
  217. MessageBox.Show("保存失败",
  218. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  219. }
  220. }
  221. catch (Exception ex)
  222. {
  223. // 对异常进行共通处理
  224. ExceptionManager.HandleEventException(this.ToString(),
  225. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  226. }
  227. }
  228. /// <summary>
  229. /// 选择产品型号
  230. /// </summary>
  231. /// <param name="sender"></param>
  232. /// <param name="e"></param>
  233. private void scbGoods_SearchedItemChanged(object sender, EventArgs e)
  234. {
  235. if (string.IsNullOrEmpty(this.scbGoods.Text))
  236. {
  237. return;
  238. }
  239. try
  240. {
  241. ClientRequestEntity cre = new ClientRequestEntity();
  242. cre.NameSpace = "FPC1002";
  243. cre.Name = "GetFPC1002GoodsData";
  244. cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  245. ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  246. if (sre == null)
  247. {
  248. return;
  249. }
  250. DataRow item = sre.Data.Tables[0].Rows[0];
  251. if (item["MouldWeight"] != DBNull.Value)
  252. {
  253. this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
  254. }
  255. if (item["MouldCost"] != DBNull.Value)
  256. {
  257. this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
  258. }
  259. if (item["StandardGroutingNum"] != DBNull.Value)
  260. {
  261. this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
  262. }
  263. if (item["MouldOutputCount"] != DBNull.Value)
  264. {
  265. this.txtOutputCount.DataValue = Convert.ToDecimal(item["MouldOutputCount"]);
  266. }
  267. }
  268. catch (Exception ex)
  269. {
  270. // 对异常进行共通处理
  271. ExceptionManager.HandleEventException(this.ToString(),
  272. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  273. }
  274. }
  275. ///// <summary>
  276. ///// 选择产品型号
  277. ///// </summary>
  278. ///// <param name="sender"></param>
  279. ///// <param name="e"></param>
  280. //private void dkGoodsCode_GoodsValueChanged(object sender, Controls.SearchTextBox.dkGoodsCodeSearchBox.TextChangeEventArgs e)
  281. //{
  282. // if (string.IsNullOrEmpty(this.scbGoods.Text))
  283. // {
  284. // return;
  285. // }
  286. // try
  287. // {
  288. // ClientRequestEntity cre = new ClientRequestEntity();
  289. // cre.NameSpace = "FPC1002";
  290. // cre.Name = "GetFPC1002GoodsData";
  291. // cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
  292. // ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
  293. // if (sre == null)
  294. // {
  295. // return;
  296. // }
  297. // DataRow item = sre.Data.Tables[0].Rows[0];
  298. // if (item["MouldWeight"] != DBNull.Value)
  299. // {
  300. // this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
  301. // }
  302. // if (item["MouldCost"] != DBNull.Value)
  303. // {
  304. // this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
  305. // }
  306. // }
  307. // catch (Exception ex)
  308. // {
  309. // // 对异常进行共通处理
  310. // ExceptionManager.HandleEventException(this.ToString(),
  311. // MethodBase.GetCurrentMethod().Name, this.Text, ex);
  312. // }
  313. //}
  314. #endregion
  315. #region 私有方法
  316. /// <summary>
  317. /// 清除画面数据
  318. /// </summary>
  319. private void ClearData()
  320. {
  321. this.txtBarcode.Clear();
  322. //this.dkGoodsCode.Text = null;
  323. //this.dkGoodsCode.GoodsID = null;
  324. //this.dkGoodsCode.GoodsCode = null;
  325. //this.ftcMouldType.ClearValue();
  326. //this.ftcSuppliers.ClearValue();
  327. //this.dtpPDate.ClearValue();
  328. //this.txtWeight.Clear();
  329. //this.txtCost.Clear();
  330. //this.txtStandardGroutingNum.Clear();
  331. //this.txtRemarks.Clear();
  332. //this.dkUserInfo.Text = null;
  333. //this.dkUserInfo.UserCode = null;
  334. //this.dkUserInfo.UserID = null;
  335. }
  336. /// <summary>
  337. /// 保存前画面数据验证
  338. /// </summary>
  339. /// <returns></returns>
  340. private bool CheckInput()
  341. {
  342. if (this._mouldID <= 0)
  343. {
  344. //if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
  345. //{
  346. // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具条码"),
  347. // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  348. // MessageBoxDefaultButton.Button1);
  349. // this.txtBarcode.Focus();
  350. // return false;
  351. //}
  352. if (this.scbGoods.SearchedPKMember == 0)
  353. {
  354. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
  355. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  356. MessageBoxDefaultButton.Button1);
  357. this.scbGoods.Focus();
  358. return false;
  359. }
  360. }
  361. if (this.ftcMouldType.SelectedValue == null)
  362. {
  363. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具类型"),
  364. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  365. MessageBoxDefaultButton.Button1);
  366. this.ftcMouldType.Focus();
  367. return false;
  368. }
  369. if (this.ftcSuppliers.SelectedValue == null)
  370. {
  371. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "材料供应商"),
  372. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  373. MessageBoxDefaultButton.Button1);
  374. this.ftcSuppliers.Focus();
  375. return false;
  376. }
  377. if (this.txtWeight.DataValue == null)
  378. {
  379. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具重量"),
  380. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  381. MessageBoxDefaultButton.Button1);
  382. this.txtWeight.Focus();
  383. return false;
  384. }
  385. if (this.txtCost.DataValue == null)
  386. {
  387. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具成本"),
  388. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  389. MessageBoxDefaultButton.Button1);
  390. this.txtCost.Focus();
  391. return false;
  392. }
  393. if (this.dkUserInfo.UserID == null)
  394. {
  395. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "生产工号"),
  396. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  397. MessageBoxDefaultButton.Button1);
  398. this.dkUserInfo.Focus();
  399. return false;
  400. }
  401. if (this.txtStandardGroutingNum.DataValue == null)
  402. {
  403. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "标准注浆次数"),
  404. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  405. MessageBoxDefaultButton.Button1);
  406. this.txtStandardGroutingNum.Focus();
  407. return false;
  408. }
  409. if (this.txtOutputCount.DataValue == null)
  410. {
  411. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产出数量"),
  412. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
  413. MessageBoxDefaultButton.Button1);
  414. this.txtOutputCount.Focus();
  415. return false;
  416. }
  417. return true;
  418. }
  419. #endregion
  420. private void txtOutputCount_TextChanged(object sender, EventArgs e)
  421. {
  422. try
  423. {
  424. int mouldOutputCount = (this.txtOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtOutputCount.DataValue) : 1);
  425. int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
  426. this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum;
  427. }
  428. catch (Exception ex)
  429. {
  430. // 对异常进行共通处理
  431. ExceptionManager.HandleEventException(this.ToString(),
  432. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  433. }
  434. }
  435. }
  436. }