F_PM_3602.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_3602.cs
  5. * 2.功能描述:首件登记新建编辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 秦祺 2024/09/14 1.00 新建
  9. *******************************************************************************/
  10. using Dongke.IBOSS.PRD.Basics.BaseResources;
  11. using Dongke.IBOSS.PRD.Client.CommonModule;
  12. using Dongke.IBOSS.PRD.Client.Controls;
  13. using Dongke.IBOSS.PRD.WCF.DataModels;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. using System;
  16. using System.Data;
  17. using System.Windows.Forms;
  18. namespace Dongke.IBOSS.PRD.Client.PMModule
  19. {
  20. public partial class F_PM_3602 : DKDockPanelBase
  21. {
  22. #region 成员变量
  23. // 窗体的单例模式
  24. private static F_PM_3602 _instance;
  25. // 存储窗口的编辑状态
  26. private Constant.FormMode _editStatus;
  27. private int _registerID;
  28. private int _barID;
  29. #endregion
  30. #region 构造函数
  31. public F_PM_3602()
  32. {
  33. InitializeComponent();
  34. }
  35. /// <summary>
  36. /// 构造函数
  37. /// </summary>
  38. public F_PM_3602(Constant.FormMode editStatus, int registerID)
  39. {
  40. InitializeComponent();
  41. this._editStatus = editStatus;
  42. // 根据新建、编辑状态为标题赋值
  43. if (editStatus == Constant.FormMode.Add)
  44. {
  45. this.Text = "新建首件登记单";
  46. }
  47. else
  48. {
  49. this.Text = "编辑首件登记单";
  50. this._registerID = registerID;
  51. this.txtRegisterNo.ReadOnly = true;
  52. }
  53. // 按钮文本
  54. this.btnSave.Text = ButtonText.BTN_SAVE;
  55. }
  56. /// <summary>
  57. /// 构造函数
  58. /// </summary>
  59. public F_PM_3602(Constant.FormMode editStatus, int registerID, int barID)
  60. {
  61. InitializeComponent();
  62. this._editStatus = editStatus;
  63. this.Text = "编辑首件登记单";
  64. this._registerID = registerID;
  65. this._barID = barID;
  66. this.txtRegisterNo.ReadOnly = true;
  67. // 按钮文本
  68. this.btnSave.Text = ButtonText.BTN_SAVE;
  69. }
  70. #endregion
  71. #region 单例模式
  72. /// <summary>
  73. /// 单例模式,防止重复创建窗体
  74. /// </summary>
  75. public static F_PM_3602 Instance
  76. {
  77. get
  78. {
  79. if (_instance == null || _instance.IsDisposed)
  80. {
  81. _instance = new F_PM_3602();
  82. }
  83. return _instance;
  84. }
  85. }
  86. #endregion
  87. #region 事件处理
  88. /// <summary>
  89. /// 窗体加载事件
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void F_PM_3602_Load(object sender, EventArgs e)
  94. {
  95. try
  96. {
  97. //不自动添加列
  98. dgvRegisterDetail.AutoGenerateColumns = false;
  99. #region 车间
  100. DataTable dtWorkShop = new DataTable();
  101. dtWorkShop.Columns.Add("WorkShopID");
  102. dtWorkShop.Columns.Add("WorkShopNames");
  103. DataRow drWorkShop = dtWorkShop.NewRow();
  104. drWorkShop["WorkShopID"] = DBNull.Value;
  105. drWorkShop["WorkShopNames"] = Constant.CBO_SELECT_EMPTY_NAME;
  106. dtWorkShop.Rows.Add(drWorkShop);
  107. drWorkShop = dtWorkShop.NewRow();
  108. drWorkShop["WorkShopID"] = 1;
  109. drWorkShop["WorkShopNames"] = "1";
  110. dtWorkShop.Rows.Add(drWorkShop);
  111. drWorkShop = dtWorkShop.NewRow();
  112. drWorkShop["WorkShopID"] = 2;
  113. drWorkShop["WorkShopNames"] = "2";
  114. dtWorkShop.Rows.Add(drWorkShop);
  115. drWorkShop = dtWorkShop.NewRow();
  116. drWorkShop["WorkShopID"] = 3;
  117. drWorkShop["WorkShopNames"] = "3";
  118. dtWorkShop.Rows.Add(drWorkShop);
  119. cmbWORKSHOP.DisplayMember = "WorkShopID";
  120. cmbWORKSHOP.ValueMember = "WorkShopNames";
  121. cmbWORKSHOP.DataSource = dtWorkShop;
  122. #endregion
  123. #region 检验结果数据源
  124. DataTable dt = new DataTable();
  125. dt.Columns.Add("itemsValueID",typeof(decimal));
  126. dt.Columns.Add("itemsValueName");
  127. DataRow dr = dt.NewRow();
  128. dr["itemsValueID"] = 1;
  129. dr["itemsValueName"] = "合格";
  130. dt.Rows.Add(dr);
  131. dr = dt.NewRow();
  132. dr["itemsValueID"] = 0;
  133. dr["itemsValueName"] = "不合格";
  134. dt.Rows.Add(dr);
  135. this.citemsvalue.DisplayMember = "itemsValueName";
  136. this.citemsvalue.ValueMember = "itemsValueID";
  137. this.citemsvalue.DataSource = dt;
  138. #endregion
  139. #region 首件检验产品类型
  140. // 获取产品类型
  141. ServiceResultEntity sreType = DoAsync<ServiceResultEntity>(() =>
  142. {
  143. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC025");
  144. }
  145. );
  146. if (sreType.Data == null)
  147. {
  148. return;
  149. }
  150. if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > 0)
  151. {
  152. // 设置空选项
  153. DataRow dataRow = sreType.Data.Tables[0].NewRow();
  154. dataRow["DictionaryID"] = DBNull.Value;
  155. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  156. dataRow["DisplayNo"] = 0;
  157. sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  158. this.cmbFIRGOODSTYPE.DisplayMember = "DictionaryValue";
  159. this.cmbFIRGOODSTYPE.ValueMember = "DictionaryID";
  160. this.cmbFIRGOODSTYPE.DataSource = sreType.Data.Tables[0];
  161. }
  162. #endregion
  163. #region 首件检验检验依据
  164. // 获取检验依据
  165. ServiceResultEntity sreType1 = DoAsync<ServiceResultEntity>(() =>
  166. {
  167. return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC026");
  168. }
  169. );
  170. if (sreType1.Data == null)
  171. {
  172. return;
  173. }
  174. if (sreType1.Data != null && sreType1.Data.Tables[0].Rows.Count > 0)
  175. {
  176. // 设置空选项
  177. DataRow dataRow = sreType1.Data.Tables[0].NewRow();
  178. dataRow["DictionaryID"] = DBNull.Value;
  179. dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
  180. dataRow["DisplayNo"] = 0;
  181. sreType1.Data.Tables[0].Rows.InsertAt(dataRow, 0);
  182. this.cmbFIRBASIS.DisplayMember = "DictionaryValue";
  183. this.cmbFIRBASIS.ValueMember = "DictionaryID";
  184. this.cmbFIRBASIS.DataSource = sreType1.Data.Tables[0];
  185. }
  186. #endregion
  187. #region 查询当天的登记单号下一位
  188. this.txtRegisterNo.Text = DateTime.Now.ToString("yyyyMMddHHmmss");
  189. #endregion
  190. #region 编辑时查询数据 总单状态为已登记的不能修改总单,未登记的可以修改总单
  191. if (_registerID > 0)
  192. {
  193. ServiceResultEntity sreno = DoAsync<ServiceResultEntity>(() =>
  194. {
  195. ClientRequestEntity cre = new ClientRequestEntity();
  196. cre.NameSpace = "F_PM_3602";
  197. cre.Name = "GetInfo";
  198. cre.Properties["REGISTERID"] = _registerID;
  199. if (_barID > 0)
  200. {
  201. cre.Properties["BARID"] = _barID;
  202. }
  203. return PMModuleProxyNew.Service.HandleRequest(cre);
  204. });
  205. if (sreno != null && sreno.Data.Tables.Count > 0 && sreno.Data.Tables[0].Rows.Count > 0)
  206. {
  207. DataTable dtable = sreno.Data.Tables[0];
  208. this.txtRegisterNo.Text = dtable.Rows[0]["REGISTERNO"].ToString();
  209. this.cmbWORKSHOP.SelectedValue = Convert.ToInt32(dtable.Rows[0]["WORKSHOP"]);
  210. this.scbGoods.CheckedData = sreno.Data.Tables[0];
  211. this.scbGoods.Text = dtable.Rows[0]["GOODSNAME"].ToString();
  212. this.txtGoodsCode.Text = dtable.Rows[0]["GOODSCODE"].ToString();
  213. this.txtMATERIALCODE.Text = dtable.Rows[0]["MATERIALCODE"].ToString();
  214. this.txtFIRQUANTITY.Text = dtable.Rows[0]["FIRQUANTITY"].ToString();
  215. this.cmbFIRGOODSTYPE.SelectedValue = Convert.ToInt32(dtable.Rows[0]["FIRGOODSTYPE"]);
  216. this.cmbFIRBASIS.SelectedValue = Convert.ToInt32(dtable.Rows[0]["FIRBASIS"]);
  217. this.txtremarks.Text = dtable.Rows[0]["REMARKS"].ToString();
  218. this.txtBarcodes.Text = dtable.Rows[0]["BARCODES"].ToString();
  219. this.dtpACCOUNTDATE.Value = Convert.ToDateTime(dtable.Rows[0]["ACCOUNTDATE"].ToString());
  220. //加载商标
  221. scbGoods_SearchedItemChanged_1(null,null);
  222. this.cmbLogo.SelectedValue = Convert.ToInt32(dtable.Rows[0]["LOGOID"]);
  223. //状态不为0时,不允许修改总单
  224. if (Convert.ToInt32(dtable.Rows[0]["STATUS"]) != 0)
  225. {
  226. this.txtRegisterNo.ReadOnly = true;
  227. this.cmbWORKSHOP.Enabled = false;
  228. this.scbGoods.ReadOnly = true;
  229. this.txtGoodsCode.ReadOnly = true;
  230. this.txtMATERIALCODE.ReadOnly = true;
  231. this.cmbLogo.Enabled = false;
  232. this.txtFIRQUANTITY.ReadOnly = true;
  233. this.cmbFIRGOODSTYPE.Enabled = false;
  234. this.cmbFIRBASIS.Enabled = false;
  235. this.txtremarks.ReadOnly = true;
  236. this.txtBarcodes.ReadOnly = true;
  237. this.dtpACCOUNTDATE.Enabled = false;
  238. }
  239. //条码明细
  240. if (sreno.Data.Tables.Count > 1)
  241. {
  242. DataTable dtable2 = sreno.Data.Tables[1];
  243. this.dgvRegisterDetail.DataSource = dtable2;
  244. this.ITEMSYTPE.ReadOnly = true;
  245. this.ITEMSNAME.ReadOnly = true;
  246. this.ITEMSINFO.ReadOnly = true;
  247. }
  248. }
  249. }
  250. #endregion
  251. }
  252. catch (Exception ex)
  253. {
  254. // 对异常进行共通处理
  255. ExceptionManager.HandleEventException(this.ToString(),
  256. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  257. }
  258. }
  259. /// <summary>
  260. /// 窗体关闭事件
  261. /// </summary>
  262. /// <param name="sender"></param>
  263. /// <param name="e"></param>
  264. private void F_PM_3602_FormClosed(object sender, FormClosedEventArgs e)
  265. {
  266. _instance = null;
  267. }
  268. /// <summary>
  269. /// 保存
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. private void btnSave_Click(object sender, EventArgs e)
  274. {
  275. try
  276. {
  277. //校验
  278. if (string.IsNullOrEmpty(this.txtRegisterNo.Text))
  279. {
  280. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "登记单号"),
  281. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  282. return;
  283. }
  284. if (string.IsNullOrWhiteSpace(this.cmbWORKSHOP.SelectedValue.ToString()))
  285. {
  286. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "车间"),
  287. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  288. return;
  289. }
  290. if (Convert.ToInt32(this.scbGoods.SearchedPKMember) == 0)
  291. {
  292. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品"),
  293. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  294. return;
  295. }
  296. if (string.IsNullOrEmpty(this.txtFIRQUANTITY.Text.ToString()))
  297. {
  298. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "检验数量"),
  299. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  300. return;
  301. }
  302. if (string.IsNullOrWhiteSpace(this.cmbFIRGOODSTYPE.SelectedValue.ToString()))
  303. {
  304. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品类型"),
  305. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  306. return;
  307. }
  308. if (string.IsNullOrWhiteSpace(this.cmbFIRBASIS.SelectedValue.ToString()))
  309. {
  310. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "检验依据"),
  311. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  312. return;
  313. }
  314. //保存
  315. ClientRequestEntity cre = new ClientRequestEntity();
  316. cre.NameSpace = "F_PM_3602";
  317. cre.Name = "SaveFirstRegister";
  318. cre.Properties["REGISTERNO"] = this.txtRegisterNo.Text;
  319. cre.Properties["WORKSHOP"] = Convert.ToInt32(this.cmbWORKSHOP.SelectedValue);
  320. cre.Properties["GOODSID"] = Convert.ToInt32(this.scbGoods.SearchedPKMember);
  321. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  322. cre.Properties["MATERIALCODE"] = this.txtMATERIALCODE.Text;
  323. cre.Properties["LOGOID"] = Convert.ToInt32(this.cmbLogo.SelectedValue);
  324. cre.Properties["FIRQUANTITY"] = Convert.ToInt32(this.txtFIRQUANTITY.Text);
  325. cre.Properties["FIRGOODSTYPE"] = Convert.ToInt32(this.cmbFIRGOODSTYPE.SelectedValue);
  326. cre.Properties["FIRBASIS"] = Convert.ToInt32(this.cmbFIRBASIS.SelectedValue);
  327. cre.Properties["REMARKS"] = this.txtremarks.Text;
  328. cre.Properties["BARCODES"] = this.txtBarcodes.Text;
  329. cre.Properties["ACCOUNTDATE"] = this.dtpACCOUNTDATE.Value;
  330. //判断新建、编辑
  331. //编辑
  332. dgvRegisterDetail.EndEdit();
  333. if (_registerID > 0 )
  334. {
  335. cre.Properties["REGISTERID"] = _registerID;
  336. if ( _barID > 0)
  337. {
  338. cre.Properties["BARID"] = _barID;
  339. if (dgvRegisterDetail.DataSource != null)
  340. {
  341. DataTable detail = (DataTable)(dgvRegisterDetail.DataSource);
  342. cre.Data = new DataSet();
  343. cre.Data.Tables.Add(detail.Copy());
  344. }
  345. }
  346. }
  347. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  348. {
  349. return PMModuleProxyNew.Service.HandleRequest(cre);
  350. });
  351. if (Convert.ToInt32(sre.Result) < 0)
  352. {
  353. MessageBox.Show(sre.Message,
  354. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  355. return;
  356. }
  357. else
  358. {
  359. // 提示信息
  360. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  361. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  362. this.btnSave.Visible = false;
  363. this.Close();
  364. }
  365. }
  366. catch (Exception ex)
  367. {
  368. this.btnSave.Enabled = true;
  369. // 对异常进行共通处理
  370. ExceptionManager.HandleEventException(this.ToString(),
  371. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  372. }
  373. }
  374. /// <summary>
  375. /// 商标变更事件
  376. /// </summary>
  377. /// <param name="sender"></param>
  378. /// <param name="e"></param>
  379. private void cmbLogo_SelectedValueChanged(object sender, EventArgs e)
  380. {
  381. try
  382. {
  383. if (Convert.ToInt32(this.cmbLogo.SelectedValue) > 0)
  384. {
  385. int logoid = Convert.ToInt32(this.cmbLogo.SelectedValue);
  386. ServiceResultEntity srematnr = DoAsync<ServiceResultEntity>(() =>
  387. {
  388. ClientRequestEntity cre = new ClientRequestEntity();
  389. cre.NameSpace = "F_PM_3602";
  390. cre.Name = "GetMatnr";
  391. cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
  392. cre.Properties["LOGOID"] = logoid;
  393. return PMModuleProxyNew.Service.HandleRequest(cre);
  394. });
  395. if (srematnr != null && srematnr.Data.Tables.Count > 0)
  396. {
  397. string txtmatnr = srematnr.Data.Tables[0].Rows[0]["MATERIALCODE"].ToString();
  398. this.txtMATERIALCODE.Text = txtmatnr;
  399. }
  400. }
  401. }
  402. catch (Exception ex)
  403. {
  404. throw ex;
  405. }
  406. }
  407. /// <summary>
  408. /// 产品选择
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. private void scbGoods_SearchedItemChanged_1(object sender, EventArgs e)
  413. {
  414. try
  415. {
  416. string goodscodevalue = scbGoods.SearchedValue.ToString();
  417. //产品编码赋值
  418. this.txtGoodsCode.Text = goodscodevalue;
  419. //查询产品商标
  420. //根据表中GOODSCODE去查找对应的商标
  421. ServiceResultEntity sreByid = DoAsync<ServiceResultEntity>(() =>
  422. {
  423. ClientRequestEntity cre = new ClientRequestEntity();
  424. cre.NameSpace = "F_PM_0102";
  425. cre.Name = "GetLogoInfoByLogoID";
  426. cre.Properties["GOODSCODE"] = "'" + goodscodevalue + "'";
  427. return SystemModuleProxy.Service.DoRequest(cre);
  428. });
  429. if (sreByid != null && sreByid.Data.Tables.Count > 0)
  430. {
  431. DataTable dataTable = sreByid.Data.Tables[0];
  432. this.cmbLogo.ValueMember = "LOGOID";
  433. this.cmbLogo.DisplayMember = "LOGONAME";
  434. this.cmbLogo.DataSource = dataTable;
  435. }
  436. }
  437. catch (Exception ex)
  438. {
  439. throw ex;
  440. }
  441. }
  442. #endregion
  443. }
  444. }