F_PM_1102.cs 51 KB

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