| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_0102.cs
- * 2.功能描述:新建成型线信息
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 庄天威 2014/09/13 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections.Generic;
- using System.Data;
- 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.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.PCModuleService;
- namespace Dongke.IBOSS.PRD.Client.PCModule
- {
- public partial class F_PC_0102 : FormBase
- {
- #region 成员变量
- //需要添加的成型线明细集合
- public List<GroutingLineDetailEntity> _addDetailList = new List<GroutingLineDetailEntity>();
- //模具总数量
- private int _mouldCount = 0;
- //是否已经提示过删除模具的信息
- private bool _isMessageShow = false;
- #endregion
- #region 构造函数
- public F_PC_0102()
- {
- 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;
- }
- #endregion
- #region 事件
- /// <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 == string.Empty)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具数量"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.dkGoods.GoodsID == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产品"), 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)
- {
- MessageBox.Show("生成模具信息后,修改成型线编码将导致清空模具信息。",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this._isMessageShow = true;
- }
- for (int i = 0; i < Convert.ToInt32(this.txtCount.Text); i++)
- {
- int GroutingMouldCodeNum = i + _mouldCount;
- GroutingLineDetailEntity detailInfo = new GroutingLineDetailEntity();
- detailInfo.GROUTINGMOULDCODE = this.txtGroutingLineCode.Text + "-" + (GroutingMouldCodeNum + 1).ToString().PadLeft(3, '0');
- detailInfo.MOULDCODE = Guid.NewGuid().ToString();
- detailInfo.GOODSID = Convert.ToInt32(this.dkGoods.GoodsID);
- detailInfo.GOODSNAME = this.dkGoods.GoodsName;
- detailInfo.GOODSCODE = this.dkGoods.GoodsCode;
- detailInfo.GoodsSpecification = this.dkGoods.GoodsSpecification;
- detailInfo.GROUTINGCOUNT = Constant.INT_IS_ZERO;
- detailInfo.MOULDSTATUS = Convert.ToInt32(Constant.GMouldStatus.Normal);
- detailInfo.REMARKS = "-";
- this._addDetailList.Add(detailInfo);
- }
- this._mouldCount += Convert.ToInt32(this.txtCount.Text);
- this.dgvDetail.AutoGenerateColumns = false;
- this.dgvDetail.DataSource = ListToTable();
- }
- 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
- {
- DataGridViewRow currentRow = this.dgvDetail.CurrentRow;
- if (currentRow == null || currentRow.Index < Constant.INT_IS_ZERO)
- {
- return;
- }
- this._addDetailList.RemoveAt(currentRow.Index);
- this.dgvDetail.DataSource = ListToTable();
- }
- 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.dkType.Focus();
- errorAddress = "成型线类别";
- break;
- default:
- break;
- };
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, errorAddress),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- return;
- }
- if (this._addDetailList.Count == Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具信息"), this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- 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;
- ginfo.MOULDTYPEID = this.dkType.MouldTypeID;
- ginfo.MouldStatus = Convert.ToInt32(Constant.GMouldStatus.Normal);
- ginfo.VALUEFLAG = Convert.ToInt32(Constant.ValueFlag.Effective);
- ginfo.MOULDQUANTITY = this._addDetailList.Count;
- int myReturn = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PCModuleProxy.Service.AddGroutingLine(ginfo, this._addDetailList);
- }));
- if (myReturn > Constant.INT_IS_ZERO)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "成型线信息", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- }
- else if (myReturn == -50)
- {
- MessageBox.Show("成型线编码已存在,请重新输入!",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- 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;
- }
- }
- #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"));
- 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);
- }
- 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 (dkType.MouldTypeID == null)
- {
- ErrorId = 8;
- return ErrorId;
- }
- return ErrorId;
- }
- #endregion
- }
- }
|