/******************************************************************************* * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential * 类的信息: * 1.程序名称:F_PM_0302.cs * 2.功能描述:新建标准、坯库计件 * 编辑履历: * 作者 日期 版本 修改内容 * 王鑫 2014/09/23 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.Client.Controls.FormCommon; using Dongke.IBOSS.PRD.WCF.DataModels; using Dongke.IBOSS.PRD.WCF.Proxys; using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService; using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService; using Dongke.IBOSS.PRD.Client.DataModels; using Dongke.IBOSS.PRD.Basics.Library; namespace Dongke.IBOSS.PRD.Client.PMModule { public partial class F_PM_2407 : FormBase { #region 成员变量 // 数据源Table private DataTable _dataSourceTable = null; // 是否有商标 private int? _isLogo = null; // 是否有商标编码 private string _isLogoCode = ""; // 是否有商标名称 private string _isLogoName = ""; // 1.产成品交接是否限制同商标 private string _isEnable_S_PM_011 = "0"; // 2.产成品交接是否限制同型号 private string _isEnable_S_PM_012 = "0"; // 3.产成品交接是否限制每板装板数量(必须先启用限制同型号); private string _isEnable_S_PM_013 = "0"; // 最大限制数量 private int _maxPlateLimitNum = 0; // 产品型号 private string _goodsModel = string.Empty; // 商标ID private int? _logoID = null; // 商标ID private string _logoName = string.Empty; #endregion #region 属性 /// /// 绑定GridView数据源 /// public DataTable DataSourceTable { set { _dataSourceTable = value; } get { if (_dataSourceTable == null) { _dataSourceTable = new DataTable("dataSourceTable"); _dataSourceTable.Columns.Add("BarCode"); _dataSourceTable.Columns.Add("FinishedBarCode"); _dataSourceTable.Columns.Add("logoid"); _dataSourceTable.Columns.Add("logocode"); _dataSourceTable.Columns.Add("logoname"); _dataSourceTable.Columns.Add("goodscode"); _dataSourceTable.Columns.Add("UserID"); _dataSourceTable.Columns.Add("GroutingUserCode"); _dataSourceTable.Columns.Add("MouldCode"); _dataSourceTable.Columns.Add("GroutingDate", typeof(DateTime)); _dataSourceTable.Columns.Add("DeliverTime", typeof(DateTime)); _dataSourceTable.Columns.Add("GoodsModel"); _dataSourceTable.Columns.Add("PlateLimitNum"); _dataSourceTable.Columns.Add("OrderNo"); _dataSourceTable.Columns.Add("FHTime", typeof(DateTime)); _dataSourceTable.Columns.Add("FHUserCode"); return _dataSourceTable; } else { return _dataSourceTable; } } } #endregion #region 构造函数 public F_PM_2407() { InitializeComponent(); } #endregion #region 事件 /// /// 窗体关闭事件 /// /// /// private void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 窗体关闭事件 /// /// /// private void tsbtnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 条形码按键事件 /// /// /// private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e) { try { if (this.txtBarcode.ReadOnly) { return; } if ((int)e.KeyChar == 13) // 按了回车键 { if (this.txtBarcode.Text.Trim() == string.Empty) { this.txtBarcode.Focus(); return; } DataRow[] drRows = this.DataSourceTable.Select("BarCode='" + this.txtBarcode.Text.Trim() + "' or FinishedBarCode='" + this.txtBarcode.Text.Trim() + "'"); if (drRows.Length == Constant.INT_IS_ZERO) { // 异步处理 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_PM_2407"; cre.Name = "BackFinishedHandoverCheck"; cre.Properties["Barcode"] = this.txtBarcode.Text; ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() => { return PMModuleProxyNew.Service.HandleRequest(cre); }); if (sre.Status == Constant.ServiceResultStatus.Success && sre.Data != null && sre.Data.Tables.Count > 0) { foreach (DataRow item in sre.Data.Tables[0].Rows) { // 添加产到列表 DataRow dr = this.DataSourceTable.NewRow(); dr["BarCode"] = item["BarCode"].ToString(); dr["FinishedBarCode"] = item["FinishedBarCode"].ToString(); dr["goodscode"] = item["goodscode"].ToString(); dr["logoid"] = item["logoid"].ToString(); dr["logoname"] = item["logoname"].ToString(); dr["GroutingUserCode"] = item["GroutingUserCode"].ToString(); dr["MouldCode"] = item["MouldCode"].ToString(); dr["GroutingDate"] = item["GroutingDate"].ToString(); if (!string.IsNullOrEmpty(item["DeliverTime"].ToString())) { dr["DeliverTime"] = item["DeliverTime"].ToString(); } dr["FHTime"] = DateTime.Now; dr["FHUserCode"] = LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode; this.DataSourceTable.Rows.Add(dr); } this.dgvProduction.CurrentCell = null; this.dgvProduction.Rows[dgvProduction.RowCount - 1].Selected = true; this.dgvProduction.CurrentCell = this.dgvProduction.Rows[dgvProduction.RowCount - 1].Cells[0]; this.txtBarcode.Focus(); this.txtBarcode.SelectAll(); this.txtBarcode.Text = ""; this.btnSave.Visible = true; this.btnSave.Enabled = true; } else { if (sre.OtherStatus >0) { S_CMN_020 frmscmn020 = new S_CMN_020(sre.OtherStatus, sre.Message); frmscmn020.ShowDialog(); } else { // 表示有错误 MessageBox.Show(string.Format(sre.Message, this.txtBarcode.Text.Trim(), "产品条码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.txtBarcode.Focus(); this.txtBarcode.SelectAll(); return; } } else { this.txtBarcode.Text = ""; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 窗体加载事件 /// /// /// private void F_PM_2407_Load(object sender, EventArgs e) { try { this.dgvProduction.AutoGenerateColumns = false; this.dgvProduction.DataSource = DataSourceTable; // 加载权限 FormPermissionManager.FormPermissionControl(this.Name, this, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData); this.btnSave.Enabled = false; } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 删除按钮事件 /// /// /// private void tsbtnDelete_Click(object sender, EventArgs e) { if (this.dgvProduction.CurrentCell != null) { this.DataSourceTable.Rows[this.dgvProduction.CurrentCell.RowIndex].Delete(); if (this.DataSourceTable.Rows.Count == 0) { // 最大限制数量 this._maxPlateLimitNum = 0; // 产品型号 this._goodsModel = string.Empty; // 商标ID this._logoID = null; // 商标ID this._logoName = string.Empty; this.btnSave.Visible = false; this.btnSave.Enabled = false; } } } /// /// 保存按钮事件 /// /// /// private void btnSave_Click(object sender, EventArgs e) { try { this.DataSourceTable.AcceptChanges(); DataSet ds = new DataSet(); ds.Tables.Add(DataSourceTable.Copy()); // 异步处理 ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_PM_2407"; cre.Name = "BackFinishedHandover"; cre.Data = ds; ServiceResultEntity sre = (ServiceResultEntity)DoAsync(() => { return PMModuleProxyNew.Service.HandleRequest(cre); }); if (sre.Result.ToNullableInt32() < 0) { MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { // 提示信息 MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新增" + this.Text, "保存"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtBarcode.Text = string.Empty; this.DataSourceTable.Rows.Clear(); this.btnSave.Visible = false; this.btnSave.Enabled = false; } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } /// /// 自动适应列宽 /// /// /// private void tsbtnAdaptive_Click(object sender, EventArgs e) { this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } /// /// 窗体关闭时事件 /// /// /// private void F_PM_0302_FormClosing(object sender, FormClosingEventArgs e) { if (this.btnSave.Visible) { try { this.DataSourceTable.AcceptChanges(); if (this.DataSourceTable.Rows.Count > Constant.INT_IS_ZERO) { DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { // 保存数据 btnSave_Click(sender, e); } else if (result == DialogResult.Cancel) { e.Cancel = true; } } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } } #endregion #region 私有方法 /// /// 获取系统参数 /// /// private object GetSystemData() { try { return SystemModuleProxy.Service.GetSystemData(); } catch (Exception ex) { throw ex; } } #endregion } }