| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0102_1_1.cs
- * 2.功能描述:新建成型线信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/09/25 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.PCModule
- {
- public partial class F_PC_0102_1_1 : FormBase
- {
- #region 成员变量
- //需要添加的成型线明细集合
- public List<GroutingLineDetailEntity> _addDetailList = new List<GroutingLineDetailEntity>();
- //需要添加的成型工号明细集合
- public List<GroutingLineUserEntity> _addDetailUserList = new List<GroutingLineUserEntity>();
- //模具总数量
- private int _mouldCount = 0;
- //是否已经提示过删除模具的信息
- private bool _isMessageShow = false;
- //
- private string _userCodeValue;
- private bool _ShowFlag = true;
- #endregion
- #region 构造函数
- public F_PC_0102_1_1()
- {
- InitializeComponent();
- this.Text = FormTitles.F_PC_0102;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- this.btnAddMould.Text = ButtonText.BTN_ADDMOULD;
- this.btnDeleteSelected.Text = ButtonText.BTN_DELETESELECTED;
- //this.dkUser.IsWorker = true;
- this.dgvUser.AutoGenerateColumns = false;
- this.dgvDetail.AutoGenerateColumns = false;
- DataTable dtUser = new DataTable();
- dtUser.Columns.Add("UserID");
- dtUser.Columns.Add("UserCode");
- dtUser.Columns.Add("UserName");
- dtUser.Columns.Add("StaffNames");
- dtUser.Columns.Add("Remark");
- dtUser.Columns["UserID"].Unique = true;
- this.dgvUser.DataSource = dtUser;
- this.scbUser1.DisplayMember = "USERNAMECode";
- this.scbUser1.ValueMember = "UserID";
- }
- #endregion
- #region 事件
- /// <summary>
- /// 自适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvUser.AutoResizeColumns();
- this.dgvDetail.AutoResizeColumns();
- }
- /// <summary>
- /// 添加成型线明细
- /// </summary>
- private void btnAddMould_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.txtGroutingLineCode.Text == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型线编码"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (string.IsNullOrEmpty(this.txtBeginNum.Text))
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "起始模具号"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.txtCount.Text == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具数量"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.scbGoods.SearchedPKMember == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产品"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (Convert.ToInt32(txtBeginNum.Text) + Convert.ToInt32(txtCount.Text) > 999)
- {
- MessageBox.Show("成型线模具数量不可超过999个!", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- //if (this._mouldCount == 999)
- //{
- // MessageBox.Show("成型线模具数量不可超过999个!", this.Text,
- // MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- if (this._isMessageShow == false)
- {
- DialogResult msgBoxResult = MessageBox.Show("添加模具后,成型线编码相关信息不予许修改,是否继续。",
- this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (msgBoxResult == DialogResult.No)
- {
- return;
- }
- else
- {
- this.txtBuildingNo.ReadOnly = true;
- this.txtFloorNo.ReadOnly = true;
- this.txtGroutingLineNo.ReadOnly = true;
- }
- this._isMessageShow = true;
- }
- //for (int i = 0; i < _addDetailList.Count; i++)
- //{
- // DataRow drRow = dtDataSourse.NewRow();
- // drRow["GROUTINGMOULDCODE"] = _addDetailList[i].GROUTINGMOULDCODE;
- // drRow["GOODSNAME"] = _addDetailList[i].GOODSNAME;
- // drRow["GoodsCode"] = _addDetailList[i].GOODSCODE;
- // drRow["GoodsSpecification"] = _addDetailList[i].GoodsSpecification;
- // drRow["GOODSID"] = _addDetailList[i].GOODSID;
- // dtDataSourse.Rows.Add(drRow);
- //}
- bool isError = false;
- DataTable dtDetail = this.dgvDetail.DataSource as DataTable;
- int BeginNum = Convert.ToInt32(this.txtBeginNum.Text);
- for (int i = 0; i < Convert.ToInt32(this.txtCount.Text); i++)
- {
- ////// int GroutingMouldCodeNum = BeginNum + _mouldCount;
- //// int GroutingMouldCodeNum = BeginNum ;
- //// GroutingLineDetailEntity detailInfo = new GroutingLineDetailEntity();
- //// detailInfo.GROUTINGMOULDCODE = this.txtGroutingLineCode.Text + "-" + (GroutingMouldCodeNum).ToString().PadLeft(3, '0');
- //// if (dtDetail != null)
- //// {
- //// DataRow[] dr = dtDetail.Select("GROUTINGMOULDCODE='" + detailInfo.GROUTINGMOULDCODE + "'");
- //// if (dr.Length > 0)
- //// {
- //// isError = true;
- //// break;
- //// }
- //// }
- //// detailInfo.MOULDCODE = Guid.NewGuid().ToString();
- //// detailInfo.GOODSID = Convert.ToInt32(this.dkGoods.GoodsID);
- //// detailInfo.GOODSNAME = this.dkGoods.GoodsName;
- //// detailInfo.GOODSCODE = this.dkGoods.GoodsCode;
- //// detailInfo.GoodsSpecification = this.dkGoods.GoodsSpecification;
- //// detailInfo.GROUTINGCOUNT = Constant.INT_IS_ZERO;
- //// detailInfo.MOULDSTATUS = Convert.ToInt32(Constant.GMouldStatus.Normal);
- //// detailInfo.REMARKS = "";
- //// detailInfo.VALUEFLAG = 1;
- //// this._addDetailList.Add(detailInfo);
- //// BeginNum = BeginNum + 1;
- int GroutingMouldCodeNum = BeginNum;
- //GroutingLineDetailEntity detailInfo = new GroutingLineDetailEntity();
- string MOULDCODE = this.txtGroutingLineCode.Text + "-" + (GroutingMouldCodeNum).ToString().PadLeft(3, '0');
- DataTable dtInfo = this.dgvDetail.DataSource as DataTable;
- DataRow[] dr = dtInfo.Select("GroutingMouldCode='" + MOULDCODE + "'");
- if (dr.Length > 0)
- {
- isError = true;
- break;
- };
- //if (dtDetail != null)
- //{
- // DataRow[] dr = dtDetail.Select("GROUTINGMOULDCODE='" + detailInfo.GROUTINGMOULDCODE + "'");
- // if (dr.Length > 0)
- // {
- // isError = true;
- // break;
- // }
- //}
- DataRow r = dtInfo.NewRow();
- r["GroutingMouldCode"] = MOULDCODE;
- r["MouldSource"] = "0";
- r["MOULDCODE"] = Guid.NewGuid().ToString();
- r["GOODSID"] = scbGoods.SearchedPKMember;
- r["GOODSNAME"] = scbGoods.SearchedItem["GOODSNAME"];
- r["GOODSCODE"] = scbGoods.SearchedItem["GOODSCODE"];
- r["GoodsSpecification"] = scbGoods.SearchedItem["GOODSSPECIFICATION"];
- r["GROUTINGCOUNT"] = 0;
- r["StandardGroutingCount"] = Convert.ToInt32(this.txtStandardGroutingCount.DataValue.Value);
- r["MOULDSTATUS"] = Convert.ToInt32(Constant.GMouldStatus.Normal);
- //r["REMARKS"] = "";
- r["VALUEFLAG"] = "1";
- dtInfo.Rows.Add(r);
- //this._addDetailList.Add(detailInfo);
- BeginNum = BeginNum + 1;
- }
- if (isError)
- {
- BeginNum = Convert.ToInt32(this.txtBeginNum.Text);
- //有错误
- MessageBox.Show("存在相同的模具编号", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- else
- {
- this.txtBeginNum.DataValue = BeginNum;
- }
- this._mouldCount += Convert.ToInt32(this.txtCount.Text);
- //this.dgvDetail.AutoGenerateColumns = false;
- //this.dgvDetail.DataSource = ListToTable();
- //this.dgvDetail.IsSetInputColumnsColor = true;
- //this.tabControl1.SelectTab(1);
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 删除明细
- /// </summary>
- private void btnDeleteSelected_Click(object sender, EventArgs e)
- {
- try
- {
- DataRowView drv = this.dgvDetail.CurrentRow.DataBoundItem as DataRowView;
- if (drv == null)
- {
- return;
- }
- // 一模多产时,同一模具一同清除。 add by chenxy 2018-10-29
- if (drv["MouldID"] != DBNull.Value)
- {
- DataTable dt = this.dgvDetail.DataSource as DataTable;
- DataRow[] drs = dt.Select("MouldID = " + drv["MouldID"]);
- if (drs.Length > 1)
- {
- foreach (DataRow item in drs)
- {
- item.Delete();
- }
- }
- else
- {
- drv.Delete();
- }
- }
- else
- {
- drv.Delete();
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 提交新建
- /// </summary>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- int ErrorId = ValidationText();
- if (ErrorId != Constant.INT_IS_ZERO)
- {
- string errorAddress = "";
- switch (ErrorId)
- {
- case 1:
- this.txtBuildingNo.Focus();
- errorAddress = "楼号";
- break;
- case 2:
- this.txtFloorNo.Focus();
- errorAddress = "楼层";
- break;
- case 3:
- this.txtGroutingLineNo.Focus();
- errorAddress = "线号";
- break;
- case 4:
- this.txtGroutingLineCode.Focus();
- errorAddress = "成型线编码";
- break;
- case 5:
- this.txtGroutingLineName.Focus();
- errorAddress = "成型线名称";
- break;
- //case 7:
- // this.dkUser.Focus();
- // errorAddress = "工号";
- // break;
- case 8:
- this.scbGMouldType.Focus();
- errorAddress = "成型线类别";
- break;
- default:
- break;
- };
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- DataTable dtInfo = this.dgvDetail.DataSource as DataTable;
- if (dtInfo.Rows.Count == Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具信息"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- DataTable dtUser = this.dgvUser.DataSource as DataTable;
- dtUser.TableName = "dtUser";
- dtUser.AcceptChanges();
- if (dtUser.Rows.Count == Constant.INT_IS_ZERO)
- {
- /* 成型线可以不绑定成型工号 chenxy 2019-10-08
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型工号"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.tabControl1.SelectTab(0);
- return;
- */
- }
- else
- {
- DataRow[] dr = dtUser.Select("UserName='' or UserName is null");
- if (dr.Length > 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型工号"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.tabControl1.SelectTab(0);
- return;
- }
- }
- //更新注浆次数
- DataTable dtDetail = this.dgvDetail.DataSource as DataTable;
- dtDetail.TableName = "dtDetail";
- GroutingLineEntity ginfo = new GroutingLineEntity();
- ginfo.BUILDINGNO = this.txtBuildingNo.Text.Trim();
- ginfo.FLOORNO = this.txtFloorNo.Text.Trim();
- ginfo.GROUTINGLINENO = this.txtGroutingLineNo.Text.Trim();
- ginfo.GROUTINGLINECODE = this.txtGroutingLineCode.Text.Trim();
- ginfo.GROUTINGLINENAME = this.txtGroutingLineName.Text.Trim();
- ginfo.REMARKS = this.txtRemarks.Text.Trim();
- //ginfo.USERID = this.dkUser.UserID;
- if (dtUser.Rows.Count > 0)
- {
- ginfo.USERID = Convert.ToInt32(dtUser.Rows[0]["UserID"]);
- }
- else
- {
- ginfo.USERID = null;
- }
- //xuwei add 2019-11-13 高压注浆
- ginfo.HIGHPRESSUREFLAG = HighPressureFlag.Checked ? 1 : 0;
- //xuwei end
- ginfo.MOULDTYPEID = this.scbGMouldType.SearchedPKMember;
- ginfo.MouldStatus = Convert.ToInt32(Constant.GMouldStatus.Normal);
- ginfo.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Effective);
- ginfo.MOULDQUANTITY = dtDetail.Rows.Count;//this._addDetailList.Count;
- if (this.scbUser1.SearchedValue != null)
- {
- ginfo.MonitorID = Convert.ToInt32(this.scbUser1.SearchedValue);
- ginfo.MonitorCode = this.scbUser1.SearchedItem["Usercode"]+"";
- }
- this._addDetailUserList.Clear();
- //for (int i = 0; i < dtDetail.Rows.Count; i++)
- //{
- // _addDetailList[i].GROUTINGCOUNT = Convert.ToDecimal(dtDetail.Rows[i]["GROUTINGCOUNT"]);
- //}
- //foreach (DataRow r in dtUser.Rows)
- //{
- // GroutingLineUserEntity entity = new GroutingLineUserEntity();
- // entity.USERID = Convert.ToInt32(r["USERID"]);
- // entity.REMARK = r["REMARK"].ToString();
- // this._addDetailUserList.Add(entity);
- //}
- //DataTable dt = this.dgvDetail.DataSource as DataTable;
- //if (dt != null)
- //{
- // for (int i = 0; i < dt.Rows.Count; i++)
- // {
- // this._addDetailList[i].REMARKS = dt.Rows[i]["Remarks"].ToString();
- // }
- //}
- ServiceResultEntity myReturn = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- //return PCModuleProxy.Service.AddGroutingLine_New(ginfo, this._addDetailList, this._addDetailUserList);
- return PCModuleProxy.Service.AddGroutingLine_NewLine(ginfo, dtDetail, dtUser);
- }));
- if (myReturn != null)
- {
- if (myReturn.Status == Constant.ServiceResultStatus.Success)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成型线信息", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- else if (myReturn.OtherStatus == -50)
- {
- MessageBox.Show("成型线编码已存在,请重新输入!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else if (myReturn.OtherStatus == -2)
- {
- MessageBox.Show(Messages.MSG_CMN_W029,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- 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>
- private void txtBuildingNo_TextChanged(object sender, EventArgs e)
- {
- this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- this.txtGroutingLineName.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- }
- /// <summary>
- /// 编号变更
- /// </summary>
- private void txtFloorNo_TextChanged(object sender, EventArgs e)
- {
- this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- this.txtGroutingLineName.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- }
- /// <summary>
- /// 编号变更
- /// </summary>
- private void txtGroutingLineNo_TextChanged(object sender, EventArgs e)
- {
- this.txtGroutingLineCode.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- this.txtGroutingLineName.Text = this.txtBuildingNo.Text + this.txtFloorNo.Text.PadLeft(2, '0')
- + this.txtGroutingLineNo.Text.Trim();
- }
- /// <summary>
- /// 成型线文本改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtGroutingLineCode_TextChanged(object sender, EventArgs e)
- {
- if (this._addDetailList.Count != Constant.INT_IS_ZERO)
- {
- MessageBox.Show("成型线编码变更后,需重新生成模具信息!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this._addDetailList.Clear();
- this._mouldCount = 0;
- this.dgvDetail.DataSource = null;
- }
- }
- /// <summary>
- /// 成型工号开始编辑事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- try
- {
- if (this.dgvUser.Rows.Count <= 1)
- {
- return;
- }
- DataGridViewColumn columnItem = this.dgvUser.Columns[e.ColumnIndex];
- if ("UserCode".Equals(columnItem.Name))
- {
- _userCodeValue = this.dgvUser.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
- }
- }
- 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 dgvUser_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvUser.Rows.Count <= 1 || !_ShowFlag)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvUser.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvUser.Columns[e.ColumnIndex];
- // 用编号获取产品信息
- if ("UserCode".Equals(columnItem.Name))
- {
- _ShowFlag = false;
- FormUtility.BindUserRowDataSource(this.dgvUser,
- e.RowIndex, columnItem.Name, _userCodeValue);
- // 设置可输入单元格的颜色
- this.dgvUser.IsSetInputColumnsColor = true;
- }
- _ShowFlag = true;
- }
- catch (Exception ex)
- {
- //_ShowFlag = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0102_1_1_Load(object sender, EventArgs e)
- {
- // dgvDetail.IsSetInputColumnsColor = true;
- //dgvUser.IsSetInputColumnsColor = true;
- //窗体加载模具数据源
- this.dgvDetail.AutoGenerateColumns = false;
- DataTable dtGroutingInfo = new DataTable();
- dtGroutingInfo.Columns.Add("MouldSource");
- dtGroutingInfo.Columns.Add("MOULDID", typeof(int));
- dtGroutingInfo.Columns.Add("MOULDBarcode");
- dtGroutingInfo.Columns.Add("MOULDCODE");
- dtGroutingInfo.Columns.Add("GOODSID", typeof(int));
- dtGroutingInfo.Columns.Add("GOODSNAME");
- dtGroutingInfo.Columns.Add("GOODSCODE");
- dtGroutingInfo.Columns.Add("GoodsSpecification");
- dtGroutingInfo.Columns.Add("GROUTINGCOUNT", typeof(int));
- dtGroutingInfo.Columns.Add("StandardGroutingCount", typeof(int));
- dtGroutingInfo.Columns.Add("MOULDSTATUS", typeof(int));
- dtGroutingInfo.Columns.Add("REMARKS");
- dtGroutingInfo.Columns.Add("VALUEFLAG");
- dtGroutingInfo.Columns.Add("GroutingMouldCode");
- dtGroutingInfo.Columns.Add("MouldOutputNo", typeof(int));
- dtGroutingInfo.DefaultView.Sort = "GroutingMouldCode";
- dtGroutingInfo.Columns["GroutingMouldCode"].Unique = true;
- this.dgvDetail.DataSource = dtGroutingInfo;
- DataSet dsSetting = SystemModuleProxy.Service.GetSystemSettingDataByCode(Constant.SettingType.S_PC_001.ToString());
- if (dsSetting != null && dsSetting.Tables[0].Rows.Count > 0)
- {
- string flag = dsSetting.Tables[0].Rows[0]["SettingValue"].ToString();
- if (flag == "2")
- {
- this.rabBinding.Checked = true;
- this.rabAuto.Enabled = false;
- }
- else if (flag == "1")
- {
- this.rabBinding.Checked = true;
- }
- else
- {
- this.rabAuto.Checked = true;
- }
- }
- }
- /// <summary>
- /// 窗体加载后显示事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_0102_1_1_Shown(object sender, EventArgs e)
- {
- //dgvDetail.IsSetInputColumnsColor = true;
- dgvUser.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 工号排序事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_Sorted(object sender, EventArgs e)
- {
- this.dgvUser.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 窗口切换事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
- {
- //dgvDetail.IsSetInputColumnsColor = true;
- this.dgvUser.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 行绘制前,控制Cell只读
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
- {
- if (this.dgvDetail.ReadOnly || e.RowIndex < 0)
- {
- return;
- }
- try
- {
- if (string.IsNullOrEmpty(dgvDetail.Rows[e.RowIndex].Cells["MouldID"].Value + ""))
- {
- // 自动生成模具
- this.dgvDetail.Rows[e.RowIndex].Cells["GroutingCount"].ReadOnly = false;
- this.dgvDetail.Rows[e.RowIndex].Cells["StandardGroutingCount"].ReadOnly = false;
- //this.dgvDetail.Rows[e.RowIndex].Cells["GroutingCount"].Style.BackColor
- // = ColorTranslator.FromHtml(ControlsConst.ALLOW_MODIFY_AREA_BACKGROUND_COLOR);
- //this.dgvDetail.Rows[e.RowIndex].Cells["StandardGroutingCount"].Style.BackColor
- // = ColorTranslator.FromHtml(ControlsConst.ALLOW_MODIFY_AREA_BACKGROUND_COLOR);
- }
- else
- {
- // 模具档案
- this.dgvDetail.Rows[e.RowIndex].Cells["GroutingCount"].ReadOnly = true;
- this.dgvDetail.Rows[e.RowIndex].Cells["StandardGroutingCount"].ReadOnly = true;
- //this.dgvDetail.Rows[e.RowIndex].Cells["GroutingCount"].Style.BackColor
- // = Color.White;
- //this.dgvDetail.Rows[e.RowIndex].Cells["StandardGroutingCount"].Style.BackColor
- //= Color.White;
- }
- foreach (DataGridViewColumn item in dgvDetail.Columns)
- {
- if (!item.Visible)
- {
- continue;
- }
- if (item.ReadOnly || this.dgvDetail.Rows[e.RowIndex].Cells[item.Index].ReadOnly)
- {
- this.dgvDetail.Rows[e.RowIndex].Cells[item.Index].Style.BackColor
- = Color.White;
- }
- else
- {
- this.dgvDetail.Rows[e.RowIndex].Cells[item.Index].Style.BackColor
- = ColorTranslator.FromHtml(ControlsConst.ALLOW_MODIFY_AREA_BACKGROUND_COLOR);
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 编辑前,控制Cell只读
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvDetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
- {
- try
- {
- }
- catch (Exception ex)
- {
- //_ShowFlag = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 切换模具来源
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rabAuto_CheckedChanged(object sender, EventArgs e)
- {
- this.pnlAuto.Enabled = this.rabAuto.Checked;
- this.pnlBinding.Enabled = this.rabBinding.Checked;
- }
- /// <summary>
- /// 验证模具号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtGMouldCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (this.txtGMouldCode.Text == "" || this.dgvDetail.Rows.Count == 0)
- {
- return;
- }
- try
- {
- string gMouldCode = this.txtGroutingLineCode.Text + "-" + this.txtGMouldCode.DataValue.Value.ToString().PadLeft(3, '0');
- DataTable dtInfo = this.dgvDetail.DataSource as DataTable;
- DataRow[] dr = dtInfo.Select("GroutingMouldCode='" + gMouldCode + "'");
- if (dr.Length > 0)
- {
- MessageBox.Show("存在相同的模具编号", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- e.Cancel = true;
- return;
- };
- }
- catch (Exception ex)
- {
- //_ShowFlag = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 验证模具条码
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- {
- this.btnAddMouldBarcode_Click(null, null);
- }
- }
- /// <summary>
- /// 添加模具
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAddMouldBarcode_Click(object sender, EventArgs e)
- {
- if (this.txtGroutingLineCode.Text == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型线编码"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.txtGMouldCode.Text == "")
- {
- MessageBox.Show("没有设定模具号", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtGMouldCode.Focus();
- return;
- }
- string barcode = this.txtBarcode.Text.Trim();
- if (barcode == "")
- {
- MessageBox.Show("没有输入模具条码", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- return;
- }
- try
- {
- string gMouldCode = this.txtGroutingLineCode.Text + "-" + this.txtGMouldCode.DataValue.Value.ToString().PadLeft(3, '0');
- DataTable dtInfo = this.dgvDetail.DataSource as DataTable;
- DataRow[] dr = dtInfo.Select("GroutingMouldCode='" + gMouldCode + "'");
- if (dr.Length > 0)
- {
- MessageBox.Show("存在相同的模具编号", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtGMouldCode.Focus();
- this.txtGMouldCode.SelectAll();
- return;
- };
- dr = dtInfo.Select("MouldBarcode = '" + barcode + "'");
- if (dr.Length > 0)
- {
- MessageBox.Show("存在相同的模具条码", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- };
- if (this._isMessageShow == false)
- {
- DialogResult msgBoxResult = MessageBox.Show("添加模具后,成型线编码相关信息不予许修改,是否继续。",
- this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (msgBoxResult == DialogResult.No)
- {
- return;
- }
- else
- {
- this.txtBuildingNo.ReadOnly = true;
- this.txtFloorNo.ReadOnly = true;
- this.txtGroutingLineNo.ReadOnly = true;
- }
- this._isMessageShow = true;
- }
- // 验证模具条码状态
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "PC_Mould";
- cre.Name = "GetMouldData";
- cre.Properties["MouldBarcode"] = barcode;
- ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
- if (sre == null || sre.Data == null || sre.Data.Tables.Count == 0 || sre.Data.Tables[0].Rows.Count == 0)
- {
- MessageBox.Show("无效模具条码", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- }
- DataRow item = sre.Data.Tables["InfoData"].Rows[0];
- int mouldStatus = Convert.ToInt32(item["MouldStatus"]);
- if (mouldStatus != 1 && mouldStatus != 3)
- {
- MessageBox.Show("此模具当前状态为【" + item["MouldStatusName"] + "】,不能添加到成型线。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- }
- int outputCount = Convert.ToInt32(item["OutputCount"]);
- if (outputCount == 1)
- {
- DataRow r = dtInfo.NewRow();
- r["GroutingMouldCode"] = gMouldCode;
- r["MouldSource"] = "1";
- r["MOULDID"] = item["MOULDID"];
- r["MOULDCODE"] = item["MOULDCODE"];
- r["MOULDBarcode"] = item["MOULDBarcode"];
- r["GOODSID"] = item["GOODSID"];
- r["GOODSNAME"] = item["GOODSNAME"];
- r["GOODSCODE"] = item["GOODSCODE"];
- r["GoodsSpecification"] = item["GoodsSpecification"];
- r["GROUTINGCOUNT"] = item["GroutingNums"];
- r["StandardGroutingCount"] = item["StandardGroutingNum"];
- r["MOULDSTATUS"] = Convert.ToInt32(Constant.GMouldStatus.Normal);
- //r["REMARKS"] = "";
- r["VALUEFLAG"] = "1";
- dtInfo.Rows.Add(r);
- }
- else
- {
- // 一模多产时,必须绑定连续成型模具编号。 add by chenxy 2018-10-29
- string minGMouldCode = gMouldCode;
- int minIndex = Convert.ToInt32(this.txtGMouldCode.DataValue.Value);
- string maxGMouldCode = this.txtGroutingLineCode.Text + "-" + (minIndex + outputCount).ToString("000");
- DataRow[] grows = dtInfo.Select("GroutingMouldCode>='" + minGMouldCode + "' and GroutingMouldCode<'" + maxGMouldCode + "'");
- if (grows.Length > 0)
- {
- MessageBox.Show("此模具的产出数量为【" + outputCount + "】,当前成型模具编号不能连续添加,不能添加到成型线。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- }
- //for (int i = 0; i < outputCount; i++)
- foreach (DataRow itemOutput in sre.Data.Tables["InfoData"].Rows)
- {
- DataRow r = dtInfo.NewRow();
- r["GroutingMouldCode"] = minGMouldCode;
- r["MouldSource"] = "1";
- r["MOULDID"] = item["MOULDID"];
- r["MOULDCODE"] = item["MOULDCODE"];
- r["MOULDBarcode"] = item["MOULDBarcode"];
- r["GOODSID"] = item["GOODSID"];
- r["GOODSNAME"] = item["GOODSNAME"];
- r["GOODSCODE"] = item["GOODSCODE"];
- r["GoodsSpecification"] = item["GoodsSpecification"];
- r["GROUTINGCOUNT"] = itemOutput["GroutingNum"];
- r["MouldOutputNo"] = itemOutput["OutputNo"];
- r["StandardGroutingCount"] = item["StandardGroutingNum"];
- r["MOULDSTATUS"] = Convert.ToInt32(Constant.GMouldStatus.Normal);
- //r["REMARKS"] = "";
- r["VALUEFLAG"] = "1";
- dtInfo.Rows.Add(r);
- minGMouldCode = this.txtGroutingLineCode.Text + "-" + (++minIndex).ToString("000");
- }
- }
- //foreach (DataGridViewRow row in dgvDetail.Rows)
- //{
- // if (string.IsNullOrEmpty(row.Cells["MouldID"].Value + ""))
- // {
- // // 自动生成模具
- // row.Cells["GroutingCount"].ReadOnly = false;
- // row.Cells["StandardGroutingCount"].ReadOnly = false;
- // }
- // else
- // {
- // // 模具档案
- // row.Cells["GroutingCount"].ReadOnly = true;
- // row.Cells["StandardGroutingCount"].ReadOnly = true;
- // }
- //}
- //this.dgvDetail.IsSetInputColumnsColor = true;
- //this.txtGMouldCode.DataValue = this.txtGMouldCode.DataValue.Value + 1;
- this.txtGMouldCode.DataValue = this.txtGMouldCode.DataValue.Value + outputCount;
- this.txtBarcode.Clear();
- this.txtBarcode.Focus();
- }
- catch (Exception ex)
- {
- //_ShowFlag = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 将实体数据转换为DataTable,绑定到控件中
- /// </summary>
- protected DataTable ListToTable()
- {
- try
- {
- DataTable dtDataSourse = new DataTable();
- dtDataSourse.Columns.Add("GROUTINGMOULDCODE", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GOODSNAME", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GoodsCode", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GoodsSpecification", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GOODSID", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("Remarks", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GROUTINGCOUNT", System.Type.GetType("System.String"));
- for (int i = 0; i < _addDetailList.Count; i++)
- {
- DataRow drRow = dtDataSourse.NewRow();
- drRow["GROUTINGMOULDCODE"] = _addDetailList[i].GROUTINGMOULDCODE;
- drRow["GOODSNAME"] = _addDetailList[i].GOODSNAME;
- drRow["GoodsCode"] = _addDetailList[i].GOODSCODE;
- drRow["GoodsSpecification"] = _addDetailList[i].GoodsSpecification;
- drRow["GOODSID"] = _addDetailList[i].GOODSID;
- drRow["Remarks"] = _addDetailList[i].REMARKS;
- drRow["GROUTINGCOUNT"] = _addDetailList[i].GROUTINGCOUNT;
- dtDataSourse.Rows.Add(drRow);
- }
- return dtDataSourse;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 验证添加项
- /// </summary>
- protected int ValidationText()
- {
- int ErrorId = 0;
- string txtBuildingNo = this.txtBuildingNo.Text.Trim();
- string txtFloorNo = this.txtFloorNo.Text.Trim();
- string txtGroutingLineNo = this.txtGroutingLineNo.Text.Trim();
- string txtGroutingLineCode = this.txtGroutingLineCode.Text.Trim();
- string txtGroutingLineName = this.txtGroutingLineName.Text.Trim();
- string txtRemarks = this.txtRemarks.Text.Trim();
- if (txtBuildingNo == string.Empty)
- {
- ErrorId = 1;
- return ErrorId;
- }
- if (txtFloorNo == string.Empty)
- {
- ErrorId = 2;
- return ErrorId;
- }
- if (txtGroutingLineNo == string.Empty)
- {
- ErrorId = 3;
- return ErrorId;
- }
- if (txtGroutingLineCode == string.Empty)
- {
- ErrorId = 4;
- return ErrorId;
- }
- if (txtGroutingLineName == string.Empty)
- {
- ErrorId = 5;
- return ErrorId;
- }
- //if (dkUser.UserID == null)
- //{
- // ErrorId = 7;
- // return ErrorId;
- //}
- if (scbGMouldType.SearchedPKMember == 0)
- {
- ErrorId = 8;
- return ErrorId;
- }
- return ErrorId;
- }
- #endregion
- }
- }
|