| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911 |
- /*******************************************************************************
- * 类的信息:
- * 1.程序名称:F_PM_1107.cs
- * 2.功能描述:批量报废信息窗体
- * 编辑履历:
- * 作者 日期
- * 李士越 2024/05/29
- *******************************************************************************/
- 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;
- using Dongke.IBOSS.PRD.Client.Controls;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- /// <summary>
- /// 批量报废信息窗体
- /// </summary>
- public partial class F_PM_1107 : DKFormBase
- {
- #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;
- //可以报损的产品条码集合
- List<string> ReportingLosses = new List<string>();
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- public F_PM_1107(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 = "批量报损";
- //}
- //else
- //{
- // this.Text = FormTitles.F_PM_1107_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_1107_Load(object sender, EventArgs e)
- {
- try
- {
- //获取当前产品分级ID
- this._goodsLevelId = Convert.ToInt32(SystemModuleProxy.Service.GetGoodsLevelDataById(_goodsLevelTypeID, null)
- .Tables[0].Rows[0]["GoodsLevelID"]);
- DataTable dt = new DataTable();
- dt.Columns.Add("DictionaryID", typeof(int));
- dt.Columns.Add("DictionaryValue", typeof(string));
- DataRow drbydt = dt.NewRow();
- drbydt["DictionaryID"] = 119;
- drbydt["DictionaryValue"] = "盘点报损";
- dt.Rows.Add(drbydt);
- this.cmbRreason.DisplayMember = "DictionaryValue";
- this.cmbRreason.ValueMember = "DictionaryID";
- this.cmbRreason.DataSource = dt;
- //绑定损坯状态
- DataTable dtAuditStatus = new DataTable();
- dtAuditStatus.Columns.Add("AuditStatusID");
- dtAuditStatus.Columns.Add("AuditStatusValue");
- DataRow dr = dtAuditStatus.NewRow();
- dr = dtAuditStatus.NewRow();
- dr["AuditStatusID"] = 1;
- dr["AuditStatusValue"] = "损坯通过";
- dtAuditStatus.Rows.Add(dr);
- this.cmbAuditStatus.DisplayMember = "AuditStatusValue";
- this.cmbAuditStatus.ValueMember = "AuditStatusID";
- this.cmbAuditStatus.DataSource = dtAuditStatus;
- 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;
- }
- //模拟回车
- KeyPressEventArgs args = new KeyPressEventArgs('\r');
- //条码校验防止重复报损
- txtBarCode_KeyPress(sender, args);
- this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
- if (ReportingLosses.Count == 0)
- {
- MessageBox.Show("未有可报损条码",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
- DataTable dt = new DataTable();
- //备注
- dt.Columns.Add("notes");
- //产品编码
- dt.Columns.Add("ProductCode");
- foreach (var item in ReportingLosses) {
- DataRow dr = dt.NewRow();
- dr["notes"] = save(item);
- dr["ProductCode"] = item;
- dt.Rows.Add(dr);
- }
- this.detailsView.DataSource = dt;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 保存方法
- /// </summary>
- /// <param name="barcode"></param>
- /// <returns></returns>
- public string save(string barcode) {
- string result = "";
- try
- {
- if (this.txtBarCode.Text == string.Empty)
- {
- this.txtBarCode.Focus();
- return "";
- }
- ServiceResultEntity sreByid = DoAsync<ServiceResultEntity>(() =>
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_1107";
- cre.Name = "ReadAllDataByProductCode";
- cre.Properties["BARCODE"] = barcode;
- return SystemModuleProxy.Service.DoRequest(cre);
- });
- if (sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()==string.Empty || sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()=="" || sreByid.Data.Tables[0].Rows[0]["USERID"].ToString()==null) {
- return "信息不全,此产品不做任何处理";
- }
- ServiceResultEntity sreByuserid = DoAsync<ServiceResultEntity>(() =>
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_1107";
- cre.Name = "ReadStaffInformation";
- cre.Properties["USERID"] = sreByid.Data.Tables[0].Rows[0]["USERID"].ToString();
- return SystemModuleProxy.Service.DoRequest(cre);
- });
- this.txtRemarks.Focus();//把光标移开,由于删除工号后,值未变
- if (this._formType == Constant.FormMode.Add)
- {
- //获取责任人集合
- List<ScrapResponsibleEntity> addResponsibleList = new List<ScrapResponsibleEntity>()
- {
- new ScrapResponsibleEntity() {
- BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString(),
- StaffID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["STAFFID"].ToString()),
- StaffStatus = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["Staffstatus"].ToString()),
- UserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString()),
- UserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "",
- UJobsID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["UJobsId"].ToString()),
- SJobsID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["JOBS"].ToString()),
- }
- };
- //如果选择了责任工序就一定要选择责任人
- //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 (sreByid.Data.Tables[0].Rows.Count == 0 && addResponsibleList.Count == Constant.INT_IS_ZERO)
- {
- thisResponType = 1;
- }
- else if (sreByid.Data.Tables[0].Rows.Count > 0 && addResponsibleList.Count != Constant.INT_IS_ZERO)
- {
- thisResponType = 3;
- }
- else if (sreByid.Data.Tables[0].Rows.Count == 0 && 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 "责任类别不正确!";
- }
- //新建报损产品实体
- ScrapProductEntity addScrapProduct = new ScrapProductEntity();
- addScrapProduct.BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString();
- addScrapProduct.ProductionLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINEID"].ToString());
- addScrapProduct.ProductionLineCode = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINECODE"].ToString();
- addScrapProduct.ProductionLineName = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINENAME"].ToString();
- addScrapProduct.GoodsID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GOODSID"].ToString());
- addScrapProduct.GoodsCode = sreByid.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
- addScrapProduct.GoodsName = sreByid.Data.Tables[0].Rows[0]["GOODSNAME"].ToString();
- addScrapProduct.GroutingDailyID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGDAILYID"].ToString());
- addScrapProduct.GroutingDailyDetailID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGDAILYDETAILID"].ToString());
- addScrapProduct.GroutingDate = Convert.ToDateTime(sreByid.Data.Tables[0].Rows[0]["GROUTINGDATE"].ToString());
- addScrapProduct.GroutingLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGLINEID"].ToString());
- addScrapProduct.GroutingLineCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGLINECODE"].ToString();
- addScrapProduct.GroutingLineName = sreByid.Data.Tables[0].Rows[0]["GROUTINGLINENAME"].ToString();
- addScrapProduct.GMouldTypeID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GMOULDTYPEID"].ToString());
- addScrapProduct.GroutingLineDetailID = int.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGLINEDETAILID"].ToString());
- addScrapProduct.GroutingMouldCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGMOULDCODE"].ToString();
- addScrapProduct.MouldCode = sreByid.Data.Tables[0].Rows[0]["MOULDCODE"].ToString();
- addScrapProduct.GoodsLevelTypeID = _goodsLevelTypeID;
- addScrapProduct.GoodsLevelID = _goodsLevelId;
- addScrapProduct.ScrapDate = DateTime.Now;
- addScrapProduct.Rreason = "盘点报损";
- addScrapProduct.ResponUserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString());
- addScrapProduct.ResponUserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "";
- addScrapProduct.ResponUserName = sreByuserid.Data.Tables[0].Rows[0]["USERNAME"].ToString();
- addScrapProduct.Remarks = this.txtRemarks.Text;
- addScrapProduct.AuditStatus = 0;
- addScrapProduct.SettlementFlag = 0;
- addScrapProduct.ResponType = thisResponType;
- addScrapProduct.GroutingUserID = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["GROUTINGUSERID"].ToString());
- addScrapProduct.GroutingUserCode = sreByid.Data.Tables[0].Rows[0]["GROUTINGUSERCODE"].ToString();
- addScrapProduct.GroutingNum = decimal.Parse(sreByid.Data.Tables[0].Rows[0]["GROUTINGNUM"].ToString());
- addScrapProduct.IsPublicBody = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["ISPUBLICBODY"].ToString());
- addScrapProduct.IsReFire = Convert.ToInt32(sreByid.Data.Tables[0].Rows[0]["ISREFIRE"].ToString());
- addScrapProduct.AuditStatus = Convert.ToInt32(cmbAuditStatus.SelectedValue);
- addScrapProduct.SpecialRepairflag = int.Parse(sreByid.Data.Tables[0].Rows[0]["SPECIALREPAIRFLAG"].ToString());
- addScrapProduct.LogoID = int.Parse(sreByid.Data.Tables[0].Rows[0]["LogoID"].ToString());
- if (sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString() != null)
- {
- addScrapProduct.ProcedureID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString());
- //addScrapProduct.ProcedureName = this.txtCompleteProcdure.Text;
- addScrapProduct.ProcedureName = sreByid.Data.Tables[0].Rows[0]["ProcedureName"].ToString();
- addScrapProduct.ProcedureCode = sreByid.Data.Tables[0].Rows[0]["ProcedureCode"].ToString();
- }
- ResponProcedureEntity addRProcedure = new ResponProcedureEntity();
- //如果存在责任工序的话,也要添加责任工序
- if (thisResponType == Constant.INT_IS_THREE)
- {
- addRProcedure.BarCode = sreByid.Data.Tables[0].Rows[0]["BarCode"].ToString();
- addRProcedure.ProductionDataID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONDATAID"].ToString());
- addRProcedure.ProductionLineID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINEID"].ToString());
- addRProcedure.ProductionLineCode = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINECODE"].ToString();
- addRProcedure.ProductionLineName = sreByid.Data.Tables[0].Rows[0]["PRODUCTIONLINENAME"].ToString();
- addRProcedure.ProcedureID = int.Parse(sreByid.Data.Tables[0].Rows[0]["PROCEDUREID"].ToString());
- addRProcedure.ProcedureCode = sreByid.Data.Tables[0].Rows[0]["ProcedureCode"].ToString();
- addRProcedure.ProcedureName = sreByid.Data.Tables[0].Rows[0]["ProcedureName"].ToString();
- addRProcedure.UserID = Convert.ToInt32(sreByuserid.Data.Tables[0].Rows[0]["USERID"].ToString());
- addRProcedure.UserCode = sreByuserid.Data.Tables[0].Rows[0]["USERCODE"].ToString() + "";
- addRProcedure.UserName = sreByuserid.Data.Tables[0].Rows[0]["USERNAME"].ToString();
- 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;
- return string.Format(Messages.MSG_CMN_I001, "废弃产品", "保存");
- }
- 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;
- return string.Format(Messages.MSG_CMN_W007, "操作的数据已经发生了变化");
- }
- else
- {
- //失败
- //MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return string.Format(Messages.MSG_CMN_W001, "废弃产品", "保存");
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- return result;
- }
- /// <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_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- //清除所有产品条码
- ReportingLosses.Clear();
- if ((int)e.KeyChar == 13 && (this.txtBarCode.Text != "" && this.txtBarCode.Text != string.Empty && this.txtBarCode.Text != null)) // 按了回车键
- {
- var dt = new DataTable();
- //备注
- dt.Columns.Add("notes");
- //产品编码
- dt.Columns.Add("ProductCode");
- var sss = SplitLong11(this.txtBarCode.Text);
- foreach (var item in sss)
- {
- var pubg = ReadAllDataByProductCode(item);
- DataRow dr = dt.NewRow();
- dr["notes"] = pubg ;
- dr["ProductCode"] = item;
- dt.Rows.Add(dr);
- if (pubg =="没有问题") { ReportingLosses.Add(item); }
-
- }
- this.dgvResponsible.DataSource = dt;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 字符串按11位分割
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- public List<string> SplitLong11(string item) {
- List<string> result = new List<string>();
- // 检查字符串长度是否大于或等于分组大小
- if (item.Length >= 11)
- {
- for (int i = 0; i < item.Length; i += 11)
- {
- // 截取当前分组,注意不要超出字符串长度
- int length = Math.Min(11, this.txtBarCode.Text.Length - i);
- string chunk = this.txtBarCode.Text.Substring(i, length);
- result.Add(chunk);
- }
- }
- return result;
- }
- #endregion
- /// <summary>
- /// 产品条码检验
- /// </summary>
- /// <param name="item"></param>
- /// <returns></returns>
- private string ReadAllDataByProductCode(string item)
- {
- string notes = "没有问题";
- try
- {
- string doRuselt = (string)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.ScrapProductChack(item);
- }));
- string[] doRuselts = doRuselt.Split(':');
- int isHave = Convert.ToInt32(doRuselts[0]);
- if (isHave == 2)
- {
- return notes = "不是在产产品不能报损!";
- //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- if (isHave == 3)
- {
- return notes = "当前工号没有此产品所在工序"+ doRuselts[1] + "的操作权限,不能报损!";
- //MessageBox.Show(string.Format("产品编码为" + item + " 当前工号没有此产品所在工序【{0}】的操作权限,不能报损!", doRuselts[1]),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- if (isHave == 4)
- {
- return notes = doRuselts[1];
- // MessageBox.Show(doRuselts[1],
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- if (isHave == Constant.INT_IS_ZERO)
- {
- return notes = "已经存在报损记录!";
- // MessageBox.Show("产品编码为" + item + " 已经存在报损记录!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- DataSet dsReturn = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetInProductionAndProductionData(item);
- }));
- if (dsReturn != null)
- {
- if (dsReturn.Tables.Count == Constant.INT_IS_TWO)
- {
- if (dsReturn.Tables[0].Rows.Count == Constant.INT_IS_ZERO) //在产表中没有数据
- {
- //目前不在生产线上也只报损 2015/07/14 modify wangx
- DataSet dsDailyDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetBarCodeInGroutingDailyDetail(item);
- }));
- if (dsDailyDetail != null && dsDailyDetail.Tables[0].Rows.Count == 0)
- {
- return notes = "条码无效,无法报损!";
- //MessageBox.Show("产品编码为" + item + " 条码无效,无法报损!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- return notes = "不是在产产品不能报损!";
- // 2015/07/14 modify wangx end
- ////产品不在生产线上
- //MessageBox.Show("产品编码为" + item + " 不是在产产品不能报损!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //////判断条码是否有效
- //Product = false;
- }
- //获取产品情况以及经过工序情况
- DataTable 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")//代表已经产成品
- {
- return notes = "已经生产完成,无法报损!";
- //MessageBox.Show("产品编码为" + item + " 已经生产完成,无法报损!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- if (dtInProduction.Rows[0]["IsReworkFlag"].ToString() == "1")//代表已经返工
- {
- return notes = "已经是返工状态,无法报损!";
- //MessageBox.Show("产品编码为" + item + " 已经是返工状态,无法报损!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- }
- //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"]);
- // 装车,入窑,出窑,窑车补件不能报损
- if (modelType == Constant.INT_IS_ONE || modelType == Constant.INT_IS_TWO || modelType == Constant.INT_IS_THREE || modelType == Constant.INT_IS_SIX)
- {
- return notes = "处于无法报损的特殊工序中!";
- //某些特殊工序不可报损
- //MessageBox.Show("产品编码为" + item + " 处于无法报损的特殊工序中!",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- //this.txtBarCode.Text = "";
- //this.txtBarCode.Focus();
- //Product = false;
- }
- }
- }
- List<InProductionEntity> inProductionList = DataConvert.TableConvertToObject<InProductionEntity>(dtInProduction);
- if (inProductionList.Count != Constant.INT_IS_ZERO)
- {
- this._isScrapProductEntity = inProductionList[0];
- }
- else
- {
- if (this._updateEntity == null)
- {
- return null;
- }
- if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
- {
- return null;
- }
- //失败,条码不存在数据或无法转换
- MessageBox.Show(Messages.MSG_PM_W007,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return null;
- }
-
- }
- else
- {
- if (this._updateEntity == null)
- {
- return null;
- }
- if (this._updateEntity.GoodsLevelTypeID != this._goodsLevelTypeID)
- {
- return null;
- }
- //失败
- 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);
- }
- return notes;
- }
-
- #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];
- }
-
- }
- }
- //获取报废产品实体
- 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;
- }
- }
- }
- 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;
- 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
- }
- }
|