| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- /*******************************************************************************
- * 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 属性
- /// <summary>
- /// 绑定GridView数据源
- /// </summary>
- 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 事件
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 条形码按键事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 删除按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- /// <summary>
- /// 自动适应列宽
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tsbtnAdaptive_Click(object sender, EventArgs e)
- {
- this.dgvProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
- }
- /// <summary>
- /// 窗体关闭时事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 私有方法
- /// <summary>
- /// 获取系统参数
- /// </summary>
- /// <returns></returns>
- private object GetSystemData()
- {
- try
- {
- return SystemModuleProxy.Service.GetSystemData();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|