/******************************************************************************* * 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 _detailList = new List(); //当前编辑成型线新增明细集合 private List _AddDetailList = new List(); //需要添加的成型工号明细集合 public List _addDetailUserList = new List(); //模具总数量 private int _mouldCount = 0; //修改前成型线编号 private string _lineCode = ""; //范围权限 private string _purview; private string _userCodeValue; private bool _ShowFlag = true; //默认条数 private int defaultRow = 0; /// /// 模具操作状态 /// private int _gmouldstatus = 0; /// /// 整线变产原数据 /// private DataTable _oldDetail = null; #endregion #region 构造函数 /// /// 编辑成型线窗体构造 /// 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; } /// /// 模具操作 /// /// /// 0:上模,4:结束变产 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 事件 /// /// 窗体加载 /// 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); } } /// /// 提交编辑 /// 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") { if (this.scbUser1.ValueFrom == WinForm.Controls.SearchBoxValueFrom.InitValue && this._lineEntity.MonitorID == null) { MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "成型班长"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); return; } if (this.scbUser1.ValueFrom != WinForm.Controls.SearchBoxValueFrom.InitValue && this.scbUser1.SearchedItem == 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 //xuwei add 2021-09-12 部门 this._lineEntity.WORKSHOP = Convert.ToInt32(txtWorkShop.Text); //xuwei end //2022年3月25日 17:37:27 by feiy 试验线 this._lineEntity.TestFlag = TestFlag.Checked ? 1 : 0; //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); } } /// /// 关闭窗体 /// private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } /// /// 工号单元格开始编辑事件 /// /// /// 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); } } /// /// 删除新建明细信息 /// 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); } } /// /// 新建明细信息 /// 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().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); //} 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().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); 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["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); } } /// /// 工号单元格值改变事件 /// /// /// 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); } } /// /// 窗体加载后显示事件 /// /// /// private void F_PC_0103_1_Shown(object sender, EventArgs e) { //dgvDetail.IsSetInputColumnsColor = true; dgvUser.IsSetInputColumnsColor = true; } /// /// 容器切换事件 /// /// /// private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { //dgvDetail.IsSetInputColumnsColor = true; this.dgvUser.IsSetInputColumnsColor = true; } /// /// 工号排序事件 /// /// /// private void dgvUser_Sorted(object sender, EventArgs e) { this.dgvUser.IsSetInputColumnsColor = true; } /// /// 单元格只读 /// /// /// 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); } } /// /// 自适应列宽 /// /// /// private void btnAdaptive_Click(object sender, EventArgs e) { this.dgvUser.AutoResizeColumns(); this.dgvDetail.AutoResizeColumns(); } /// /// 切换模具来源 /// /// /// private void rabAuto_CheckedChanged(object sender, EventArgs e) { this.pnlAuto.Enabled = this.rabAuto.Checked; this.pnlBinding.Enabled = this.rabBinding.Checked; } /// /// 验证模具号 /// /// /// 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); } } /// /// 验证模具条码 /// /// /// private void txtBarcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.btnAddMouldBarcode_Click(null, null); } } /// /// 添加模具 /// /// /// 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 私有方法 /// /// 加载成型线数据 /// 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 //xuwei add 2021-09-12 部门 this.txtWorkShop.Text = this._lineEntity.WORKSHOP.ToString(); //xuwei end //feiy add 2022-3-25 试验线 this.TestFlag.Checked = this._lineEntity.TestFlag == 1 ? true : false; //feiy 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; } } /// /// 将DataRow转换为实体 /// 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"]); if (drGrouting["HIGHPRESSUREFLAG"] == DBNull.Value) { this._lineEntity.HIGHPRESSUREFLAG = 0; } else { this._lineEntity.HIGHPRESSUREFLAG = Convert.ToInt32(drGrouting["HIGHPRESSUREFLAG"]); } //xuwei end //xuwei add 2021-09-12 if (drGrouting["WORKSHOP"] == DBNull.Value) { this._lineEntity.WORKSHOP = 0; } else { this._lineEntity.WORKSHOP = Convert.ToInt32(drGrouting["WORKSHOP"]); } //xuwei end //feiy add 2022-3-25 if (drGrouting["TESTFLAG"] == DBNull.Value) { this._lineEntity.TestFlag = 0; } else { this._lineEntity.TestFlag = Convert.ToInt32(drGrouting["TESTFLAG"]); } //feiy 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; } } /// /// 根据成型线ID绑定该成型线所属成型线模具信息 /// 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; } } /// /// 将成型线明细DataSet数据集转换为实体集合 /// 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; } } /// /// 验证添加项 /// 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; } } /// /// 将实体数据转换为DataTable,绑定到控件中 /// 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; } } /// /// 获取权限 /// 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 } }