| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092 |
- /*******************************************************************************
- * 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.Client.DataModels;
- 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().ToUpper();
- //// 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().ToUpper();
- r["GOODSID"] = scbGoods.SearchedPKMember;
- r["GOODSNAME"] = scbGoods.SearchedItem["GOODSNAME"];
- r["GOODSCODE"] = scbGoods.SearchedItem["GOODSCODE"];
- r["GoodsSpecification"] = scbGoods.SearchedItem["GOODSSPECIFICATION"];
- r["GROUTINGCOUNT"] = Convert.ToInt32(this.txtGroutingCount.DataValue ?? 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;
- }
- if (LogInUserInfo.CurrentUser.CurrentUserEntity.AccountCode == "imex" &&
- this.scbUser1.SearchedValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型班长"),
- 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
- }
- }
|