| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- /*******************************************************************************
- * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PC_1002.cs
- * 2.功能描述:新建、编辑模具档案
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2017/12/11 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Drawing;
- using System.Reflection;
- using System.Windows.Forms;
- 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
- {
- /// <summary>
- /// 新建、编辑模具档案
- /// </summary>
- public partial class F_PC_1002 : DKFormBase
- {
- #region 成员变量
- /// <summary>
- /// 模具ID
- /// </summary>
- private int _mouldID = 0;
- #endregion
- #region 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PC_1002(int mouldID)
- {
- InitializeComponent();
- //this.txtWeight.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
- //this.txtCost.Number = new Dongke.WinForm.Controls.DNumber(5, 2);
- //this.txtStandardGroutingNum.Number = new Dongke.WinForm.Controls.DNumber(6, 0);
- //txtOutputCount.Number = new Dongke.WinForm.Controls.DNumber(3, 0);
- this.txtWeight.Number = new Point(5, 2);
- this.txtCost.Number = new Point(5, 2);
- this.txtStandardGroutingNum.Number = new Point(6, 0);
- txtOutputCount.Number = new Point(3, 0);
- this._mouldID = mouldID;
- if (this._mouldID > 0)
- {
- this.Text = "编辑模具档案";
- this.txtBarcode.ReadOnly = true;
- this.scbGoods.EditReadOnly = true;
- this.scbGoods.Enabled = false;
- }
- else
- {
- this.Text = "新建模具档案";
- }
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 画面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PC_1002_Load(object sender, System.EventArgs e)
- {
- try
- {
- if (this._mouldID > 0)
- {
- chkAutoPrint.Checked = false;
- chkAutoPrint.Visible = false;
- txtMCount.Visible = false;
- lblMCount.Visible = false;
- }
- this.dtpPDate.Value = DateTime.Now;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "FPC1002";
- cre.Name = "GetFPC1002LoadData";
- cre.Properties["MouldID"] = this._mouldID;
- ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
- if (sre == null)
- {
- this.Close();
- return;
- }
- this.ftcMouldType.DataSource = sre.Data.Tables["MouldType"];
- this.ftcSuppliers.DataSource = sre.Data.Tables["Suppliers"];
- if (this._mouldID > 0)
- {
- DataRow item = sre.Data.Tables["InfoData"].Rows[0];
- // 编辑
- this.txtBarcode.Text = item["MouldBarcode"].ToString();
- this.scbGoods.CheckedData = sre.Data.Tables["InfoData"];
- this.scbGoods.Text = item["GoodsCode"].ToString();
- this.ftcMouldType.InitValue(item["MouldTypeName"].ToString(), item["MouldType"]);
- this.ftcSuppliers.InitValue(item["SupplierName"].ToString(), item["materialsupplier"]);
- this.dtpPDate.Value = Convert.ToDateTime(item["ProductionDate"]);
- this.txtWeight.DataValue = Convert.ToDecimal(item["Weight"]);
- this.txtCost.DataValue = Convert.ToDecimal(item["Cost"]);
- this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
- this.txtOutputCount.DataValue = Convert.ToDecimal(item["OutputCount"]);
- this.txtRemarks.Text = item["Remarks"].ToString();
- this.dkUserInfo.Text = item["UserCode"].ToString();
- this.dkUserInfo.UserCode = item["UserCode"].ToString();
- this.dkUserInfo.UserID = Convert.ToInt32(item["UserID"]);
- this.txtStandardGroutingNum.ReadOnly = true;
- this.txtOutputCount.ReadOnly = true;
- }
- else
- {
- //this.txtBarcode.Text = DateTime.Now.ToString("yyMMdd") + "XXXXXX";
- this.dkUserInfo.Text = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
- this.dkUserInfo.UserCode = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode;
- this.dkUserInfo.UserID = LogInUserInfo.CurrentUser.CurrentUserEntity.UserID;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭画面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, System.EventArgs e)
- {
- if (this._mouldID < 0)
- {
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- }
- else
- {
- this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- }
- this.Close();
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if (!this.CheckInput())
- {
- return;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "FPC1002";
- cre.Name = "SetFPC1002Data";
- cre.Properties["MouldID"] = (this._mouldID > 0 ? this._mouldID : 0);
- //cre.Properties["MouldBarcode"] = this.txtBarcode.Text.Trim();
- cre.Properties["GoodsID"] = scbGoods.SearchedPKMember;
- cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
- cre.Properties["MouldType"] = this.ftcMouldType.SelectedValue;
- cre.Properties["MaterialSupplier"] = this.ftcSuppliers.SelectedValue;
- cre.Properties["ProductionDate"] = this.dtpPDate.Value;
- cre.Properties["UserID"] = this.dkUserInfo.UserID;
- cre.Properties["UserCode"] = this.dkUserInfo.UserCode;
- cre.Properties["Weight"] = this.txtWeight.DataValue;
- cre.Properties["Cost"] = this.txtCost.DataValue;
- cre.Properties["StandardGroutingNum"] = this.txtStandardGroutingNum.DataValue;
- cre.Properties["OutputCount"] = this.txtOutputCount.DataValue;
- cre.Properties["Remarks"] = this.txtRemarks.Text;
- cre.Properties["MCount"] = this.txtMCount.DataValue;
- ServiceResultEntity sre = this.DoAsync<ServiceResultEntity>(() =>
- {
- return PCModuleProxyNew.Service.HandleRequest(cre);
- });
- if (sre != null)
- {
- if (sre.Status == Constant.ServiceResultStatus.Success)
- {
- if (this.chkAutoPrint.Checked && sre.Result != null)
- {
- string[] barcodes = (sre.Result as string).Split(',');
- foreach (string item in barcodes)
- {
- F_MST_013006.PrintBarcode(item, 1, this);
- }
- }
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- if (this._mouldID > 0)
- {
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- this._mouldID = -1;
- this.ClearData();
- this.txtBarcode.Focus();
- }
- }
- else if (!string.IsNullOrWhiteSpace(sre.Message))
- {
- MessageBox.Show(sre.Message,
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- else
- {
- // 提示信息
- MessageBox.Show("保存失败",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选择产品型号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void scbGoods_SearchedItemChanged(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(this.scbGoods.Text))
- {
- return;
- }
- try
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "FPC1002";
- cre.Name = "GetFPC1002GoodsData";
- cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
- ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
- if (sre == null)
- {
- return;
- }
- DataRow item = sre.Data.Tables[0].Rows[0];
- if (item["MouldWeight"] != DBNull.Value)
- {
- this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
- }
- if (item["MouldCost"] != DBNull.Value)
- {
- this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
- }
- if (item["StandardGroutingNum"] != DBNull.Value)
- {
- this.txtStandardGroutingNum.DataValue = Convert.ToDecimal(item["StandardGroutingNum"]);
- }
- if (item["MouldOutputCount"] != DBNull.Value)
- {
- this.txtOutputCount.DataValue = Convert.ToDecimal(item["MouldOutputCount"]);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- ///// <summary>
- ///// 选择产品型号
- ///// </summary>
- ///// <param name="sender"></param>
- ///// <param name="e"></param>
- //private void dkGoodsCode_GoodsValueChanged(object sender, Controls.SearchTextBox.dkGoodsCodeSearchBox.TextChangeEventArgs e)
- //{
- // if (string.IsNullOrEmpty(this.scbGoods.Text))
- // {
- // return;
- // }
- // try
- // {
- // ClientRequestEntity cre = new ClientRequestEntity();
- // cre.NameSpace = "FPC1002";
- // cre.Name = "GetFPC1002GoodsData";
- // cre.Properties["GoodsCode"] = scbGoods.SearchedValue;
- // ServiceResultEntity sre = PCModuleProxyNew.Service.HandleRequest(cre);
- // if (sre == null)
- // {
- // return;
- // }
- // DataRow item = sre.Data.Tables[0].Rows[0];
- // if (item["MouldWeight"] != DBNull.Value)
- // {
- // this.txtWeight.DataValue = Convert.ToDecimal(item["MouldWeight"]);
- // }
- // if (item["MouldCost"] != DBNull.Value)
- // {
- // this.txtCost.DataValue = Convert.ToDecimal(item["MouldCost"]);
- // }
- // }
- // catch (Exception ex)
- // {
- // // 对异常进行共通处理
- // ExceptionManager.HandleEventException(this.ToString(),
- // MethodBase.GetCurrentMethod().Name, this.Text, ex);
- // }
- //}
- #endregion
- #region 私有方法
- /// <summary>
- /// 清除画面数据
- /// </summary>
- private void ClearData()
- {
- this.txtBarcode.Clear();
- //this.dkGoodsCode.Text = null;
- //this.dkGoodsCode.GoodsID = null;
- //this.dkGoodsCode.GoodsCode = null;
- //this.ftcMouldType.ClearValue();
- //this.ftcSuppliers.ClearValue();
- //this.dtpPDate.ClearValue();
- //this.txtWeight.Clear();
- //this.txtCost.Clear();
- //this.txtStandardGroutingNum.Clear();
- //this.txtRemarks.Clear();
- //this.dkUserInfo.Text = null;
- //this.dkUserInfo.UserCode = null;
- //this.dkUserInfo.UserID = null;
- }
- /// <summary>
- /// 保存前画面数据验证
- /// </summary>
- /// <returns></returns>
- private bool CheckInput()
- {
- if (this._mouldID <= 0)
- {
- //if (string.IsNullOrEmpty(this.txtBarcode.Text.Trim()))
- //{
- // MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具条码"),
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- // MessageBoxDefaultButton.Button1);
- // this.txtBarcode.Focus();
- // return false;
- //}
- if (this.scbGoods.SearchedPKMember == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品型号"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.scbGoods.Focus();
- return false;
- }
- }
- if (this.ftcMouldType.SelectedValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具类型"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.ftcMouldType.Focus();
- return false;
- }
- if (this.ftcSuppliers.SelectedValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "材料供应商"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.ftcSuppliers.Focus();
- return false;
- }
- if (this.txtWeight.DataValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具重量"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.txtWeight.Focus();
- return false;
- }
- if (this.txtCost.DataValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具成本"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.txtCost.Focus();
- return false;
- }
- if (this.dkUserInfo.UserID == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "生产工号"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.dkUserInfo.Focus();
- return false;
- }
- if (this.txtStandardGroutingNum.DataValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "标准注浆次数"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.txtStandardGroutingNum.Focus();
- return false;
- }
- if (this.txtOutputCount.DataValue == null)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "模具产出数量"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning,
- MessageBoxDefaultButton.Button1);
- this.txtOutputCount.Focus();
- return false;
- }
- return true;
- }
- #endregion
- private void txtOutputCount_TextChanged(object sender, EventArgs e)
- {
- try
- {
- int mouldOutputCount = (this.txtOutputCount.DataValue.HasValue ? Convert.ToInt32(this.txtOutputCount.DataValue) : 1);
- int standardGroutingNum = (this.txtStandardGroutingNum.DataValue.HasValue ? Convert.ToInt32(this.txtStandardGroutingNum.DataValue) : 0);
- this.txtStandardGroutingSum.DataValue = mouldOutputCount * standardGroutingNum;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|