| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522 |
- /*******************************************************************************
- * 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;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- public partial class F_PM_2402 : 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_2402()
- {
- 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)
- {
- // 包装装板,产成品交接不限制
- //if (this._maxPlateLimitNum > 0 && this.DataSourceTable.Rows.Count >= this._maxPlateLimitNum)
- //{
- // MessageBox.Show("超过最大装板数量【" + this._maxPlateLimitNum + "】",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.txtBarcode.Focus();
- // this.txtBarcode.SelectAll();
- // return;
- //}
- ServiceResultEntity resultEntity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.FinishedHandoverBarcode(this.txtBarcode.Text.Trim());
- }));
- if (Convert.ToInt32(resultEntity.Result) > 0)
- {
- /* 包装装板,产成品交接不限制
- if (this.DataSourceTable.Rows.Count == 0)
- {
- // 设置装板数量
- if (this._isEnable_S_PM_013 == "1" && this._isEnable_S_PM_012 == "1")
- {
- this._maxPlateLimitNum = Convert.ToInt32(resultEntity.Data.Tables[0].Rows[0]["PlateLimitNum"]);
- }
- this._goodsModel = resultEntity.Data.Tables[0].Rows[0]["GoodsModel"].ToString();
- this._logoID = Convert.ToInt32(resultEntity.Data.Tables[0].Rows[0]["logoid"]);
- this._logoName = resultEntity.Data.Tables[0].Rows[0]["logoName"].ToString();
- }
- else
- {
- #region 启用限制同商标
- if (this._isEnable_S_PM_011 == "1")
- {
- if (Convert.ToInt32(resultEntity.Data.Tables[0].Rows[0]["logoid"]) != this._logoID)
- {
- MessageBox.Show("此产品【" + resultEntity.Data.Tables[0].Rows[0]["BarCode"] + "】的商标【"
- + resultEntity.Data.Tables[0].Rows[0]["logoname"] + "】与此批次商标【" + this._logoName + "】不同,不能进行该操作。 ",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- }
- }
- #endregion
- #region 启用限制同型号
- if (this._isEnable_S_PM_012 == "1")
- {
- if (resultEntity.Data.Tables[0].Rows[0]["GoodsModel"].ToString() != this._goodsModel)
- {
- MessageBox.Show("此产品【" + resultEntity.Data.Tables[0].Rows[0]["BarCode"] + "】的型号【"
- + resultEntity.Data.Tables[0].Rows[0]["GoodsModel"] + "】与此批次型号【" + this._goodsModel + "】不同,不能进行该操作。 ",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- this.txtBarcode.SelectAll();
- return;
- }
- }
- #endregion
- }
- */
- foreach (DataRow item in resultEntity.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["OrderNo"] = this.cmbLogo.Text;
- 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 (resultEntity.OtherStatus >0)
- {
- S_CMN_020 frmscmn020 = new S_CMN_020(resultEntity.OtherStatus, resultEntity.Message);
- frmscmn020.ShowDialog();
- }
- else
- {
- // 表示有错误
- MessageBox.Show(string.Format(resultEntity.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_2402_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);
- // 加载订单数据源
- DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetOrderList(new OrderEntity());
- }));
- if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
- {
- DataView dv = dsResultLogo.Tables[0].DefaultView;
- dv.RowFilter = "ValueFlag=1";
- DataTable dtNew = dv.ToTable();
- DataRow dr = dtNew.NewRow();
- dr["OrderID"] = -1;
- dr["OrderNo"] = string.Empty;
- dtNew.Rows.InsertAt(dr, 0);
- this.cmbLogo.DataSource = dtNew;
- this.cmbLogo.ValueMember = "OrderID";
- this.cmbLogo.DisplayMember = "OrderNo";
- }
- // 包装装板,产成品交接不限制
- //DataSet dsSystemData = (DataSet)DoAsync(new BaseAsyncMethod(GetSystemData));
- //if (dsSystemData != null && dsSystemData.Tables[0].Rows.Count > 0)
- //{
- // this._isEnable_S_PM_011 = dsSystemData.Tables[0].Select("SettingCode='S_PM_011'")[0]["SettingValue"].ToString();
- // this._isEnable_S_PM_012 = dsSystemData.Tables[0].Select("SettingCode='S_PM_012'")[0]["SettingValue"].ToString();
- // this._isEnable_S_PM_013 = dsSystemData.Tables[0].Select("SettingCode='S_PM_013'")[0]["SettingValue"].ToString();
- //}
- 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();
- if (this.cmbLogo.SelectedValue.ToString() == "-1")
- {
- MessageBox.Show("请选择生产订单",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.cmbLogo.Focus();
- return;
- }
- // 包装装板,产成品交接不限制
- //if (this._maxPlateLimitNum > 0 && this._maxPlateLimitNum != this.DataSourceTable.Rows.Count)
- //{
- // MessageBox.Show("未达到装板数量【" + this._maxPlateLimitNum + "】",
- // this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- // this.cmbLogo.Focus();
- // return;
- //}
- int orderid = Convert.ToInt32(this.cmbLogo.SelectedValue);
- ServiceResultEntity entity = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.SaveFinishedHandover(orderid, this.DataSourceTable);
- }));
- if (Convert.ToInt32(entity.Result) < 0)
- {
- MessageBox.Show(entity.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.cmbLogo.SelectedValue = -1;
- this.txtOrderNo.Text = string.Empty;
- 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);
- }
- }
- }
- /// <summary>
- /// 生产订单号回车事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtUserCode_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- if (this.txtOrderNo.ReadOnly)
- {
- return;
- }
- if ((int)e.KeyChar == 13) // 按了回车键
- {
- DataTable dt = this.cmbLogo.DataSource as DataTable;
- if (dt != null && dt.Rows.Count > 0)
- {
- DataRow[] dr = dt.Select("OrderNo='" + this.txtOrderNo.Text.Trim() + "'");
- if (dr.Length > 0)
- {
- this.cmbLogo.SelectedValue = Convert.ToInt32(dr[0]["OrderID"]);
- }
- else
- {
- this.cmbLogo.SelectedIndex = 0;
- }
- this.txtOrderNo.Text = string.Empty;
- }
- }
- }
- 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
- }
- }
|