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