F_PM_1102.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1102.cs
  5. * 2.功能描述:新建/编辑产品废弃信息窗体
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/24 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.BaseResources;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.Library;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. /// <summary>
  24. /// 编辑产品废弃信息窗体
  25. /// </summary>
  26. public partial class F_PM_1102 : FormBase
  27. {
  28. #region 成员变量
  29. //窗体模式ID
  30. private Constant.FormMode _formType;
  31. //修改产品报损信息ID
  32. private string _barCode;
  33. //页面报损工序的数据源
  34. private List<ProductionDataEntity> _productionDataList = new List<ProductionDataEntity>();
  35. //该产品在产信息实体
  36. private InProductionEntity _isScrapProductEntity;
  37. //用户选择报损工序实体
  38. private ProductionDataEntity _scrapProductResponProcedure;
  39. //当前责任人集合
  40. private List<ScrapResponsibleEntity> _scrapResponsibleList = new List<ScrapResponsibleEntity>();
  41. //修改用废弃产品实体
  42. private ScrapProductEntity _updateEntity;
  43. //修改用废弃责任工序实体
  44. private ResponProcedureEntity _updateProcedureEntity;
  45. //修改用责任人集合
  46. private List<ScrapResponsibleEntity> _updateScrapResponsibleList;
  47. //有效条码标示
  48. private bool _yxBarCode = false;
  49. //产品分级类别ID
  50. private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
  51. //产品分级ID
  52. private int _goodsLevelId;
  53. //报损信息ID
  54. private int _editSPId;
  55. //是否允许审批
  56. private bool _isScrap = false;
  57. //未干补
  58. int SpecialRepairFlag = 0;
  59. //完成工序
  60. int? _CompleteProcdureID = null;
  61. //完成工序编码
  62. string _CompleteProcdureCode = "";
  63. //完成工序名称
  64. string _CompleteProcdureName = "";
  65. // 商标ID
  66. int? _LogoID = null;
  67. #endregion
  68. #region 构造函数
  69. /// <summary>
  70. /// 窗体构造
  71. /// </summary>
  72. public F_PM_1102(Constant.FormMode formType, string BarCode, int EditSPId, bool isScrap)
  73. {
  74. InitializeComponent();
  75. this._formType = formType;
  76. this._barCode = BarCode;
  77. this._editSPId = EditSPId;
  78. this._isScrap = isScrap;
  79. if (formType == Constant.FormMode.Add)
  80. {
  81. this.Text = FormTitles.F_PM_1102_ADD;
  82. }
  83. else
  84. {
  85. this.Text = FormTitles.F_PM_1102_EDIT;
  86. }
  87. this.btnViewApprover.Text = ButtonText.BTN_VIEWAPPROVER;
  88. this.btnSave.Text = ButtonText.BTN_SAVE;
  89. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  90. }
  91. #endregion
  92. #region 事件
  93. /// <summary>
  94. /// 窗体加载
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void F_PM_1102_Load(object sender, EventArgs e)
  99. {
  100. try
  101. {
  102. //获取当前产品分级ID
  103. this._goodsLevelId = Convert.ToInt32(SystemModuleProxy.Service.GetGoodsLevelDataById(_goodsLevelTypeID, null)
  104. .Tables[0].Rows[0]["GoodsLevelID"]);
  105. // 损坯原因
  106. DataSet dsRreason = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  107. {
  108. return SystemModuleProxy.Service.GetDictionaryData(0, "TPC008");
  109. }));
  110. this.cmbRreason.DisplayMember = "DictionaryValue";
  111. this.cmbRreason.ValueMember = "DictionaryID";
  112. this.cmbRreason.DataSource = dsRreason.Tables[0];
  113. //绑定损坯状态
  114. DataTable dtAuditStatus = new DataTable();
  115. dtAuditStatus.Columns.Add("AuditStatusID");
  116. dtAuditStatus.Columns.Add("AuditStatusValue");
  117. DataRow dr = dtAuditStatus.NewRow();
  118. dr["AuditStatusID"] = 0;
  119. dr["AuditStatusValue"] = "待审核";
  120. dtAuditStatus.Rows.Add(dr);
  121. if (this._isScrap)
  122. {
  123. dr = dtAuditStatus.NewRow();
  124. dr["AuditStatusID"] = 1;
  125. dr["AuditStatusValue"] = "损坯通过";
  126. dtAuditStatus.Rows.Add(dr);
  127. dr = dtAuditStatus.NewRow();
  128. dr["AuditStatusID"] = 2;
  129. dr["AuditStatusValue"] = "损坯驳回";
  130. dtAuditStatus.Rows.Add(dr);
  131. }
  132. this.cmbAuditStatus.DisplayMember = "AuditStatusValue";
  133. this.cmbAuditStatus.ValueMember = "AuditStatusID";
  134. this.cmbAuditStatus.DataSource = dtAuditStatus;
  135. if (this._formType == Constant.FormMode.Edit)
  136. {
  137. BindEntity();
  138. }
  139. }
  140. catch (Exception ex)
  141. {
  142. // 对异常进行共通处理
  143. ExceptionManager.HandleEventException(this.ToString(),
  144. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  145. }
  146. }
  147. /// <summary>
  148. /// 提交操作
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void btnSave_Click(object sender, EventArgs e)
  153. {
  154. try
  155. {
  156. if (this.txtBarCode.Text == string.Empty)
  157. {
  158. this.txtBarCode.Focus();
  159. return;
  160. }
  161. if (this.cmbRreason.Text == string.Empty)
  162. {
  163. MessageBox.Show("损坯原因必须填写!",
  164. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  165. return;
  166. }
  167. this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
  168. if (this._formType == Constant.FormMode.Add)
  169. {
  170. if (this._yxBarCode != true)
  171. {
  172. MessageBox.Show("请先输入一个有效条码!!",
  173. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  174. this.txtBarCode.Focus();
  175. return;
  176. }
  177. ScrapProductEntity addScrapProduct = null;
  178. ResponProcedureEntity addRProcedure = null;
  179. //获取责任人集合
  180. List<ScrapResponsibleEntity> addResponsibleList = new List<ScrapResponsibleEntity>();
  181. foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
  182. {
  183. int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
  184. if (isSelected == Constant.INT_IS_ONE)
  185. {
  186. ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
  187. selectResponsible.BarCode = this.txtBarCode.Text;
  188. selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
  189. selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
  190. selectResponsible.UserID = scbUser.SearchedPKMember;
  191. selectResponsible.UserCode = scbUser.SearchedValue + "";
  192. selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
  193. selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
  194. addResponsibleList.Add(selectResponsible);
  195. }
  196. }
  197. //如果选择了责任工序就一定要选择责任人
  198. //if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
  199. if (addResponsibleList.Count == Constant.INT_IS_ZERO)
  200. {
  201. MessageBox.Show("请选择责任人!",
  202. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  203. return;
  204. }
  205. //首先判断责任类型
  206. int thisResponType = 0;
  207. if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
  208. {
  209. thisResponType = 1;
  210. }
  211. else if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
  212. {
  213. thisResponType = 3;
  214. }
  215. else if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
  216. {
  217. thisResponType = 2;
  218. }
  219. if (thisResponType == Constant.INT_IS_ZERO)
  220. {
  221. MessageBox.Show("责任类别不正确!",
  222. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  223. return;
  224. }
  225. //新建报损产品实体
  226. addScrapProduct = new ScrapProductEntity();
  227. addScrapProduct.BarCode = this.txtBarCode.Text;
  228. addScrapProduct.ProductionLineID = _isScrapProductEntity.ProductionLineID;
  229. addScrapProduct.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
  230. addScrapProduct.ProductionLineName = _isScrapProductEntity.ProductionLineName;
  231. addScrapProduct.GoodsID = _isScrapProductEntity.GoodsID;
  232. addScrapProduct.GoodsCode = _isScrapProductEntity.GoodsCode;
  233. addScrapProduct.GoodsName = _isScrapProductEntity.GoodsName;
  234. addScrapProduct.GroutingDailyID = _isScrapProductEntity.GroutingDailyID;
  235. addScrapProduct.GroutingDailyDetailID = _isScrapProductEntity.GroutingDailyDetailID;
  236. addScrapProduct.GroutingDate = Convert.ToDateTime(_isScrapProductEntity.GroutingDate);
  237. addScrapProduct.GroutingLineID = _isScrapProductEntity.GroutingLineID;
  238. addScrapProduct.GroutingLineCode = _isScrapProductEntity.GroutingLineCode;
  239. addScrapProduct.GroutingLineName = _isScrapProductEntity.GroutingLineName;
  240. addScrapProduct.GMouldTypeID = _isScrapProductEntity.GMouldTypeID;
  241. addScrapProduct.GroutingLineDetailID = _isScrapProductEntity.GroutingLineDetailID;
  242. addScrapProduct.GroutingMouldCode = _isScrapProductEntity.GroutingMouldCode;
  243. addScrapProduct.MouldCode = _isScrapProductEntity.MouldCode;
  244. addScrapProduct.GoodsLevelTypeID = _goodsLevelTypeID;
  245. addScrapProduct.GoodsLevelID = _goodsLevelId;
  246. addScrapProduct.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
  247. addScrapProduct.Rreason = this.cmbRreason.Text;
  248. addScrapProduct.ResponUserID = scbUser.SearchedPKMember;
  249. addScrapProduct.ResponUserCode = scbUser.SearchedValue + "";
  250. addScrapProduct.ResponUserName = scbUser.Text;
  251. addScrapProduct.Remarks = this.txtRemarks.Text;
  252. addScrapProduct.AuditStatus = 0;
  253. addScrapProduct.SettlementFlag = 0;
  254. addScrapProduct.ResponType = thisResponType;
  255. addScrapProduct.GroutingUserID = Convert.ToInt32(_isScrapProductEntity.GroutingUserID);
  256. addScrapProduct.GroutingUserCode = _isScrapProductEntity.GroutingUserCode;
  257. addScrapProduct.GroutingNum = _isScrapProductEntity.GroutingNum;
  258. addScrapProduct.IsPublicBody = Convert.ToInt32(_isScrapProductEntity.IsPublicBody);
  259. addScrapProduct.IsReFire = Convert.ToInt32(_isScrapProductEntity.IsReFire);
  260. addScrapProduct.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
  261. addScrapProduct.SpecialRepairflag = this.SpecialRepairFlag;
  262. addScrapProduct.LogoID = this._LogoID;
  263. if (this._CompleteProcdureID != null)
  264. {
  265. addScrapProduct.ProcedureID = this._CompleteProcdureID;
  266. //addScrapProduct.ProcedureName = this.txtCompleteProcdure.Text;
  267. addScrapProduct.ProcedureName = this._CompleteProcdureName;
  268. addScrapProduct.ProcedureCode = this._CompleteProcdureCode;
  269. }
  270. if (txtScrapFine.Text != string.Empty)
  271. {
  272. addScrapProduct.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
  273. }
  274. //如果存在责任工序的话,也要添加责任工序
  275. if (thisResponType == Constant.INT_IS_THREE)
  276. {
  277. addRProcedure = new ResponProcedureEntity();
  278. addRProcedure.BarCode = this.txtBarCode.Text;
  279. addRProcedure.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
  280. addRProcedure.ProductionLineID = _isScrapProductEntity.ProductionLineID;
  281. addRProcedure.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
  282. addRProcedure.ProductionLineName = _isScrapProductEntity.ProductionLineName;
  283. addRProcedure.ProcedureID = _scrapProductResponProcedure.ProcedureID;
  284. addRProcedure.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
  285. addRProcedure.ProcedureName = _scrapProductResponProcedure.ProcedureName;
  286. addRProcedure.UserID = scbUser.SearchedPKMember;
  287. addRProcedure.UserCode = scbUser.SearchedValue + "";
  288. addRProcedure.UserName = scbUser.Text;
  289. addRProcedure.Remarks = "";
  290. }
  291. int addReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  292. {
  293. return PMModuleProxy.Service.AddScrapProduct(addScrapProduct, addRProcedure, addResponsibleList);
  294. }));
  295. if (addReturn > Constant.INT_IS_ZERO)
  296. {
  297. //成功
  298. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
  299. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  300. this.DialogResult = DialogResult.OK;
  301. }
  302. else if (addReturn == Constant.RETURN_IS_DATACHANGED)
  303. {
  304. //成功
  305. MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化"),
  306. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  307. this.DialogResult = DialogResult.OK;
  308. }
  309. else
  310. {
  311. //失败
  312. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
  313. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  314. }
  315. }
  316. else
  317. {
  318. //获取修改后的责任人集合
  319. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  320. foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
  321. {
  322. int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
  323. if (isSelected == Constant.INT_IS_ONE)
  324. {
  325. ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
  326. selectResponsible.BarCode = this.txtBarCode.Text;
  327. selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
  328. selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
  329. selectResponsible.UserID = scbUser.SearchedPKMember;
  330. selectResponsible.UserCode = scbUser.SearchedValue + "";
  331. selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
  332. selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
  333. this._updateScrapResponsibleList.Add(selectResponsible);
  334. }
  335. }
  336. //如果选择了责任工序就一定要选择责任人
  337. //if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  338. if (_updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  339. {
  340. MessageBox.Show("请选择责任人!",
  341. this.Text,
  342. MessageBoxButtons.OK,
  343. MessageBoxIcon.Warning,
  344. MessageBoxDefaultButton.Button1);
  345. return;
  346. }
  347. //根据修改信息判断新的责任类型
  348. int thisResponType = 0;
  349. if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
  350. {
  351. thisResponType = 1;
  352. }
  353. else if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
  354. {
  355. thisResponType = 3;
  356. }
  357. else if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
  358. {
  359. thisResponType = 2;
  360. }
  361. if (thisResponType == Constant.INT_IS_ZERO)
  362. {
  363. MessageBox.Show("责任类别不正确!",
  364. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  365. return;
  366. }
  367. //为修改实体赋值(可修改的只有备注,原因,责任工序,以及责任人)
  368. this._updateEntity.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
  369. this._updateEntity.Rreason = this.cmbRreason.Text;
  370. this._updateEntity.Remarks = this.txtRemarks.Text;
  371. this._updateEntity.ResponType = thisResponType;
  372. this._updateEntity.LogoID = this._LogoID;
  373. if (txtScrapFine.Text != string.Empty)
  374. {
  375. this._updateEntity.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
  376. }
  377. //新添审批状态判断,如果审批状态为未通过审批,要修改为未审批
  378. //if (this._updateEntity.AuditStatus != null)
  379. //{
  380. // if (this._updateEntity.AuditStatus == Constant.INT_IS_TWO)
  381. // {
  382. // this._updateEntity.AuditStatus = 0;
  383. // }
  384. //}
  385. this._updateEntity.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
  386. //如果存在责任工序的话,也要添加责任工序
  387. if (thisResponType == Constant.INT_IS_THREE)
  388. {
  389. if (this._updateProcedureEntity == null)
  390. {
  391. this._updateProcedureEntity = new ResponProcedureEntity();
  392. }
  393. this._updateProcedureEntity.BarCode = this.txtBarCode.Text;
  394. this._updateProcedureEntity.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
  395. this._updateProcedureEntity.ProductionLineID = _updateEntity.ProductionLineID;
  396. this._updateProcedureEntity.ProductionLineCode = _updateEntity.ProductionLineCode;
  397. this._updateProcedureEntity.ProductionLineName = _updateEntity.ProductionLineName;
  398. this._updateProcedureEntity.ProcedureID = _scrapProductResponProcedure.ProcedureID;
  399. this._updateProcedureEntity.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
  400. this._updateProcedureEntity.ProcedureName = _scrapProductResponProcedure.ProcedureName;
  401. this._updateProcedureEntity.UserID = scbUser.SearchedPKMember;
  402. this._updateProcedureEntity.UserCode = scbUser.SearchedValue + "";
  403. this._updateProcedureEntity.UserName = scbUser.Text;
  404. }
  405. else //不存在了直接把原来的删掉
  406. {
  407. if (this._updateProcedureEntity != null)
  408. {
  409. this._updateProcedureEntity.ValueFlag = 0;
  410. }
  411. }
  412. int updateReturn = (int)DoAsync(new BaseAsyncMethod(() =>
  413. {
  414. return PMModuleProxy.Service.UpdateScrapProduct(_updateEntity, _updateProcedureEntity, _updateScrapResponsibleList, _scrapResponsibleList);
  415. }));
  416. if (updateReturn > Constant.INT_IS_ZERO)
  417. {
  418. //成功
  419. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
  420. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  421. this.DialogResult = DialogResult.OK;
  422. }
  423. else
  424. {
  425. //失败
  426. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
  427. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  428. }
  429. }
  430. }
  431. catch (Exception ex)
  432. {
  433. // 对异常进行共通处理
  434. ExceptionManager.HandleEventException(this.ToString(),
  435. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  436. }
  437. }
  438. /// <summary>
  439. /// 察看审批意见
  440. /// </summary>
  441. /// <param name="sender"></param>
  442. /// <param name="e"></param>
  443. private void btnViewApprover_Click(object sender, EventArgs e)
  444. {
  445. try
  446. {
  447. string barCode = this.txtBarCode.Text;
  448. F_PM_1103 frmFPM1103 = new F_PM_1103(barCode, 1, _editSPId);
  449. DialogResult dialogresult = frmFPM1103.ShowDialog();
  450. }
  451. catch (Exception ex)
  452. {
  453. // 对异常进行共通处理
  454. ExceptionManager.HandleEventException(this.ToString(),
  455. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  456. }
  457. }
  458. /// <summary>
  459. /// 选择工号改变
  460. /// </summary>
  461. /// <param name="sender"></param>
  462. /// <param name="e"></param>
  463. private void scbUser_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
  464. {
  465. try
  466. {
  467. if (this.scbUser.SearchedPKMember != 0)
  468. {
  469. if (this.scbUser.Text != "")
  470. {
  471. this.dgvResponsible.AutoGenerateColumns = false;
  472. DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  473. {
  474. return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
  475. }));
  476. this.dgvResponsible.DataSource = dsUser.Tables[0];
  477. }
  478. else
  479. {
  480. this.dgvResponsible.DataSource = null;
  481. this.scbUser.ClearValue();
  482. }
  483. }
  484. else
  485. {
  486. this.dgvResponsible.DataSource = null;
  487. }
  488. if (this._formType == Constant.FormMode.Edit)
  489. {
  490. if (this.dgvResponsible.DataSource != null)
  491. {
  492. if (_scrapResponsibleList.Count != 0)
  493. {
  494. foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
  495. {
  496. string sourseNow = drNow.Cells["StaffID"].Value.ToString();
  497. foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
  498. {
  499. if (srFor.StaffID.ToString() == sourseNow)
  500. {
  501. drNow.Cells["UserSelected"].Value = "1";
  502. break;
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. catch (Exception ex)
  511. {
  512. // 对异常进行共通处理
  513. ExceptionManager.HandleEventException(this.ToString(),
  514. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  515. }
  516. }
  517. /// <summary>
  518. /// 选择工号改变
  519. /// </summary>
  520. /// <param name="sender"></param>
  521. /// <param name="e"></param>
  522. private void dkUser_UserValueChanged(object sender, Controls.SearchTextBox.dkUserInfoSearchBox.TextChangeEventArgs e)
  523. {
  524. // try
  525. // {
  526. // if (this.scbUser.SearchedPKMember != 0)
  527. // {
  528. // if (this.scbUser.Text != "")
  529. // {
  530. // this.dgvResponsible.AutoGenerateColumns = false;
  531. // DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  532. // {
  533. // return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
  534. // }));
  535. // this.dgvResponsible.DataSource = dsUser.Tables[0];
  536. // }
  537. // else
  538. // {
  539. // this.dgvResponsible.DataSource = null;
  540. // this.scbUser.ClearValue();
  541. //}
  542. // }
  543. // else
  544. // {
  545. // this.dgvResponsible.DataSource = null;
  546. // }
  547. // if (this._formType == Constant.FormMode.Edit)
  548. // {
  549. // if (this.dgvResponsible.DataSource != null)
  550. // {
  551. // if (_scrapResponsibleList.Count != 0)
  552. // {
  553. // foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
  554. // {
  555. // string sourseNow = drNow.Cells["StaffID"].Value.ToString();
  556. // foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
  557. // {
  558. // if (srFor.StaffID.ToString() == sourseNow)
  559. // {
  560. // drNow.Cells["UserSelected"].Value = "1";
  561. // break;
  562. // }
  563. // }
  564. // }
  565. // }
  566. // }
  567. // }
  568. // }
  569. // catch (Exception ex)
  570. // {
  571. // // 对异常进行共通处理
  572. // ExceptionManager.HandleEventException(this.ToString(),
  573. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  574. // }
  575. }
  576. /// <summary>
  577. /// 窗体关闭
  578. /// </summary>
  579. /// <param name="sender"></param>
  580. /// <param name="e"></param>
  581. private void btnCancel_Click(object sender, EventArgs e)
  582. {
  583. this.Close();
  584. }
  585. /// <summary>
  586. /// 条码输入完毕后
  587. /// </summary>
  588. /// <param name="sender"></param>
  589. /// <param name="e"></param>
  590. private void txtBarCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  591. {
  592. try
  593. {
  594. string BarCode = this.txtBarCode.Text.Trim();
  595. if (BarCode != string.Empty)
  596. {
  597. string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
  598. {
  599. return PMModuleProxy.Service.ScrapProductChack(BarCode);
  600. }));
  601. string[] doRuselts = doRuselt.Split(':');
  602. int isHave = Convert.ToInt32(doRuselts[0]);
  603. if (isHave == 2)
  604. {
  605. MessageBox.Show("不是在产产品不能报损!",
  606. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  607. this.txtBarCode.Text = "";
  608. this.txtBarCode.Focus();
  609. return;
  610. }
  611. if (isHave == 3)
  612. {
  613. MessageBox.Show(string.Format("当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
  614. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  615. this.txtBarCode.Text = "";
  616. this.txtBarCode.Focus();
  617. return;
  618. }
  619. if (isHave == 4)
  620. {
  621. MessageBox.Show(doRuselts[1],
  622. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  623. this.txtBarCode.Text = "";
  624. this.txtBarCode.Focus();
  625. return;
  626. }
  627. if (isHave == Constant.INT_IS_ZERO)
  628. {
  629. MessageBox.Show("该产品已经存在报损记录!",
  630. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  631. this.txtBarCode.Text = "";
  632. this.txtBarCode.Focus();
  633. return;
  634. }
  635. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  636. {
  637. return PMModuleProxy.Service.GetInProductionAndProductionData(BarCode);
  638. }));
  639. if (dsReturn != null)
  640. {
  641. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  642. {
  643. if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO) //在产表中没有数据
  644. {
  645. //目前不在生产线上也只报损 2015/07/14 modify wangx
  646. DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  647. {
  648. return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(BarCode);
  649. }));
  650. if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
  651. {
  652. MessageBox.Show("该产品条码无效,无法报损!",
  653. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  654. this.txtBarCode.Text = "";
  655. this.txtBarCode.Focus();
  656. return;
  657. }
  658. //SpecialRepairFlag = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["SpecialRepairFlag"]);
  659. //this.txtProductionLineName.Text = "";
  660. //this.txtGoodsCode.Text = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
  661. //this.txtGroutingLine.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  662. //this.txtMouldCode.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  663. //this.txtGroutingUser.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  664. //this.cbResponProcedure.Enabled = false;
  665. ////this._isScrapProductEntity.ProductionLineID = 0;//放null
  666. ////this._isScrapProductEntity.ProductionLineCode = null;
  667. ////this._isScrapProductEntity.ProductionLineName = null;
  668. //this._isScrapProductEntity = new InProductionEntity();
  669. //this._isScrapProductEntity.GoodsID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GoodsID"]);
  670. //this._isScrapProductEntity.GoodsCode = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
  671. //this._isScrapProductEntity.GoodsName = dsDailyDetail.Tables[0].Rows[0]["GoodsName"].ToString();
  672. //this._isScrapProductEntity.GroutingDailyID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyID"]);
  673. //this._isScrapProductEntity.GroutingDailyDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyDetailID"]);
  674. //this._isScrapProductEntity.GroutingDate = Convert.ToDateTime(dsDailyDetail.Tables[0].Rows[0]["GroutingDate"]);
  675. //this._isScrapProductEntity.GroutingLineID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineID"]);
  676. //this._isScrapProductEntity.GroutingLineCode = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
  677. //this._isScrapProductEntity.GroutingLineName = dsDailyDetail.Tables[0].Rows[0]["GroutingLineName"].ToString();
  678. //this._isScrapProductEntity.GMouldTypeID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GMouldTypeID"]);
  679. //this._isScrapProductEntity.GroutingLineDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineDetailID"]);
  680. //this._isScrapProductEntity.GroutingMouldCode = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
  681. //this._isScrapProductEntity.MouldCode = dsDailyDetail.Tables[0].Rows[0]["MouldCode"].ToString();
  682. //this._isScrapProductEntity.GroutingUserID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingUserID"]);
  683. //this._isScrapProductEntity.GroutingUserCode = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
  684. //this._isScrapProductEntity.GroutingNum = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingNum"]);
  685. //this._isScrapProductEntity.IsPublicBody = 0;
  686. //this._isScrapProductEntity.IsReFire = 0;
  687. //this._yxBarCode = true;
  688. //this.txtBarCode.Enabled = false;
  689. // 2015/07/14 modify wangx end
  690. ////产品不在生产线上
  691. MessageBox.Show("不是在产产品不能报损!",
  692. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  693. this.txtBarCode.Text = "";
  694. this.txtBarCode.Focus();
  695. ////判断条码是否有效
  696. return; //加这个返回代码为了如果在注浆登记中,赋完值后直接返回,为了保存时候取值
  697. }
  698. //获取产品情况以及经过工序情况
  699. DataTable dtInProduction = dsReturn.Tables[0];
  700. //2015-05-26 begin modify by wangx
  701. if (dtInProduction != null && dtInProduction.Rows.Count > 0)
  702. {
  703. if (dtInProduction.Rows[0]["endmode"].ToString() == "2")//代表已经产成品
  704. {
  705. MessageBox.Show("该产品条码已经生产完成,无法报损!",
  706. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  707. this.txtBarCode.Text = "";
  708. this.txtBarCode.Focus();
  709. return;
  710. }
  711. if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
  712. {
  713. MessageBox.Show("该产品条码已经是返工状态,无法报损!",
  714. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  715. this.txtBarCode.Text = "";
  716. this.txtBarCode.Focus();
  717. return;
  718. }
  719. }
  720. //2015-05-26 end
  721. //获取节点类型
  722. //如果存在该类型的字段的话,判断一下
  723. // string a = dtInProduction.Columns[dtInProduction.Columns.Count - 1].ColumnName;
  724. foreach (DataColumn dcFor in dtInProduction.Columns)
  725. {
  726. if (dcFor.ColumnName.ToLower() == "proceduremodeltypeid")
  727. {
  728. int modelType = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureModelTypeID"]);
  729. // 装车,入窑,出窑,窑车补件不能报损
  730. if (modelType == Constant.INT_IS_ONE || modelType == Constant.INT_IS_TWO || modelType == Constant.INT_IS_THREE || modelType == Constant.INT_IS_SIX)
  731. {
  732. //某些特殊工序不可报损
  733. MessageBox.Show("该产品处于无法报损的特殊工序中!",
  734. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  735. this.txtBarCode.Text = "";
  736. this.txtBarCode.Focus();
  737. return;
  738. }
  739. }
  740. }
  741. DataTable dtProductionData = dsReturn.Tables[1];
  742. foreach (DataRow drFor in dtInProduction.Rows)
  743. {
  744. SpecialRepairFlag = Convert.ToInt32(drFor["SpecialRepairFlag"]);
  745. this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  746. this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  747. this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  748. this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  749. this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  750. if (drFor["logoID"].ToString() != "")
  751. {
  752. this._LogoID = Convert.ToInt32(drFor["logoID"]);
  753. }
  754. }
  755. this.cbResponProcedure.DataSource = dtProductionData;
  756. this.cbResponProcedure.ValueMember = "ProcedureID";
  757. this.cbResponProcedure.DisplayMember = "ProcedureName";
  758. this.cbResponProcedure.Text = "";
  759. List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
  760. if (inProductionList.Count != Constant.INT_IS_ZERO)
  761. {
  762. this._isScrapProductEntity = inProductionList[0];
  763. }
  764. else
  765. {
  766. if (this._updateEntity == null)
  767. {
  768. return;
  769. }
  770. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  771. {
  772. return;
  773. }
  774. //失败,条码不存在数据或无法转换
  775. MessageBox.Show(Messages.MSG_PM_W007,
  776. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  777. return;
  778. }
  779. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  780. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  781. {
  782. this._scrapProductResponProcedure = this._productionDataList[0];
  783. }
  784. this._yxBarCode = true;
  785. this.txtBarCode.Enabled = false;
  786. if (dtProductionData != null && dtProductionData.Rows.Count > 0)
  787. {
  788. this.cbResponProcedure.SelectedValue = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"];
  789. //this.cbResponProcedure.Enabled = false;
  790. // modify wangx 2015/06/06 begin
  791. this._CompleteProcdureID = Convert.ToInt32(dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"]);
  792. this.txtCompleteProcdure.Text = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
  793. _CompleteProcdureName = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
  794. this._CompleteProcdureCode = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureCode"].ToString();
  795. // modify wangx 2015/06/06 end
  796. cbResponProcedure_SelectedIndexChanged(sender, e);
  797. }
  798. else
  799. {
  800. this._CompleteProcdureID = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureID"]);
  801. _CompleteProcdureName = dtInProduction.Rows[0]["ProcedureName"].ToString();
  802. this._CompleteProcdureCode = dtInProduction.Rows[0]["ProcedureCode"].ToString();
  803. }
  804. }
  805. }
  806. else
  807. {
  808. if (this._updateEntity == null)
  809. {
  810. return;
  811. }
  812. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
  813. {
  814. return;
  815. }
  816. //失败
  817. MessageBox.Show(Messages.MSG_PM_W007,
  818. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  819. }
  820. }
  821. }
  822. catch (Exception ex)
  823. {
  824. // 对异常进行共通处理
  825. ExceptionManager.HandleEventException(this.ToString(),
  826. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  827. }
  828. }
  829. /// <summary>
  830. /// 将用户选择的工序实体赋值
  831. /// </summary>
  832. /// <param name="sender"></param>
  833. /// <param name="e"></param>
  834. private void cbResponProcedure_SelectedIndexChanged(object sender, EventArgs e)
  835. {
  836. try
  837. {
  838. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  839. {
  840. if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
  841. {
  842. this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
  843. DataTable dt = this.cbResponProcedure.DataSource as DataTable;
  844. int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
  845. DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  846. {
  847. return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
  848. }));
  849. if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
  850. && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  851. {
  852. this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  853. scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
  854. //this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
  855. //this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
  856. this.cbResponProcedure.DataSource = dt;
  857. this.cbResponProcedure.Enabled = true;
  858. //this.dkUser.ReadOnly = true;
  859. this.scbUser.Enabled = false;
  860. }
  861. else
  862. {
  863. this.scbUser.Enabled = true;
  864. this.scbUser.SearchedPKMember = 0;
  865. this.scbUser.ClearValue();
  866. }
  867. }
  868. else
  869. {
  870. this._scrapProductResponProcedure = null;
  871. }
  872. }
  873. }
  874. catch (Exception ex)
  875. {
  876. // 对异常进行共通处理
  877. ExceptionManager.HandleEventException(this.ToString(),
  878. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  879. }
  880. }
  881. private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
  882. {
  883. try
  884. {
  885. if ((int)e.KeyChar == 13) // 按了回车键
  886. {
  887. this.cbResponProcedure.Focus();
  888. }
  889. }
  890. catch (Exception ex)
  891. {
  892. // 对异常进行共通处理
  893. ExceptionManager.HandleEventException(this.ToString(),
  894. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  895. }
  896. }
  897. #endregion
  898. #region 私有方法
  899. /// <summary>
  900. /// 加载数据
  901. /// </summary>
  902. private void BindEntity()
  903. {
  904. try
  905. {
  906. //条码控件不可用
  907. this.txtBarCode.Enabled = false;
  908. this._updateEntity = new ScrapProductEntity();
  909. this._updateEntity.BarCode = _barCode;
  910. this._updateEntity.ScrapProductID = _editSPId;
  911. //绑定生产工序集合
  912. DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  913. {
  914. return PMModuleProxy.Service.GetInProductionAndProductionData(_barCode);
  915. }));
  916. if (dsReturn != null)
  917. {
  918. if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
  919. {
  920. //获取产品情况以及经过工序情况
  921. DataTable dtInProduction = dsReturn.Tables[0];
  922. DataTable dtProductionData = dsReturn.Tables[1];
  923. foreach (DataRow drFor in dtInProduction.Rows)
  924. {
  925. this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
  926. this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
  927. this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
  928. this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
  929. this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
  930. }
  931. this.cbResponProcedure.DataSource = dtProductionData;
  932. this.cbResponProcedure.DisplayMember = "ProcedureName";
  933. this.cbResponProcedure.ValueMember = "ProcedureID";
  934. this._productionDataList = DataTableToListByProductionData(dtProductionData);
  935. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  936. {
  937. this._scrapProductResponProcedure = this._productionDataList[0];
  938. }
  939. if (dtInProduction.Rows.Count == 0)
  940. {
  941. this.cbResponProcedure.Enabled = false;
  942. }
  943. }
  944. }
  945. //获取报废产品实体
  946. DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  947. {
  948. return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
  949. }));
  950. if (dsScrap != null)
  951. {
  952. if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
  953. {
  954. DataRow drScrap = dsScrap.Tables[0].Rows[0];
  955. this._updateEntity.BarCode = drScrap["BarCode"].ToString();
  956. if (drScrap["ProductionLineID"].ToString() != "")
  957. {
  958. this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
  959. this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
  960. this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
  961. this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  962. this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  963. this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  964. this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  965. this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
  966. this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
  967. this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
  968. }
  969. else //等于空时,取模具信息
  970. {
  971. this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
  972. this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
  973. this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
  974. this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
  975. }
  976. if (drScrap["logoid"].ToString() != "")
  977. {
  978. this._LogoID = Convert.ToInt32(drScrap["logoid"]);
  979. }
  980. this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
  981. this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
  982. this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
  983. this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
  984. this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
  985. this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
  986. this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
  987. this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
  988. this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
  989. this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
  990. this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
  991. this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
  992. this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
  993. this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
  994. this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
  995. this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
  996. this._updateEntity.Rreason = drScrap["Rreason"].ToString();
  997. this._updateEntity.Remarks = drScrap["Remarks"].ToString();
  998. this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
  999. this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
  1000. this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  1001. this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
  1002. if (drScrap["Auditor"] != DBNull.Value)
  1003. {
  1004. this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
  1005. }
  1006. if (drScrap["AuditDate"] != DBNull.Value)
  1007. {
  1008. this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
  1009. }
  1010. this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
  1011. if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
  1012. {
  1013. this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
  1014. }
  1015. if (drScrap["UserID"] != DBNull.Value)
  1016. {
  1017. this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
  1018. }
  1019. if (drScrap["UserCode"] != DBNull.Value)
  1020. {
  1021. this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
  1022. }
  1023. if (drScrap["UserName"] != DBNull.Value)
  1024. {
  1025. this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
  1026. }
  1027. if (drScrap["ScrapFine"] != DBNull.Value)
  1028. {
  1029. this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
  1030. }
  1031. this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
  1032. if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
  1033. (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
  1034. {
  1035. this.txtBarCode.Enabled = false;
  1036. this.txtGoodsCode.Enabled = false;
  1037. this.txtProductionLineName.Enabled = false;
  1038. this.cbResponProcedure.Enabled = false;
  1039. // 报损日期不能修改
  1040. //this.txtScrapDate.Enabled = false;
  1041. this.cmbRreason.Enabled = false;
  1042. this.txtRemarks.Enabled = false;
  1043. this.scbUser.Enabled = false;
  1044. this.dgvResponsible.Enabled = false;
  1045. this.btnSave.Enabled = false;
  1046. this.btnViewApprover.Visible = false;
  1047. this.cmbAuditStatus.Enabled = false;
  1048. }
  1049. if (this._updateEntity.Auditor != null && this._updateEntity.GoodsLevelTypeID == this._goodsLevelTypeID)
  1050. {
  1051. this.btnViewApprover.Visible = true;
  1052. }
  1053. }
  1054. }
  1055. else
  1056. {
  1057. this.Close();
  1058. return;
  1059. }
  1060. //获取报废责任工序实体
  1061. if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
  1062. {
  1063. DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1064. {
  1065. return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1066. }));
  1067. this._updateProcedureEntity = new ResponProcedureEntity();
  1068. if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
  1069. {
  1070. DataRow drResPro = dsResPro.Tables[0].Rows[0];
  1071. this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
  1072. this.scbUser.Enabled = false;
  1073. }
  1074. this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
  1075. }
  1076. //获取报废责任人实体集合
  1077. if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
  1078. {
  1079. this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
  1080. DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1081. {
  1082. return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
  1083. }));
  1084. DataTableToListByScrapResponsible(dsResponsible);
  1085. }
  1086. //控件赋值
  1087. this.txtBarCode.Text = _updateEntity.BarCode;
  1088. this.txtGoodsCode.Text = _updateEntity.GoodsCode;
  1089. this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
  1090. this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
  1091. this.txtScrapDate.Text = _updateEntity.ScrapDate.ToString();
  1092. try
  1093. {
  1094. this.cmbRreason.Text = _updateEntity.Rreason;
  1095. }
  1096. catch
  1097. {
  1098. this.cmbRreason.Text = "";
  1099. }
  1100. this.txtRemarks.Text = _updateEntity.Remarks;
  1101. this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
  1102. //this._updateEntity.ScrapFine
  1103. if (this._updateEntity.ResponUserID != null)
  1104. {
  1105. scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
  1106. scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
  1107. //this.dkUser.UserID = _updateEntity.ResponUserID;
  1108. // this.dkUser.UserCode = _updateEntity.ResponUserCode;
  1109. // this.dkUser.UserName = _updateEntity.ResponUserName;
  1110. }
  1111. else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
  1112. {
  1113. scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
  1114. scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
  1115. //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
  1116. // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
  1117. // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
  1118. }
  1119. }
  1120. catch (Exception ex)
  1121. {
  1122. throw ex;
  1123. }
  1124. }
  1125. /// <summary>
  1126. /// 数据表到实体转换
  1127. /// </summary>
  1128. /// <param name="dsScrapResponsible"></param>
  1129. private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
  1130. {
  1131. foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
  1132. {
  1133. ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
  1134. srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
  1135. srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
  1136. srEntity.BarCode = drFor["BarCode"].ToString();
  1137. srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
  1138. if (drFor["ResponProcedureID"] != DBNull.Value)
  1139. {
  1140. srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
  1141. }
  1142. srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
  1143. srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
  1144. srEntity.UserCode = drFor["UserCode"].ToString();
  1145. srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
  1146. srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
  1147. srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
  1148. srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
  1149. srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
  1150. srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
  1151. srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
  1152. srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
  1153. srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
  1154. srEntity.UserName = drFor["userName"].ToString();
  1155. this._scrapResponsibleList.Add(srEntity);
  1156. }
  1157. }
  1158. /// <summary>
  1159. /// 数据表到实体转换
  1160. /// </summary>
  1161. /// <param name="dtProductionData"></param>
  1162. /// <returns></returns>
  1163. private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
  1164. {
  1165. List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
  1166. foreach (DataRow drFor in dtProductionData.Rows)
  1167. {
  1168. ProductionDataEntity pdEntity = new ProductionDataEntity();
  1169. pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
  1170. pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
  1171. pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
  1172. pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
  1173. pdList.Add(pdEntity);
  1174. }
  1175. return pdList;
  1176. }
  1177. #endregion
  1178. private void cbResponProcedure_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  1179. {
  1180. try
  1181. {
  1182. if (this._productionDataList.Count != Constant.INT_IS_ZERO)
  1183. {
  1184. if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
  1185. {
  1186. this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
  1187. DataTable dt = this.cbResponProcedure.DataSource as DataTable;
  1188. int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
  1189. DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  1190. {
  1191. return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
  1192. }));
  1193. if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
  1194. && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
  1195. {
  1196. this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  1197. scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
  1198. //this.dkUser.UserID = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
  1199. // this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
  1200. // this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
  1201. this.cbResponProcedure.DataSource = dt;
  1202. this.cbResponProcedure.Enabled = true;
  1203. this.scbUser.Enabled = false; ;
  1204. }
  1205. else
  1206. {
  1207. this.scbUser.Enabled = true;
  1208. this.scbUser.SearchedPKMember = 0;
  1209. this.scbUser.ClearValue();
  1210. }
  1211. }
  1212. else
  1213. {
  1214. this._scrapProductResponProcedure = null;
  1215. this.scbUser.Enabled = true;
  1216. }
  1217. }
  1218. }
  1219. catch (Exception ex)
  1220. {
  1221. // 对异常进行共通处理
  1222. ExceptionManager.HandleEventException(this.ToString(),
  1223. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1224. }
  1225. }
  1226. }
  1227. }