| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585 |
- /*******************************************************************************
- * 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")
- {
- 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();
- //qq add 20260311 高压线组及序号
- this._lineEntity.HLINECODE = this.txtHighLineCode.Text.Trim();
- this._lineEntity.HLINEINDEX = this.txtHighLineIndex.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 if (myReturn.OtherStatus == -10001 || myReturn.OtherStatus == -10002)
- {
- MessageBox.Show(myReturn.Message,
- 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().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);
- }
- }
- /// <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;
- }
- if (!string.IsNullOrWhiteSpace(item["MouldTypeName"].ToString()) && item["MouldTypeName"].ToString() != "高压")
- {
- if (string.IsNullOrWhiteSpace(item["mouldPlan"].ToString()) || Convert.ToInt32(item["mouldPlan"].ToString()) == 0)
- {
- MessageBox.Show("此模具未报工,不能添加到成型线。", 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
- //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
- //add qq 20260311
- this.txtHighLineCode.Text = this._lineEntity.HLINECODE.ToString();
- this.txtHighLineIndex.Text = this._lineEntity.HLINEINDEX.ToString();
- 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"]);
- 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"]);
- this._lineEntity.HLINECODE = drGrouting["H_LINECODE"].ToString();
- this._lineEntity.HLINEINDEX = drGrouting["H_LINEINDEX"].ToString();
- }
- 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
- }
- }
|