| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_1102.cs
- * 2.功能描述:新建/编辑产品废弃信息窗体
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/09/24 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 编辑产品废弃信息窗体
- /// </summary>
- public partial class F_PM_1102 : FormBase
- {
- #region 成员变量
- //窗体模式ID
- private Constant.FormMode _formType;
- //修改产品报损信息ID
- private string _barCode;
- //页面报损工序的数据源
- private List<ProductionDataEntity> _productionDataList = new List<ProductionDataEntity>();
- //该产品在产信息实体
- private InProductionEntity _isScrapProductEntity;
- //用户选择报损工序实体
- private ProductionDataEntity _scrapProductResponProcedure;
- //当前责任人集合
- private List<ScrapResponsibleEntity> _scrapResponsibleList = new List<ScrapResponsibleEntity>();
- //修改用废弃产品实体
- private ScrapProductEntity _updateEntity;
- //修改用废弃责任工序实体
- private ResponProcedureEntity _updateProcedureEntity;
- //修改用责任人集合
- private List<ScrapResponsibleEntity> _updateScrapResponsibleList;
- //有效条码标示
- private bool _yxBarCode = false;
- //产品分级类别ID
- private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
- //产品分级ID
- private int _goodsLevelId;
- //报损信息ID
- private int _editSPId;
- //是否允许审批
- private bool _isScrap = false;
- //未干补
- int SpecialRepairFlag = 0;
- //完成工序
- int? _CompleteProcdureID = null;
- //完成工序编码
- string _CompleteProcdureCode = "";
- //完成工序名称
- string _CompleteProcdureName = "";
- // 商标ID
- int? _LogoID = null;
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- public F_PM_1102(Constant.FormMode formType, string BarCode, int EditSPId, bool isScrap)
- {
- InitializeComponent();
- this._formType = formType;
- this._barCode = BarCode;
- this._editSPId = EditSPId;
- this._isScrap = isScrap;
- if (formType == Constant.FormMode.Add)
- {
- this.Text = FormTitles.F_PM_1102_ADD;
- }
- else
- {
- this.Text = FormTitles.F_PM_1102_EDIT;
- }
- this.btnViewApprover.Text = ButtonText.BTN_VIEWAPPROVER;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_1102_Load(object sender, EventArgs e)
- {
- try
- {
- //获取当前产品分级ID
- this._goodsLevelId = Convert.ToInt32(SystemModuleProxy.Service.GetGoodsLevelDataById(_goodsLevelTypeID, null)
- .Tables[0].Rows[0]["GoodsLevelID"]);
- // 损坯原因
- DataSet dsRreason = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetDictionaryData(0, "TPC008");
- }));
- this.cmbRreason.DisplayMember = "DictionaryValue";
- this.cmbRreason.ValueMember = "DictionaryID";
- this.cmbRreason.DataSource = dsRreason.Tables[0];
- //绑定损坯状态
- DataTable dtAuditStatus = new DataTable();
- dtAuditStatus.Columns.Add("AuditStatusID");
- dtAuditStatus.Columns.Add("AuditStatusValue");
- DataRow dr = dtAuditStatus.NewRow();
- dr["AuditStatusID"] = 0;
- dr["AuditStatusValue"] = "待审核";
- dtAuditStatus.Rows.Add(dr);
- //if (this._isScrap)
- //{
-
- //}
- dr = dtAuditStatus.NewRow();
- dr["AuditStatusID"] = 1;
- dr["AuditStatusValue"] = "损坯通过";
- dtAuditStatus.Rows.Add(dr);
- dr = dtAuditStatus.NewRow();
- dr["AuditStatusID"] = 2;
- dr["AuditStatusValue"] = "损坯驳回";
- dtAuditStatus.Rows.Add(dr);
- this.cmbAuditStatus.DisplayMember = "AuditStatusValue";
- this.cmbAuditStatus.ValueMember = "AuditStatusID";
- this.cmbAuditStatus.DataSource = dtAuditStatus;
- this.cmbAuditStatus.SelectedValue = 1;
- if (this._formType == Constant.FormMode.Edit)
- {
- BindEntity();
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 提交操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.txtBarCode.Text == string.Empty)
- {
- this.txtBarCode.Focus();
- return;
- }
- if (this.cmbRreason.Text == string.Empty)
- {
- MessageBox.Show("损坯原因必须填写!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
- if (this._formType == Constant.FormMode.Add)
- {
- if (this._yxBarCode != true)
- {
- MessageBox.Show("请先输入一个有效条码!!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Focus();
- return;
- }
- ScrapProductEntity addScrapProduct = null;
- ResponProcedureEntity addRProcedure = null;
- //获取责任人集合
- List<ScrapResponsibleEntity> addResponsibleList = new List<ScrapResponsibleEntity>();
- foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
- {
- int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
- if (isSelected == Constant.INT_IS_ONE)
- {
- ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
- selectResponsible.BarCode = this.txtBarCode.Text;
- selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
- selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
- selectResponsible.UserID = scbUser.SearchedPKMember;
- selectResponsible.UserCode = scbUser.SearchedValue + "";
- selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
- selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
- addResponsibleList.Add(selectResponsible);
- }
- }
- //如果选择了责任工序就一定要选择责任人
- //if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
- if (addResponsibleList.Count == Constant.INT_IS_ZERO)
- {
- MessageBox.Show("请选择责任人!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- //首先判断责任类型
- int thisResponType = 0;
- if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count == Constant.INT_IS_ZERO)
- {
- thisResponType = 1;
- }
- else if (cbResponProcedure.Text != string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- thisResponType = 3;
- }
- else if (cbResponProcedure.Text == string.Empty && addResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- thisResponType = 2;
- }
- if (thisResponType == Constant.INT_IS_ZERO)
- {
- MessageBox.Show("责任类别不正确!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- //新建报损产品实体
- addScrapProduct = new ScrapProductEntity();
- addScrapProduct.BarCode = this.txtBarCode.Text;
- addScrapProduct.ProductionLineID = _isScrapProductEntity.ProductionLineID;
- addScrapProduct.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
- addScrapProduct.ProductionLineName = _isScrapProductEntity.ProductionLineName;
- addScrapProduct.GoodsID = _isScrapProductEntity.GoodsID;
- addScrapProduct.GoodsCode = _isScrapProductEntity.GoodsCode;
- addScrapProduct.GoodsName = _isScrapProductEntity.GoodsName;
- addScrapProduct.GroutingDailyID = _isScrapProductEntity.GroutingDailyID;
- addScrapProduct.GroutingDailyDetailID = _isScrapProductEntity.GroutingDailyDetailID;
- addScrapProduct.GroutingDate = Convert.ToDateTime(_isScrapProductEntity.GroutingDate);
- addScrapProduct.GroutingLineID = _isScrapProductEntity.GroutingLineID;
- addScrapProduct.GroutingLineCode = _isScrapProductEntity.GroutingLineCode;
- addScrapProduct.GroutingLineName = _isScrapProductEntity.GroutingLineName;
- addScrapProduct.GMouldTypeID = _isScrapProductEntity.GMouldTypeID;
- addScrapProduct.GroutingLineDetailID = _isScrapProductEntity.GroutingLineDetailID;
- addScrapProduct.GroutingMouldCode = _isScrapProductEntity.GroutingMouldCode;
- addScrapProduct.MouldCode = _isScrapProductEntity.MouldCode;
- addScrapProduct.GoodsLevelTypeID = _goodsLevelTypeID;
- addScrapProduct.GoodsLevelID = _goodsLevelId;
- addScrapProduct.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
- addScrapProduct.Rreason = this.cmbRreason.Text;
- addScrapProduct.ResponUserID = scbUser.SearchedPKMember;
- addScrapProduct.ResponUserCode = scbUser.SearchedValue + "";
- addScrapProduct.ResponUserName = scbUser.Text;
- addScrapProduct.Remarks = this.txtRemarks.Text;
- addScrapProduct.AuditStatus = 0;
- addScrapProduct.SettlementFlag = 0;
- addScrapProduct.ResponType = thisResponType;
- addScrapProduct.GroutingUserID = Convert.ToInt32(_isScrapProductEntity.GroutingUserID);
- addScrapProduct.GroutingUserCode = _isScrapProductEntity.GroutingUserCode;
- addScrapProduct.GroutingNum = _isScrapProductEntity.GroutingNum;
- addScrapProduct.IsPublicBody = Convert.ToInt32(_isScrapProductEntity.IsPublicBody);
- addScrapProduct.IsReFire = Convert.ToInt32(_isScrapProductEntity.IsReFire);
- addScrapProduct.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
- addScrapProduct.SpecialRepairflag = this.SpecialRepairFlag;
- addScrapProduct.LogoID = this._LogoID;
- addScrapProduct.DiscovererStaffCode = this.dkStaffName.Text;
- if (this._CompleteProcdureID != null)
- {
- addScrapProduct.ProcedureID = this._CompleteProcdureID;
- //addScrapProduct.ProcedureName = this.txtCompleteProcdure.Text;
- addScrapProduct.ProcedureName = this._CompleteProcdureName;
- addScrapProduct.ProcedureCode = this._CompleteProcdureCode;
- }
- if (txtScrapFine.Text != string.Empty)
- {
- addScrapProduct.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
- }
- //如果存在责任工序的话,也要添加责任工序
- if (thisResponType == Constant.INT_IS_THREE)
- {
- addRProcedure = new ResponProcedureEntity();
- addRProcedure.BarCode = this.txtBarCode.Text;
- addRProcedure.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
- addRProcedure.ProductionLineID = _isScrapProductEntity.ProductionLineID;
- addRProcedure.ProductionLineCode = _isScrapProductEntity.ProductionLineCode;
- addRProcedure.ProductionLineName = _isScrapProductEntity.ProductionLineName;
- addRProcedure.ProcedureID = _scrapProductResponProcedure.ProcedureID;
- addRProcedure.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
- addRProcedure.ProcedureName = _scrapProductResponProcedure.ProcedureName;
- addRProcedure.UserID = scbUser.SearchedPKMember;
- addRProcedure.UserCode = scbUser.SearchedValue + "";
- addRProcedure.UserName = scbUser.Text;
- addRProcedure.Remarks = "";
- }
- int addReturn = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.AddScrapProduct(addScrapProduct, addRProcedure, addResponsibleList);
- }));
- if (addReturn > Constant.INT_IS_ZERO)
- {
- //成功
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- else if (addReturn == Constant.RETURN_IS_DATACHANGED)
- {
- //成功
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- //失败
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- //获取修改后的责任人集合
- this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
- foreach (DataGridViewRow gvrFor in dgvResponsible.Rows)
- {
- int isSelected = Convert.ToInt32(gvrFor.Cells["UserSelected"].Value);
- if (isSelected == Constant.INT_IS_ONE)
- {
- ScrapResponsibleEntity selectResponsible = new ScrapResponsibleEntity();
- selectResponsible.BarCode = this.txtBarCode.Text;
- selectResponsible.StaffID = Convert.ToInt32(gvrFor.Cells["StaffID"].Value);
- selectResponsible.StaffStatus = Convert.ToInt32(gvrFor.Cells["Staffstatus"].Value);
- selectResponsible.UserID = scbUser.SearchedPKMember;
- selectResponsible.UserCode = scbUser.SearchedValue + "";
- selectResponsible.UJobsID = Convert.ToInt32(gvrFor.Cells["UJobsId"].Value);
- selectResponsible.SJobsID = Convert.ToInt32(gvrFor.Cells["JobsId"].Value);
- this._updateScrapResponsibleList.Add(selectResponsible);
- }
- }
- //如果选择了责任工序就一定要选择责任人
- //if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
- if (_updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
- {
- MessageBox.Show("请选择责任人!",
- this.Text,
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- return;
- }
- //根据修改信息判断新的责任类型
- int thisResponType = 0;
- if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count == Constant.INT_IS_ZERO)
- {
- thisResponType = 1;
- }
- else if (cbResponProcedure.Text != string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- thisResponType = 3;
- }
- else if (cbResponProcedure.Text == string.Empty && _updateScrapResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- thisResponType = 2;
- }
- if (thisResponType == Constant.INT_IS_ZERO)
- {
- MessageBox.Show("责任类别不正确!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- //为修改实体赋值(可修改的只有备注,原因,责任工序,以及责任人)
- this._updateEntity.ScrapDate = Convert.ToDateTime(this.txtScrapDate.Text);
- this._updateEntity.Rreason = this.cmbRreason.Text;
- this._updateEntity.Remarks = this.txtRemarks.Text;
- this._updateEntity.ResponType = thisResponType;
- this._updateEntity.LogoID = this._LogoID;
- if (txtScrapFine.Text != string.Empty)
- {
- this._updateEntity.ScrapFine = Convert.ToDecimal(this.txtScrapFine.Text);
- }
- //新添审批状态判断,如果审批状态为未通过审批,要修改为未审批
- //if (this._updateEntity.AuditStatus != null)
- //{
- // if (this._updateEntity.AuditStatus == Constant.INT_IS_TWO)
- // {
- // this._updateEntity.AuditStatus = 0;
- // }
- //}
- this._updateEntity.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
- //如果存在责任工序的话,也要添加责任工序
- if (thisResponType == Constant.INT_IS_THREE)
- {
- if (this._updateProcedureEntity == null)
- {
- this._updateProcedureEntity = new ResponProcedureEntity();
- }
- this._updateProcedureEntity.BarCode = this.txtBarCode.Text;
- this._updateProcedureEntity.ProductionDataID = _scrapProductResponProcedure.ProductionDataID;
- this._updateProcedureEntity.ProductionLineID = _updateEntity.ProductionLineID;
- this._updateProcedureEntity.ProductionLineCode = _updateEntity.ProductionLineCode;
- this._updateProcedureEntity.ProductionLineName = _updateEntity.ProductionLineName;
- this._updateProcedureEntity.ProcedureID = _scrapProductResponProcedure.ProcedureID;
- this._updateProcedureEntity.ProcedureCode = _scrapProductResponProcedure.ProcedureCode;
- this._updateProcedureEntity.ProcedureName = _scrapProductResponProcedure.ProcedureName;
- this._updateProcedureEntity.UserID = scbUser.SearchedPKMember;
- this._updateProcedureEntity.UserCode = scbUser.SearchedValue + "";
- this._updateProcedureEntity.UserName = scbUser.Text;
- }
- else //不存在了直接把原来的删掉
- {
- if (this._updateProcedureEntity != null)
- {
- this._updateProcedureEntity.ValueFlag = 0;
- }
- }
- int updateReturn = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.UpdateScrapProduct(_updateEntity, _updateProcedureEntity, _updateScrapResponsibleList, _scrapResponsibleList);
- }));
- if (updateReturn > Constant.INT_IS_ZERO)
- {
- //成功
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- else
- {
- //失败
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 察看审批意见
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnViewApprover_Click(object sender, EventArgs e)
- {
- try
- {
- string barCode = this.txtBarCode.Text;
- F_PM_1103 frmFPM1103 = new F_PM_1103(barCode, 1, _editSPId);
- DialogResult dialogresult = frmFPM1103.ShowDialog();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选择工号改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void scbUser_TextValueChanged(object sender, WinForm.Controls.ScbSearchBox.TextChangeEventArgs e)
- {
- try
- {
- if (this.scbUser.SearchedPKMember != 0)
- {
- if (this.scbUser.Text != "")
- {
- this.dgvResponsible.AutoGenerateColumns = false;
- DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
- }));
- this.dgvResponsible.DataSource = dsUser.Tables[0];
- }
- else
- {
- this.dgvResponsible.DataSource = null;
- this.scbUser.ClearValue();
- }
- }
- else
- {
- this.dgvResponsible.DataSource = null;
- }
- if (this._formType == Constant.FormMode.Edit)
- {
- if (this.dgvResponsible.DataSource != null)
- {
- if (_scrapResponsibleList.Count != 0)
- {
- foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
- {
- string sourseNow = drNow.Cells["StaffID"].Value.ToString();
- foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
- {
- if (srFor.StaffID.ToString() == sourseNow)
- {
- drNow.Cells["UserSelected"].Value = "1";
- break;
- }
- }
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选择工号改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dkUser_UserValueChanged(object sender, Controls.SearchTextBox.dkUserInfoSearchBox.TextChangeEventArgs e)
- {
- // try
- // {
- // if (this.scbUser.SearchedPKMember != 0)
- // {
- // if (this.scbUser.Text != "")
- // {
- // this.dgvResponsible.AutoGenerateColumns = false;
- // DataSet dsUser = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- // {
- // return HRModuleProxy.Service.SearchHrStaffInfo(this.scbUser.SearchedPKMember);
- // }));
- // this.dgvResponsible.DataSource = dsUser.Tables[0];
- // }
- // else
- // {
- // this.dgvResponsible.DataSource = null;
- // this.scbUser.ClearValue();
- //}
- // }
- // else
- // {
- // this.dgvResponsible.DataSource = null;
- // }
- // if (this._formType == Constant.FormMode.Edit)
- // {
- // if (this.dgvResponsible.DataSource != null)
- // {
- // if (_scrapResponsibleList.Count != 0)
- // {
- // foreach (DataGridViewRow drNow in this.dgvResponsible.Rows)
- // {
- // string sourseNow = drNow.Cells["StaffID"].Value.ToString();
- // foreach (ScrapResponsibleEntity srFor in _scrapResponsibleList)
- // {
- // if (srFor.StaffID.ToString() == sourseNow)
- // {
- // drNow.Cells["UserSelected"].Value = "1";
- // break;
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- // catch (Exception ex)
- // {
- // // 对异常进行共通处理
- // ExceptionManager.HandleEventException(this.ToString(),
- // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- // }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 条码输入完毕后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtBarCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- try
- {
- string BarCode = this.txtBarCode.Text.Trim();
- if (BarCode != string.Empty)
- {
- string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.ScrapProductChack(BarCode);
- }));
- string[] doRuselts = doRuselt.Split(':');
- int isHave = Convert.ToInt32(doRuselts[0]);
- if (isHave == 2)
- {
- MessageBox.Show("不是在产产品不能报损!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- if (isHave == 3)
- {
- MessageBox.Show(string.Format("当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- if (isHave == 4)
- {
- MessageBox.Show(doRuselts[1],
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- if (isHave == Constant.INT_IS_ZERO)
- {
- MessageBox.Show("该产品已经存在报损记录!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetInProductionAndProductionData(BarCode);
- }));
- if (dsReturn != null)
- {
- if (dsReturn.Tables.Count == 4)
- {
- //判断在产表以及报损表中是否存在条码数据
- if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO && dsReturn.Tables[2].Rows.Count== Constant.INT_IS_ZERO) //在产表中没有数据
- {
- //目前不在生产线上也只报损 2015/07/14 modify wangx
- DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(BarCode);
- }));
- if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
- {
- MessageBox.Show("该产品条码无效,无法报损!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- //SpecialRepairFlag = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["SpecialRepairFlag"]);
- //this.txtProductionLineName.Text = "";
- //this.txtGoodsCode.Text = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
- //this.txtGroutingLine.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
- //this.txtMouldCode.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
- //this.txtGroutingUser.Text = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
- //this.cbResponProcedure.Enabled = false;
- ////this._isScrapProductEntity.ProductionLineID = 0;//放null
- ////this._isScrapProductEntity.ProductionLineCode = null;
- ////this._isScrapProductEntity.ProductionLineName = null;
- //this._isScrapProductEntity = new InProductionEntity();
- //this._isScrapProductEntity.GoodsID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GoodsID"]);
- //this._isScrapProductEntity.GoodsCode = dsDailyDetail.Tables[0].Rows[0]["GoodsCode"].ToString();
- //this._isScrapProductEntity.GoodsName = dsDailyDetail.Tables[0].Rows[0]["GoodsName"].ToString();
- //this._isScrapProductEntity.GroutingDailyID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyID"]);
- //this._isScrapProductEntity.GroutingDailyDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingDailyDetailID"]);
- //this._isScrapProductEntity.GroutingDate = Convert.ToDateTime(dsDailyDetail.Tables[0].Rows[0]["GroutingDate"]);
- //this._isScrapProductEntity.GroutingLineID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineID"]);
- //this._isScrapProductEntity.GroutingLineCode = dsDailyDetail.Tables[0].Rows[0]["GroutingLineCode"].ToString();
- //this._isScrapProductEntity.GroutingLineName = dsDailyDetail.Tables[0].Rows[0]["GroutingLineName"].ToString();
- //this._isScrapProductEntity.GMouldTypeID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GMouldTypeID"]);
- //this._isScrapProductEntity.GroutingLineDetailID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingLineDetailID"]);
- //this._isScrapProductEntity.GroutingMouldCode = dsDailyDetail.Tables[0].Rows[0]["GroutingMouldCode"].ToString();
- //this._isScrapProductEntity.MouldCode = dsDailyDetail.Tables[0].Rows[0]["MouldCode"].ToString();
- //this._isScrapProductEntity.GroutingUserID = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingUserID"]);
- //this._isScrapProductEntity.GroutingUserCode = dsDailyDetail.Tables[0].Rows[0]["GroutingUserCode"].ToString();
- //this._isScrapProductEntity.GroutingNum = Convert.ToInt32(dsDailyDetail.Tables[0].Rows[0]["GroutingNum"]);
- //this._isScrapProductEntity.IsPublicBody = 0;
- //this._isScrapProductEntity.IsReFire = 0;
- //this._yxBarCode = true;
- //this.txtBarCode.Enabled = false;
- // 2015/07/14 modify wangx end
- ////产品不在生产线上
- MessageBox.Show("不是在产产品不能报损!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- ////判断条码是否有效
- return; //加这个返回代码为了如果在注浆登记中,赋完值后直接返回,为了保存时候取值
- }
- DataTable dtInProduction = null;
- //获取产品情况以及经过工序情况
- if (dsReturn.Tables[0] == null ||dsReturn.Tables[0].Rows.Count==0)
- {
- dtInProduction = dsReturn.Tables[2];
- }
- else {
- //如果为第一次报损
- dtInProduction = dsReturn.Tables[0];
- //2015-05-26 begin modify by wangx
- if (dtInProduction != null && dtInProduction.Rows.Count > 0)
- {
- if (dtInProduction.Rows[0]["endmode"].ToString() == "2")//代表已经产成品
- {
- MessageBox.Show("该产品条码已经生产完成,无法报损!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
- {
- MessageBox.Show("该产品条码已经是返工状态,无法报损!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Text = "";
- this.txtBarCode.Focus();
- return;
- }
- }
- }
- //2015-05-26 end
- //获取节点类型
- //如果存在该类型的字段的话,判断一下
- // string a = dtInProduction.Columns[dtInProduction.Columns.Count - 1].ColumnName;
- foreach (DataColumn dcFor in dtInProduction.Columns)
- {
- if (dcFor.ColumnName.ToLower() == "proceduremodeltypeid")
- {
- int modelType = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureModelTypeID"]);
- // 装车,入窑,出窑,窑车补件不能报损
-
- }
- }
- DataTable dtProductionData = null;
- //过滤查询已经报损过的工序
- if (dsReturn.Tables[1].Rows.Count == 0) {
- dtProductionData = dsReturn.Tables[2];
- }
- else {
- dtProductionData = dsReturn.Tables[1];
- this.cbResponProcedure.DataSource = dtProductionData;
- this.cbResponProcedure.ValueMember = "ProcedureID";
- this.cbResponProcedure.DisplayMember = "ProcedureName";
- this.cbResponProcedure.Text = "";
- }
- foreach (DataRow drFor in dtInProduction.Rows)
- {
- SpecialRepairFlag = Convert.ToInt32(drFor["SpecialRepairFlag"]);
- this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
- this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
- this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
- this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
- this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
- if (drFor["logoID"].ToString() != "")
- {
- this._LogoID = Convert.ToInt32(drFor["logoID"]);
- }
- }
-
-
- List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
- if (inProductionList.Count != Constant.INT_IS_ZERO)
- {
- this._isScrapProductEntity = inProductionList[0];
- }
- else
- {
- if (this._updateEntity == null)
- {
- return;
- }
- if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
- {
- return;
- }
- //失败,条码不存在数据或无法转换
- MessageBox.Show(Messages.MSG_PM_W007,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- this._productionDataList = DataTableToListByProductionData(dtProductionData);
- if (this._productionDataList.Count != Constant.INT_IS_ZERO)
- {
- this._scrapProductResponProcedure = this._productionDataList[0];
- }
- this._yxBarCode = true;
- this.txtBarCode.Enabled = false;
- if (dtProductionData != null && dtProductionData.Rows.Count > 0)
- {
- this.cbResponProcedure.SelectedValue = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"];
- //赋值第三个table值
- dtProductionData = dsReturn.Tables[3];
- //this.cbResponProcedure.Enabled = false;
- // modify wangx 2015/06/06 begin
- this._CompleteProcdureID = Convert.ToInt32(dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureID"]);
- this.txtCompleteProcdure.Text = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
- _CompleteProcdureName = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureName"].ToString();
- this._CompleteProcdureCode = dtProductionData.Rows[dtProductionData.Rows.Count - 1]["ProcedureCode"].ToString();
- // modify wangx 2015/06/06 end
- cbResponProcedure_SelectedIndexChanged(sender, e);
- }
- else
- {
- this._CompleteProcdureID = Convert.ToInt32(dtInProduction.Rows[0]["ProcedureID"]);
- _CompleteProcdureName = dtInProduction.Rows[0]["ProcedureName"].ToString();
- this._CompleteProcdureCode = dtInProduction.Rows[0]["ProcedureCode"].ToString();
- }
- if (this.cbResponProcedure.Text == "" || this.cbResponProcedure.Text == null)
- {
- MessageBox.Show("该产品目前无可选损坯工序!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtBarCode.Focus();
- return;
- }
- }
- }
- else
- {
- if (this._updateEntity == null)
- {
- return;
- }
- if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
- {
- return;
- }
- //失败
- MessageBox.Show(Messages.MSG_PM_W007,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 将用户选择的工序实体赋值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cbResponProcedure_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- if (this._productionDataList.Count != Constant.INT_IS_ZERO)
- {
- if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
- {
- this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
- DataTable dt = this.cbResponProcedure.DataSource as DataTable;
- int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
- DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
- }));
- if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
- && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
- scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
- //this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
- //this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
- this.cbResponProcedure.DataSource = dt;
- this.cbResponProcedure.Enabled = true;
- //this.dkUser.ReadOnly = true;
- this.scbUser.Enabled = false;
- }
- else
- {
- this.scbUser.Enabled = true;
- this.scbUser.SearchedPKMember = 0;
- this.scbUser.ClearValue();
- }
- }
- else
- {
- this._scrapProductResponProcedure = null;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- if ((int)e.KeyChar == 13) // 按了回车键
- {
- this.cbResponProcedure.Focus();
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 加载数据
- /// </summary>
- private void BindEntity()
- {
- try
- {
- //条码控件不可用
- this.txtBarCode.Enabled = false;
- this._updateEntity = new ScrapProductEntity();
- this._updateEntity.BarCode = _barCode;
- this._updateEntity.ScrapProductID = _editSPId;
- //绑定生产工序集合
- DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetInProductionAndProductionData (_barCode);
- }));
- if (dsReturn != null)
- {
- if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
- {
- //获取产品情况以及经过工序情况
- DataTable dtInProduction = dsReturn.Tables[0];
- DataTable dtProductionData = dsReturn.Tables[1];
- foreach (DataRow drFor in dtInProduction.Rows)
- {
- this.txtProductionLineName.Text = drFor["ProductionLineName"].ToString();
- this.txtGoodsCode.Text = drFor["GoodsCode"].ToString();
- this.txtGroutingLine.Text = drFor["GroutingLineCode"].ToString();
- this.txtMouldCode.Text = drFor["GroutingMouldCode"].ToString();
- this.txtGroutingUser.Text = drFor["GroutingUserCode"].ToString();
- }
- this.cbResponProcedure.DataSource = dtProductionData;
- this.cbResponProcedure.DisplayMember = "ProcedureName";
- this.cbResponProcedure.ValueMember = "ProcedureID";
- this._productionDataList = DataTableToListByProductionData(dtProductionData);
- if (this._productionDataList.Count != Constant.INT_IS_ZERO)
- {
- this._scrapProductResponProcedure = this._productionDataList[0];
- }
- if (dtInProduction.Rows.Count == 0)
- {
- this.cbResponProcedure.Enabled = false;
- }
- }
- }
- //获取报废产品实体
- DataSet dsScrap = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetScrapProduct(this._updateEntity);
- }));
- if (dsScrap != null)
- {
- if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
- {
- DataRow drScrap = dsScrap.Tables[0].Rows[0];
- this._updateEntity.BarCode = drScrap["BarCode"].ToString();
- if (drScrap["ProductionLineID"].ToString() != "")
- {
- this._updateEntity.ProductionLineID = Convert.ToInt32(drScrap["ProductionLineID"]);
- this._updateEntity.ProductionLineCode = drScrap["ProductionLineCode"].ToString();
- this._updateEntity.ProductionLineName = drScrap["ProductionLineName"].ToString();
- this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
- this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
- this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
- this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
- this._CompleteProcdureID = Convert.ToInt32(drScrap["ProcedureID"]);
- this._CompleteProcdureCode = drScrap["ProcedureCode"].ToString();
- this.txtCompleteProcdure.Text = drScrap["ProcedureName"].ToString();
- }
- else //等于空时,取模具信息
- {
- this.txtGoodsCode.Text = drScrap["GoodsCode"].ToString();
- this.txtGroutingLine.Text = drScrap["GroutingLineCode"].ToString();
- this.txtMouldCode.Text = drScrap["GroutingMouldCode"].ToString();
- this.txtGroutingUser.Text = drScrap["GroutingUserCode"].ToString();
- }
- if (drScrap["logoid"].ToString() != "")
- {
- this._LogoID = Convert.ToInt32(drScrap["logoid"]);
- }
- this._updateEntity.GoodsID = Convert.ToInt32(drScrap["GoodsID"]);
- this._updateEntity.GoodsCode = drScrap["GoodsCode"].ToString();
- this._updateEntity.GoodsName = drScrap["GoodsName"].ToString();
- this._updateEntity.GroutingDailyID = Convert.ToInt32(drScrap["GroutingDailyID"]);
- this._updateEntity.GroutingDailyDetailID = Convert.ToInt32(drScrap["GroutingDailyDetailID"]);
- this._updateEntity.GroutingDate = Convert.ToDateTime(drScrap["GroutingDate"]);
- this._updateEntity.GroutingLineID = Convert.ToInt32(drScrap["GroutingLineID"]);
- this._updateEntity.GroutingLineCode = drScrap["GroutingLineCode"].ToString();
- this._updateEntity.GroutingLineName = drScrap["GroutingLineName"].ToString();
- this._updateEntity.GMouldTypeID = Convert.ToInt32(drScrap["GMouldTypeID"]);
- this._updateEntity.GroutingLineDetailID = Convert.ToInt32(drScrap["GroutingLineDetailID"]);
- this._updateEntity.GroutingMouldCode = drScrap["GroutingMouldCode"].ToString();
- this._updateEntity.MouldCode = drScrap["MouldCode"].ToString();
- this._updateEntity.GoodsLevelTypeID = Convert.ToInt32(drScrap["GoodsLevelTypeID"]);
- this._updateEntity.GoodsLevelID = Convert.ToInt32(drScrap["GoodsLevelID"]);
- this._updateEntity.ScrapDate = Convert.ToDateTime(drScrap["ScrapDate"]);
- this._updateEntity.Rreason = drScrap["Rreason"].ToString();
- this._updateEntity.Remarks = drScrap["Remarks"].ToString();
- this._updateEntity.AuditStatus = Convert.ToInt32(drScrap["AuditStatus"]);
- this._updateEntity.ResponType = Convert.ToInt32(drScrap["ResponType"]);
- this._updateEntity.SpecialRepairflag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
- this.SpecialRepairFlag = Convert.ToInt32(drScrap["SpecialRepairflag"]);
- if (drScrap["Auditor"] != DBNull.Value)
- {
- this._updateEntity.Auditor = Convert.ToInt32(drScrap["Auditor"]);
- }
- if (drScrap["AuditDate"] != DBNull.Value)
- {
- this._updateEntity.AuditlDate = Convert.ToDateTime(drScrap["AuditDate"]);
- }
- this._updateEntity.SettlementFlag = Convert.ToInt32(drScrap["SettlementFlag"]);
- if (drScrap["ResponProcedureID"] != DBNull.Value) //ProcedureID--改到ResponProcedureID
- {
- this._updateEntity.ResponProcedureID = Convert.ToInt32(drScrap["ResponProcedureID"]);
- }
- if (drScrap["UserID"] != DBNull.Value)
- {
- this._updateEntity.ResponUserID = Convert.ToInt32(drScrap["UserID"]);
- }
- if (drScrap["UserCode"] != DBNull.Value)
- {
- this._updateEntity.ResponUserCode = drScrap["UserCode"].ToString();
- }
- if (drScrap["UserName"] != DBNull.Value)
- {
- this._updateEntity.ResponUserName = drScrap["UserName"].ToString();
- }
- if (drScrap["ScrapFine"] != DBNull.Value)
- {
- this._updateEntity.ScrapFine = Convert.ToDecimal(drScrap["ScrapFine"]);
- }
- this.cmbAuditStatus.SelectedValue = this._updateEntity.AuditStatus;
- if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID ||
- (this._updateEntity.AuditStatus == Constant.INT_IS_ONE || this._updateEntity.AuditStatus == Constant.INT_IS_TWO)) //除关闭窗体外所有功能不可用
- {
- this.txtBarCode.Enabled = false;
- this.txtGoodsCode.Enabled = false;
- this.txtProductionLineName.Enabled = false;
- this.cbResponProcedure.Enabled = false;
- // 报损日期不能修改
- //this.txtScrapDate.Enabled = false;
- this.cmbRreason.Enabled = false;
- this.txtRemarks.Enabled = false;
- this.scbUser.Enabled = false;
- this.dgvResponsible.Enabled = false;
- this.btnSave.Enabled = false;
- this.btnViewApprover.Visible = false;
- this.cmbAuditStatus.Enabled = false;
- }
- if (this._updateEntity.Auditor != null && this._updateEntity.GoodsLevelTypeID == this._goodsLevelTypeID)
- {
- this.btnViewApprover.Visible = true;
- }
- }
- }
- else
- {
- this.Close();
- return;
- }
- //获取报废责任工序实体
- if (Convert.ToInt32(_updateEntity.ResponType) == Constant.INT_IS_THREE)
- {
- DataSet dsResPro = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetResponProcedureBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
- }));
- this._updateProcedureEntity = new ResponProcedureEntity();
- if (dsResPro != null && dsResPro.Tables[0].Rows.Count > 0) //如果原来存在责任工序实体
- {
- DataRow drResPro = dsResPro.Tables[0].Rows[0];
- this._updateProcedureEntity.ResponProcedureID = Convert.ToInt32(drResPro["ResponProcedureID"]);
- this.scbUser.Enabled = false;
- }
- this._updateProcedureEntity.BarCode = _updateEntity.BarCode;
- }
- //获取报废责任人实体集合
- if (Convert.ToInt32(_updateEntity.ResponType) != Constant.INT_IS_ONE)
- {
- this._updateScrapResponsibleList = new List<ScrapResponsibleEntity>();
- DataSet dsResponsible = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetScrapResponsibleBySPId(Convert.ToInt32(_updateEntity.ScrapProductID));
- }));
- DataTableToListByScrapResponsible(dsResponsible);
- }
- //控件赋值
- this.txtBarCode.Text = _updateEntity.BarCode;
- this.txtGoodsCode.Text = _updateEntity.GoodsCode;
- this.txtProductionLineName.Text = _updateEntity.ProductionLineName;
- this.cbResponProcedure.SelectedValue = _updateEntity.ResponProcedureID;
- this.txtScrapDate.Text = _updateEntity.ScrapDate.ToString();
- try
- {
- this.cmbRreason.Text = _updateEntity.Rreason;
- }
- catch
- {
- this.cmbRreason.Text = "";
- }
- this.txtRemarks.Text = _updateEntity.Remarks;
- this.txtScrapFine.Text = _updateEntity.ScrapFine.ToString();
- //this._updateEntity.ScrapFine
- if (this._updateEntity.ResponUserID != null)
- {
- scbUser.SearchedPKMember = Convert.ToInt32(_updateEntity.ResponUserID);
- scbUser.InitValue(_updateEntity.ResponUserName, _updateEntity.ResponUserCode);
- //this.dkUser.UserID = _updateEntity.ResponUserID;
- // this.dkUser.UserCode = _updateEntity.ResponUserCode;
- // this.dkUser.UserName = _updateEntity.ResponUserName;
- }
- else if (this._scrapResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- scbUser.SearchedPKMember = Convert.ToInt32(_scrapResponsibleList[0].UserID);
- scbUser.InitValue(_scrapResponsibleList[0].UserName, _scrapResponsibleList[0].UserCode);
- //this.dkUser.UserID = _scrapResponsibleList[0].UserID;
- // this.dkUser.UserCode = _scrapResponsibleList[0].UserCode;
- // this.dkUser.UserName = _scrapResponsibleList[0].UserName;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 数据表到实体转换
- /// </summary>
- /// <param name="dsScrapResponsible"></param>
- private void DataTableToListByScrapResponsible(DataSet dsScrapResponsible)
- {
- foreach (DataRow drFor in dsScrapResponsible.Tables[0].Rows)
- {
- ScrapResponsibleEntity srEntity = new ScrapResponsibleEntity();
- srEntity.ResponsibleID = Convert.ToInt32(drFor["ResponsibleID"]);
- srEntity.ScrapProductID = Convert.ToInt32(drFor["ScrapProductID"]);
- srEntity.BarCode = drFor["BarCode"].ToString();
- srEntity.ResponType = Convert.ToInt32(drFor["ResponType"]);
- if (drFor["ResponProcedureID"] != DBNull.Value)
- {
- srEntity.ResponProcedureID = Convert.ToInt32(drFor["ResponProcedureID"]);
- }
- srEntity.StaffID = Convert.ToInt32(drFor["StaffID"]);
- srEntity.UserID = Convert.ToInt32(drFor["UserID"]);
- srEntity.UserCode = drFor["UserCode"].ToString();
- srEntity.UJobsID = Convert.ToInt32(drFor["UJobsID"]);
- srEntity.SJobsID = Convert.ToInt32(drFor["SJobsID"]);
- srEntity.StaffStatus = Convert.ToInt32(drFor["StaffStatus"]);
- srEntity.AccountID = Convert.ToInt32(drFor["AccountID"]);
- srEntity.CreateTime = Convert.ToDateTime(drFor["CreateTime"]);
- srEntity.CreateUserID = Convert.ToInt32(drFor["CreateUserID"]);
- srEntity.UpdateTime = Convert.ToDateTime(drFor["UpdateTime"]);
- srEntity.UpdateUserID = Convert.ToInt32(drFor["UpdateUserID"]);
- srEntity.OPTimeStamp = Convert.ToDateTime(drFor["OPTimeStamp"]);
- srEntity.UserName = drFor["userName"].ToString();
- this._scrapResponsibleList.Add(srEntity);
- }
- }
- /// <summary>
- /// 数据表到实体转换
- /// </summary>
- /// <param name="dtProductionData"></param>
- /// <returns></returns>
- private List<ProductionDataEntity> DataTableToListByProductionData(DataTable dtProductionData)
- {
- List<ProductionDataEntity> pdList = new List<ProductionDataEntity>();
- foreach (DataRow drFor in dtProductionData.Rows)
- {
- ProductionDataEntity pdEntity = new ProductionDataEntity();
- pdEntity.ProductionDataID = Convert.ToInt32(drFor["ProductionDataID"]);
- pdEntity.ProcedureID = Convert.ToInt32(drFor["ProcedureID"]);
- pdEntity.ProcedureCode = drFor["ProcedureCode"].ToString();
- pdEntity.ProcedureName = drFor["ProcedureName"].ToString();
- pdList.Add(pdEntity);
- }
- return pdList;
- }
- #endregion
- private void cbResponProcedure_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- try
- {
- if (this._productionDataList.Count != Constant.INT_IS_ZERO)
- {
- if (this.cbResponProcedure.ListBox.SelectedIndex > -Constant.INT_IS_ONE)
- {
- this._scrapProductResponProcedure = _productionDataList[this.cbResponProcedure.ListBox.SelectedIndex];
- DataTable dt = this.cbResponProcedure.DataSource as DataTable;
- int ProductionDataID = Convert.ToInt32(dt.Select("ProcedureID=" + this.cbResponProcedure.SelectedValue)[0]["ProductionDataID"]);
- DataSet dsUserCode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetScrapProductUserCodeByProductionDataID(ProductionDataID);
- }));
- if (dsUserCode != null && dsUserCode.Tables.Count > Constant.INT_IS_ZERO
- && dsUserCode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this.scbUser.SearchedPKMember = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
- scbUser.InitValue(dsUserCode.Tables[0].Rows[0]["UserName"].ToString(), dsUserCode.Tables[0].Rows[0]["UserCode"].ToString());
- //this.dkUser.UserID = Convert.ToInt32(dsUserCode.Tables[0].Rows[0]["UserId"]);
- // this.dkUser.UserName = dsUserCode.Tables[0].Rows[0]["UserName"].ToString();
- // this.dkUser.UserCode = dsUserCode.Tables[0].Rows[0]["UserCode"].ToString();
- this.cbResponProcedure.DataSource = dt;
- this.cbResponProcedure.Enabled = true;
- this.scbUser.Enabled = false; ;
- }
- else
- {
- this.scbUser.Enabled = true;
- this.scbUser.SearchedPKMember = 0;
- this.scbUser.ClearValue();
- }
- }
- else
- {
- this._scrapProductResponProcedure = null;
- this.scbUser.Enabled = true;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|