| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0103_1.cs
- * 2.功能描述:编辑成型线信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/09/25 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Text;
- 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_0103_1 : FormBase
- {
- #region 成员变量
- //当前编辑成型线ID
- private int _groutingLineId;
- //当前编辑成型线实体
- private GroutingLineEntity _lineEntity = new GroutingLineEntity();
- //当前编辑成型线明细集合
- private List<GroutingLineDetailEntity> _detailList = new List<GroutingLineDetailEntity>();
- //当前编辑成型线新增明细集合
- private List<GroutingLineDetailEntity> _AddDetailList = new List<GroutingLineDetailEntity>();
- //需要添加的成型工号明细集合
- public List<GroutingLineUserEntity> _addDetailUserList = new List<GroutingLineUserEntity>();
- //模具总数量
- private int _mouldCount = 0;
- //修改前成型线编号
- private string _lineCode = "";
- //范围权限
- private string _purview;
- private string _userCodeValue;
- private bool _ShowFlag = true;
- //默认条数
- private int defaultRow = 0;
- /// <summary>
- /// 模具操作状态
- /// </summary>
- private int _gmouldstatus = 0;
- /// <summary>
- /// 整线变产原数据
- /// </summary>
- private DataTable _oldDetail = null;
- #endregion
- #region 构造函数
- /// <summary>
- /// 编辑成型线窗体构造
- /// </summary>
- public F_PC_0103_1(int GroutingLineId)
- {
- InitializeComponent();
- this._groutingLineId = GroutingLineId;
- this.Text = FormTitles.F_PC_0103;
- 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.scbUser1.DisplayMember = "USERNAMECode";
- this.scbUser1.ValueMember = "UserID";
- 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;
- }
- /// <summary>
- /// 模具操作
- /// </summary>
- /// <param name="GroutingLineId"></param>
- /// <param name="GMouldStatus">0:上模,4:结束变产</param>
- public F_PC_0103_1(int GroutingLineId, int GMouldStatus)
- : this(GroutingLineId)
- {
- this._gmouldstatus = GMouldStatus;
- this.tabControl1.SelectedIndex = 1;
- this.dgvUser.AllowUserToAddRows = false;
- this.dgvUser.ReadOnly = true;
- this.c_GroupBox1.Enabled = false;
- this.scbUser1.DisplayMember = "USERNAMECode";
- this.scbUser1.ValueMember = "UserID";
- if (this._gmouldstatus == 0)
- {
- this.Text = "模具管理-上模";
- }
- if (this._gmouldstatus == 4)
- {
- this.Text = "模具管理-结束整线变产";
- }
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载
- /// </summary>
- private void F_PC_0103_Load(object sender, EventArgs e)
- {
- try
- {
- this.dgvUser.AutoGenerateColumns = false;
- this.dgvDetail.AutoGenerateColumns = false;
- this.BindGrouting();
- //_groutingLineId
- ////DataSet dsUserList = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- ////{
- //// return PCModuleProxy.Service.GetGroutingLineUserDetailByMainId(_groutingLineId);
- ////}));
- DataSet dsUserList = PCModuleProxy.Service.GetGroutingLineUserDetailByMainId(_groutingLineId);
- if (dsUserList != null && dsUserList.Tables.Count > 0)
- {
- this.dgvUser.DataSource = dsUserList.Tables[0];
- dsUserList.Tables[0].Columns["userid"].Unique = true;
- }
- 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;
- }
- }
- }
- 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 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;
- }
- //this._lineEntity.BUILDINGNO = this.txtBuildingNo.Text.Trim();
- //this._lineEntity.FLOORNO = this.txtFloorNo.Text.Trim();
- //this._lineEntity.GROUTINGLINENO = this.txtGroutingLineNo.Text.Trim();
- this._lineEntity.GROUTINGLINECODE = this.txtGroutingLineCode.Text.Trim();
- this._lineEntity.GROUTINGLINENAME = this.txtGroutingLineName.Text.Trim();
- this._lineEntity.REMARKS = this.txtRemarks.Text.Trim();
- //xuwei add 2019-11-13 高压注浆
- this._lineEntity.HIGHPRESSUREFLAG = HighPressureFlag.Checked ? 1 : 0;
- //xuwei end
- //this._lineEntity.USERID = this.dkUser.UserID;
- this._lineEntity.MOULDTYPEID = this.scbGMouldType.SearchedPKMember;
- if (this.scbUser1.SearchedItem != null)
- {
- this._lineEntity.MonitorID = Convert.ToInt32(this.scbUser1.SearchedValue);
- this._lineEntity.MonitorCode = this.scbUser1.SearchedItem["Usercode"] + "";
- }
- else if(this.scbUser1.ValueFrom == WinForm.Controls.SearchBoxValueFrom.InitValue)
- {
- //this._lineEntity.MonitorID = Convert.ToInt32(this.scbUser1.SearchedValue);
- //this._lineEntity.MonitorCode = this.scbUser1.InitItems[0] + "";
- }
- else
- {
- this._lineEntity.MonitorID = null;
- this._lineEntity.MonitorCode = null;
- }
- //this._lineEntity.CANMANYTIMES = this.dkType.IsCanManyTimes;
- //this._lineEntity.MOULDQUANTITY = _detailList.Count + _AddDetailList.Count;
- this._lineEntity.MOULDQUANTITY = this.dgvDetail.RowCount;
- //if (this.cbValueFlag.Checked == false)
- //{
- // this._lineEntity.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Invalid);
- //}
- //else
- //{
- // this._lineEntity.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Effective);
- //}
- if (this.chkEnable.Checked)
- {
- this._lineEntity.ValueFlag2 = "1";
- }
- else
- {
- this._lineEntity.ValueFlag2 = "2";
- }
- if (this._lineCode != this._lineEntity.GROUTINGLINECODE)
- {
- bool isHaveGroutingLineCode = (bool)DoAsync(new BaseAsyncMethod(() =>
- {
- return PCModuleProxy.Service.GroutingLineCodeIsRepeat(this.txtGroutingLineCode.Text);
- }));
- if (isHaveGroutingLineCode == false)
- {
- 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();
- //this._addDetailUserList.Clear();
- //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);
- //}
- 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;
- }
- }
- if (dtUser.Rows.Count > 0)
- {
- _lineEntity.USERID = Convert.ToInt32(dtUser.Rows[0]["UserID"]);
- }
- else
- {
- _lineEntity.USERID = null;
- }
- //更新注浆次数
- DataTable dtDetail = this.dgvDetail.DataSource as DataTable;
- //if (dtDetail == null || dtDetail.Rows.Count == Constant.INT_IS_ZERO)
- //{
- // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具信息"), this.Text,
- // MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // return;
- //}
- DataTable dt1 = null;
- DataRow[] drNewFlag_Zero = dtDetail.Select("NewFlag=0");
- if (drNewFlag_Zero.Length > 0)
- {
- dt1 = drNewFlag_Zero.CopyToDataTable();
- dt1.TableName = "dt1";
- }
- DataTable dt2 = null;
- DataRow[] drNewFlag_One = dtDetail.Select("NewFlag=1");
- if (drNewFlag_One.Length > 0)
- {
- dt2 = drNewFlag_One.CopyToDataTable();
- dt2.TableName = "dt2";
- }
- //for (int i = 0; i < _AddDetailList.Count; i++)
- //{
- // _AddDetailList[i].GROUTINGCOUNT = Convert.ToDecimal(dtDetail.Rows[defaultRow + i]["GROUTINGCOUNT"]);
- // _AddDetailList[i].REMARKS = dtDetail.Rows[defaultRow + i]["REMARKS"].ToString();
- //}
- //DataTable dt = this.dgvDetail1.DataSource as DataTable;
- //if (dt != null)
- //{
- //for (int i = 0; i < _detailList.Count; i++)
- //{
- // this._detailList[i].REMARKS = dtDetail.Rows[i]["Remarks"].ToString();
- //}
- //}
- if (!this.c_GroupBox1.Enabled)
- {
- // 上摸 或 整线变产
- _lineEntity.GROUTINGLINEIDS = "0";
- }
- ServiceResultEntity myReturn = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- if (this._gmouldstatus != 4)
- {
- return PCModuleProxy.Service.UpdateGroutingLine_NewLine(_lineEntity, dt2, dtUser, dt1);
- }
- else
- {
- // 整线变产
- return PCModuleProxy.Service.UpdateAllLineEndGroutingLineDetail(dt2, _oldDetail, this._lineEntity.GROUTINGLINEID.Value, this._lineEntity.OPTIMESTAMP);
- }
- }));
- 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;
- return;
- }
- else if (myReturn.OtherStatus == -500)
- {
- MessageBox.Show(Messages.MSG_CMN_W012, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.Close();
- }
- else if (myReturn.OtherStatus == -2)
- {
- MessageBox.Show(Messages.MSG_CMN_W029,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show(myReturn.Message,
- 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 btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <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>
- private void btnDeleteSelected_Click(object sender, EventArgs e)
- {
- try
- {
- DataRowView drv = this.dgvDetail.CurrentRow.DataBoundItem as DataRowView;
- if (drv == null)
- {
- return;
- }
- if (Convert.ToInt32(drv["NewFlag"]) == 1)
- {
- ////DataTable dt = drv.Row.Table;
- //drv.Delete();
- ////dt.AcceptChanges();
- // 一模多产时,同一模具一同清除。 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();
- }
- }
- else
- {
- MessageBox.Show(Messages.MSG_PC_W002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- //DataTable dt = this.dgvDetail.DataSource as DataTable;
- //dt.Rows[currentRow.Index].Delete();
- //dt.AcceptChanges();
- //this.dgvDetail.DataSource = dt;// ListToTable();
- //this.dgvDetail1.DataSource = this.ListToTable();
- //this.dgvUser.IsSetInputColumnsColor = true;
- //this.dgvDetail.IsSetInputColumnsColor = true;
- // 重置哪个单元格是只读
- //foreach (DataGridViewRow row in this.dgvDetail.Rows)
- //{
- // //遍历以前模具编号
- // for (int i = 0; i < this._detailList.Count; i++)
- // {
- // if (row.Cells["GroutingMouldCode"].Value.ToString() == _detailList[i].GROUTINGMOULDCODE)
- // {
- // row.Cells["GROUTINGCOUNT"].ReadOnly = true;
- // break;
- // }
- // else
- // {
- // row.Cells["GROUTINGCOUNT"].ReadOnly = false;
- // }
- // }
- //}
- //this.dgvDetail.IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <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 (this.txtCount.Text == "")
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具数量"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.txtStandardGroutingCount.Text == "")
- {
- 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;
- //}
- //for (int i = 0; i < Convert.ToInt32(this.txtCount.Text); i++)
- //{
- // int GroutingMouldCodeNum = i + _mouldCount;
- // GroutingLineDetailEntity detailInfo = new GroutingLineDetailEntity();
- // detailInfo.GROUTINGMOULDCODE = this.txtGroutingLineCode.Text + "-" + (GroutingMouldCodeNum + 1).ToString().PadLeft(3, '0');
- // 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);
- //}
- 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();
- 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;
- };
- //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);
- 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"] = Convert.ToInt32(this.txtGroutingCount.DataValue ?? 0);
- r["StandardGroutingCount"] = Convert.ToInt32(this.txtStandardGroutingCount.DataValue.Value);
- //r["MOULDSTATUS"] = Convert.ToInt32(Constant.GMouldStatus.Normal);
- //r["REMARKS"] = "";
- r["NewFlag"] = 1;
- r["VALUEFLAG"] = 1;
- dtInfo.Rows.Add(r);
- BeginNum = BeginNum + 1;
- }
- if (isError)
- {
- BeginNum = Convert.ToInt32(this.txtBeginNum.Text);
- //有错误
- MessageBox.Show("存在相同的模具编号");
- return;
- }
- else
- {
- this.txtBeginNum.DataValue = BeginNum;
- }
- this._mouldCount += Convert.ToInt32(this.txtCount.Text);
- //this.dgvDetail.AutoGenerateColumns = false;
- //this.dgvDetail1.DataSource = ListToTable();
- // 重置哪个单元格是只读
- //foreach (DataGridViewRow row in this.dgvDetail.Rows)
- //{
- // //遍历以前模具编号
- // for (int i = 0; i < this._detailList.Count; i++)
- // {
- // if (row.Cells["GroutingMouldCode"].Value.ToString() == _detailList[i].GROUTINGMOULDCODE)
- // {
- // row.Cells["GROUTINGCOUNT"].ReadOnly = true;
- // break;
- // }
- // else
- // {
- // row.Cells["GROUTINGCOUNT"].ReadOnly = false;
- // }
- // }
- //}
- //this.dgvDetail.IsSetInputColumnsColor = true;
- }
- 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_0103_1_Shown(object sender, EventArgs e)
- {
- //dgvDetail.IsSetInputColumnsColor = true;
- 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>
- /// 工号排序事件
- /// </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 dgvDetail1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
- {
- if (this.dgvDetail.ReadOnly || e.RowIndex < 0)
- {
- return;
- }
- try
- {
- //e.InheritedRowStyle.BackColor = Color.White;
- if (!string.IsNullOrEmpty(dgvDetail.Rows[e.RowIndex].Cells["MouldID"].Value + ""))
- {
- // 模具档案
- 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;
- }
- else if (dgvDetail.Rows[e.RowIndex].Cells["NewFlag"].Value + "" == "0")
- {
- // 自动生成模具
- this.dgvDetail.Rows[e.RowIndex].Cells["GroutingCount"].ReadOnly = true;
- 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
- // = Color.White;
- }
- else
- {
- // 新加模具
- 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);
- }
- 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>
- /// 自适应列宽
- /// </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>
- /// <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;
- }
- // 模具ID存在 是正常状态的成型模具
- dr = dtInfo.Select("MouldID is not null and MouldBarcode = '" + barcode + "'");
- if (dr.Length > 0)
- {
- MessageBox.Show("存在相同的模具条码", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- };
- // 验证模具条码状态
- 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;
- }
- //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["GroutingNum"];
- //r["StandardGroutingCount"] = item["StandardGroutingNum"];
- ////r["MOULDSTATUS"] = Convert.ToInt32(Constant.GMouldStatus.Normal);
- ////r["REMARKS"] = "";
- //r["VALUEFLAG"] = "1";
- //r["NEWFLAG"] = "1";
- //dtInfo.Rows.Add(r);
- 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";
- r["NEWFLAG"] = "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";
- r["NEWFLAG"] = "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>
- /// 加载成型线数据
- /// </summary>
- private void BindGrouting()
- {
- try
- {
- //首先绑定成型线基础信息
- GroutingLineEntity ginfo = new GroutingLineEntity();
- ginfo.GROUTINGLINEID = _groutingLineId;
- ginfo.ValueFlag2 = "A";
- //DataSet dsGroutingLine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PCModuleProxy.Service.GetGroutingLine(ginfo);
- //}));
- DataSet dsGroutingLine = PCModuleProxy.Service.GetGroutingLine(ginfo);
- if (dsGroutingLine.Tables[0].Rows.Count != Constant.INT_IS_ZERO)
- {
- //给实体绑定值
- BindGroutingEntity(dsGroutingLine.Tables[0].Rows[0]);
- //将实体值绑定给界面控件
- //this.txtBuildingNo.Text = _lineEntity.BUILDINGNO;
- //this.txtFloorNo.Text = _lineEntity.FLOORNO;
- //this.txtGroutingLineNo.Text = _lineEntity.GROUTINGLINENO;
- this.txtGroutingLineCode.Text = _lineEntity.GROUTINGLINECODE;
- this.txtGroutingLineName.Text = _lineEntity.GROUTINGLINENAME;
- this.txtRemarks.Text = _lineEntity.REMARKS;
- //this.dkUser.UserID = _lineEntity.USERID;
- //this.dkUser.UserName = dsGroutingLine.Tables[0].Rows[0]["UserName"].ToString();
- //this.dkUser.UserCode = dsGroutingLine.Tables[0].Rows[0]["UserCode"].ToString();
- //this.dkUser.Text = dsGroutingLine.Tables[0].Rows[0]["UserCode"].ToString();
- //this.dkType.MouldTypeID = _lineEntity.MOULDTYPEID;
- //this.dkType.MouldTypeName = dsGroutingLine.Tables[0].Rows[0]["GMouldTypeName"].ToString();
- //this.dkType.Text = dsGroutingLine.Tables[0].Rows[0]["GMouldTypeName"].ToString();
- this.scbGMouldType.CheckedData = dsGroutingLine.Tables[0];
- this.scbGMouldType.Text = dsGroutingLine.Tables[0].Rows[0]["GMouldTypeName"] + "";
- this.scbUser1.InitValue(_lineEntity.MonitorNameCode, _lineEntity.MonitorID, _lineEntity.MonitorCode);
- //xuwei add 2019-11-13 高压注浆
- this.HighPressureFlag.Checked = this._lineEntity.HIGHPRESSUREFLAG == 1 ? true : false;
- //xuwei end
- if (this._lineEntity.ValueFlag2 == "1")
- {
- this.chkEnable.Checked = true;
- }
- else
- {
- this.chkEnable.Checked = false;
- }
- this._lineCode = _lineEntity.GROUTINGLINECODE;
- // 变产的成型线不能添加模具 begin
- if (this._gmouldstatus == 0 &&
- "4" == dsGroutingLine.Tables[0].Rows[0]["GMOULDSTATUS"].ToString())
- {
- this.panel1.Visible = false;
- this.lblGStatus.Visible = true;
- }
- // 变产的成型线不能添加模具 end
- }
- //然后绑定该成型线所属的明细信息
- BindDetailInfo(_groutingLineId);
- foreach (DataGridViewRow row in this.dgvDetail.Rows)
- {
- row.Cells["GROUTINGCOUNT"].ReadOnly = true;
- }
- this.dgvDetail.IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 将DataRow转换为实体
- /// </summary>
- private void BindGroutingEntity(DataRow drGrouting)
- {
- try
- {
- this._lineEntity.GROUTINGLINEID = Convert.ToInt32(drGrouting["GROUTINGLINEID"]);
- this._lineEntity.BUILDINGNO = drGrouting["BUILDINGNO"].ToString();
- this._lineEntity.FLOORNO = drGrouting["FLOORNO"].ToString();
- this._lineEntity.GROUTINGLINENO = drGrouting["GROUTINGLINENO"].ToString();
- this._lineEntity.GROUTINGLINECODE = drGrouting["GROUTINGLINECODE"].ToString();
- this._lineEntity.GROUTINGLINENAME = drGrouting["GROUTINGLINENAME"].ToString();
- //xuwei add 2019-11-13
- this._lineEntity.HIGHPRESSUREFLAG = Convert.ToInt32(drGrouting["HIGHPRESSUREFLAG"]);
- //xuwei end
- this._lineEntity.MOULDQUANTITY = Convert.ToDecimal(drGrouting["MOULDQUANTITY"]);
- this._lineEntity.MOULDTYPEID = Convert.ToInt32(drGrouting["GMOULDTYPEID"]);
- if (drGrouting["USERID"] != null && drGrouting["USERID"] != DBNull.Value)
- {
- this._lineEntity.USERID = Convert.ToInt32(drGrouting["USERID"]);
- }
- object mid = drGrouting["MonitorID"];
- if (mid != null && mid != DBNull.Value)
- {
- this._lineEntity.MonitorID = Convert.ToInt32(mid);
- }
- this._lineEntity.MonitorCode = drGrouting["MonitorCode"]+"";
- this._lineEntity.MonitorNameCode = drGrouting["MonitorNameCode"] + "";
- this._lineEntity.BEGINUSEDDATE = Convert.ToDateTime(drGrouting["BEGINUSEDDATE"]);
- if (drGrouting["ENDUSEDDATE"].ToString() != string.Empty && drGrouting["ENDUSEDDATE"] != DBNull.Value)
- {
- this._lineEntity.ENDUSEDDATE = Convert.ToDateTime(drGrouting["ENDUSEDDATE"]);
- }
- this._lineEntity.MouldStatus = Convert.ToInt32(drGrouting["GMouldStatus"]);
- if (drGrouting["REMARKS"].ToString() != string.Empty && drGrouting["REMARKS"] != DBNull.Value)
- {
- this._lineEntity.REMARKS = drGrouting["REMARKS"].ToString();
- }
- this._lineEntity.ACCOUNTID = Convert.ToInt32(drGrouting["ACCOUNTID"]);
- this._lineEntity.VALUEFLAG = Convert.ToInt32(drGrouting["VALUEFLAG"]);
- this._lineEntity.ValueFlag2 = drGrouting["VALUEFLAG2"].ToString();
- this._lineEntity.CREATETIME = Convert.ToDateTime(drGrouting["CREATETIME"]);
- this._lineEntity.CREATEUSERID = Convert.ToInt32(drGrouting["CREATEUSERID"]);
- this._lineEntity.UPDATETIME = Convert.ToDateTime(drGrouting["UPDATETIME"]);
- this._lineEntity.UPDATEUSERID = Convert.ToInt32(drGrouting["UPDATEUSERID"]);
- this._lineEntity.OPTIMESTAMP = Convert.ToDateTime(drGrouting["OPTIMESTAMP"]);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 根据成型线ID绑定该成型线所属成型线模具信息
- /// </summary>
- private void BindDetailInfo(int GroutingLineID)
- {
- try
- {
- //this.dgvDetail.AutoGenerateColumns = false;
- //this.dgvDetail.IsSetInputColumnsColor = true;
- //DataSet dsDetail = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- //{
- // return PCModuleProxy.Service.GetGroutingLineDetailByMainId(GroutingLineID, null, 0);
- //}));
- DataSet dsDetail = PCModuleProxy.Service.GetGroutingLineDetailByMainId(GroutingLineID, null, 0);
- //this.DataTableToListByDetail(dsDetail);
- DataColumn newFlag = new DataColumn("NewFlag", typeof(int));
- newFlag.DefaultValue = 0;
- dsDetail.Tables[0].Columns.Add(newFlag);
- dsDetail.Tables[0].DefaultView.Sort = "GroutingMouldCode";
- // 结束变产操作删除变产前模具
- if (this._gmouldstatus == 4)
- {
- _oldDetail = dsDetail.Tables[0].Copy();
- foreach (DataRow item in dsDetail.Tables[0].Rows)
- {
- item.Delete();
- }
- dsDetail.Tables[0].AcceptChanges();
- }
- DataView dv = dsDetail.Tables[0].DefaultView;
- if (dv.Count > 0)
- {
- string groutingMouldCode = dv[dv.Count - 1]["GroutingMouldCode"].ToString();
- int lineIndexOf = groutingMouldCode.LastIndexOf("-") + 1;
- this._mouldCount = Convert.ToInt32(groutingMouldCode.Substring(lineIndexOf));
- }
- this.dgvDetail.AutoGenerateColumns = false;
- this.dgvDetail.DataSource = dsDetail.Tables[0];
- dsDetail.Tables[0].Columns["GroutingMouldCode"].Unique = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 将成型线明细DataSet数据集转换为实体集合
- /// </summary>
- private void DataTableToListByDetail(DataSet dsDetail)
- {
- try
- {
- this._detailList.Clear();
- defaultRow = dsDetail.Tables[0].Rows.Count;
- foreach (DataRow drFor in dsDetail.Tables[0].Rows)
- {
- if (drFor["ValueFlag"].ToString() == "1")
- {
- GroutingLineDetailEntity detailEntity = new GroutingLineDetailEntity();
- detailEntity.GROUTINGLINEDETAILID = Convert.ToInt32(drFor["GROUTINGLINEDETAILID"]);
- detailEntity.GROUTINGLINEID = Convert.ToInt32(drFor["GROUTINGLINEID"]);
- detailEntity.GROUTINGMOULDCODE = drFor["GROUTINGMOULDCODE"].ToString();
- detailEntity.MOULDCODE = drFor["MOULDCODE"].ToString();
- detailEntity.GOODSID = Convert.ToInt32(drFor["GOODSID"]);
- detailEntity.StandardGroutingCount = Convert.ToDecimal(drFor["StandardGroutingCount"]);
- detailEntity.GROUTINGCOUNT = Convert.ToDecimal(drFor["GROUTINGCOUNT"]);
- detailEntity.MOULDSTATUS = Convert.ToInt32(drFor["GMOULDSTATUS"]);
- detailEntity.BEGINUSEDDATE = Convert.ToDateTime(drFor["BEGINUSEDDATE"]);
- detailEntity.REMARKS = drFor["REMARKS"].ToString();
- detailEntity.ACCOUNTID = Convert.ToInt32(drFor["ACCOUNTID"]);
- detailEntity.VALUEFLAG = Convert.ToInt32(drFor["VALUEFLAG"]);
- detailEntity.CREATETIME = Convert.ToDateTime(drFor["CREATETIME"]);
- detailEntity.CREATEUSERID = Convert.ToInt32(drFor["CREATEUSERID"]);
- detailEntity.UPDATETIME = Convert.ToDateTime(drFor["UPDATETIME"]);
- detailEntity.UPDATEUSERID = Convert.ToInt32(drFor["UPDATEUSERID"]);
- detailEntity.OPTIMESTAMP = Convert.ToDateTime(drFor["OPTIMESTAMP"]);
- detailEntity.GOODSNAME = drFor["GOODSNAME"].ToString();
- detailEntity.GROUTINGLINENAME = drFor["GMOULDSTATUSNAME"].ToString();
- detailEntity.GOODSCODE = drFor["GOODSCODE"].ToString();
- detailEntity.GoodsSpecification = drFor["GoodsSpecification"].ToString();
- detailEntity.MouldOutputNo = drFor["MouldOutputNo"];
- this._detailList.Add(detailEntity);
- }
- }
- if (_detailList.Count != 0)
- {
- //获取最后一个模具编号的最后数字
- int lineIndexOf = _detailList[_detailList.Count - 1].GROUTINGMOULDCODE.LastIndexOf("-") + 1;
- this._mouldCount = Convert.ToInt32(_detailList[_detailList.Count - 1].GROUTINGMOULDCODE.Substring(lineIndexOf));
- this.dgvDetail.AutoGenerateColumns = false;
- this.dgvDetail.DataSource = ListToTable();
- }
- else
- {
- DataTable dtDataSourse = new DataTable();
- dtDataSourse.Columns.Add("GROUTINGLINEDETAILID", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("MOULDCODE", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GROUTINGMOULDCODE", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GOODSID", 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("REMARKS", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("MOULDSTATUS", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("StandardGroutingCount", typeof(decimal));
- dtDataSourse.Columns.Add("GROUTINGCOUNT", typeof(decimal));
- dtDataSourse.Columns.Add("MouldOutputNo", typeof(int));
- dtDataSourse.Columns.Add("NewFlag", System.Type.GetType("System.String"));
- this.dgvDetail.DataSource = dtDataSourse;
- }
- this.dgvDetail.IsSetInputColumnsColor = true;
- //((C_DataGridView)this.tabPage2.Controls[0]).IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 验证添加项
- /// </summary>
- private int ValidationText()
- {
- try
- {
- 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;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 将实体数据转换为DataTable,绑定到控件中
- /// </summary>
- private DataTable ListToTable()
- {
- try
- {
- //detailEntity.GROUTINGLINEDETAILID = Convert.ToInt32(drFor["GROUTINGLINEDETAILID"]);
- //detailEntity.GROUTINGLINEID = Convert.ToInt32(drFor["GROUTINGLINEID"]);
- //detailEntity.GROUTINGMOULDCODE = drFor["GROUTINGMOULDCODE"].ToString();
- //detailEntity.MOULDCODE = drFor["MOULDCODE"].ToString();
- //detailEntity.GOODSID = Convert.ToInt32(drFor["GOODSID"]);
- //detailEntity.GROUTINGCOUNT = Convert.ToDecimal(drFor["GROUTINGCOUNT"]);
- //detailEntity.MOULDSTATUS = Convert.ToInt32(drFor["GMOULDSTATUS"]);
- //detailEntity.BEGINUSEDDATE = Convert.ToDateTime(drFor["BEGINUSEDDATE"]);
- //detailEntity.REMARKS = drFor["REMARKS"].ToString();
- //detailEntity.ACCOUNTID = Convert.ToInt32(drFor["ACCOUNTID"]);
- //detailEntity.VALUEFLAG = Convert.ToInt32(drFor["VALUEFLAG"]);
- //detailEntity.CREATETIME = Convert.ToDateTime(drFor["CREATETIME"]);
- //detailEntity.CREATEUSERID = Convert.ToInt32(drFor["CREATEUSERID"]);
- //detailEntity.UPDATETIME = Convert.ToDateTime(drFor["UPDATETIME"]);
- //detailEntity.UPDATEUSERID = Convert.ToInt32(drFor["UPDATEUSERID"]);
- //detailEntity.OPTIMESTAMP = Convert.ToDateTime(drFor["OPTIMESTAMP"]);
- //detailEntity.GOODSNAME = drFor["GOODSNAME"].ToString();
- //detailEntity.GROUTINGLINENAME = drFor["GMOULDSTATUSNAME"].ToString();
- //detailEntity.GOODSCODE = drFor["GOODSCODE"].ToString();
- //detailEntity.GoodsSpecification = drFor["GoodsSpecification"].ToString();
- DataTable dtDataSourse = new DataTable();
- dtDataSourse.Columns.Add("GROUTINGLINEDETAILID", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("MOULDCODE", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GROUTINGMOULDCODE", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("GOODSID", 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("REMARKS", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("MOULDSTATUS", System.Type.GetType("System.String"));
- dtDataSourse.Columns.Add("StandardGroutingCount", typeof(decimal));
- dtDataSourse.Columns.Add("GroutingCount", typeof(decimal));
- dtDataSourse.Columns.Add("MouldOutputNo", typeof(int));
- dtDataSourse.Columns.Add("NewFlag", System.Type.GetType("System.String"));
- for (int i = 0; i < this._detailList.Count; i++)
- {
- DataRow drRow = dtDataSourse.NewRow();
- drRow["GROUTINGLINEDETAILID"] = this._detailList[i].GROUTINGLINEDETAILID;
- drRow["GROUTINGMOULDCODE"] = this._detailList[i].GROUTINGMOULDCODE;
- drRow["GOODSID"] = this._detailList[i].GOODSID;
- drRow["GOODSNAME"] = this._detailList[i].GOODSNAME;
- drRow["GoodsCode"] = this._detailList[i].GOODSCODE;
- drRow["GoodsSpecification"] = this._detailList[i].GoodsSpecification;
- drRow["REMARKS"] = this._detailList[i].REMARKS;
- drRow["MOULDSTATUS"] = this._detailList[i].GROUTINGLINENAME;
- drRow["StandardGroutingCount"] = this._detailList[i].StandardGroutingCount;
- drRow["GROUTINGCOUNT"] = this._detailList[i].GROUTINGCOUNT;
- drRow["MouldOutputNo"] = this._detailList[i].MouldOutputNo;
- drRow["NewFlag"] = 0;
- dtDataSourse.Rows.Add(drRow);
- }
- for (int i = 0; i < this._AddDetailList.Count; i++)
- {
- DataRow dr = dtDataSourse.NewRow();
- dr["GROUTINGLINEDETAILID"] = this._AddDetailList[i].GROUTINGLINEDETAILID;
- dr["GROUTINGMOULDCODE"] = _AddDetailList[i].GROUTINGMOULDCODE;
- dr["GOODSID"] = this._AddDetailList[i].GOODSID;
- dr["GOODSNAME"] = this._AddDetailList[i].GOODSNAME;
- dr["GoodsCode"] = this._AddDetailList[i].GOODSCODE;
- dr["GoodsSpecification"] = this._AddDetailList[i].GoodsSpecification;
- dr["REMARKS"] = this._AddDetailList[i].REMARKS;
- dr["MOULDSTATUS"] = "";
- dr["StandardGroutingCount"] = 0;
- dr["GROUTINGCOUNT"] = 0;
- dr["NewFlag"] = 0;
- dtDataSourse.Rows.Add(dr);
- }
- return dtDataSourse;
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 获取权限
- /// </summary>
- protected void getPurview()
- {
- try
- {
- StringBuilder sbPurview = new StringBuilder();
- DataSet dsPurview = SystemModuleProxy.Service.GetUserPurview(6, LogInUserInfo.CurrentUser.UserID);
- if (dsPurview != null)
- {
- foreach (DataRow dr in dsPurview.Tables[0].Rows)
- {
- sbPurview.Append(dr[0].ToString() + ",");
- }
- if (sbPurview.Length != 0)
- {
- this._purview = sbPurview.ToString().Substring(0, sbPurview.Length - 1);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|