| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_2405.cs
- * 2.功能描述:变更单号整板
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 付斌 2018/08/06 1.00 新建
- *******************************************************************************/
- using System;
- 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;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- public partial class F_PM_2405 : FormBase
- {
- #region 成员变量
- private DataTable _dataSourceTable; // 数据源Table
- #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 构造函数
- /// <summary>
- /// 构造函数
- /// </summary>
- public F_PM_2405()
- {
- InitializeComponent();
- this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CANCEL;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_2405_Load(object sender, EventArgs e)
- {
- try
- {
- this.dgvProduction.AutoGenerateColumns = false;
- this.dgvProduction.DataSource = DataSourceTable;
- // 加载权限
- FormPermissionManager.FormPermissionControl(this.Name, this,
- DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
- DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
- // 加载商标数据源
- DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.GetLogoInfo();
- }));
- if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
- {
- DataTable dtNew = dsResultLogo.Tables[0];
- DataRow dr = dtNew.NewRow();
- dr["LogoID"] = -1;
- dr["LogoNameCode"] = string.Empty;
- dtNew.Rows.InsertAt(dr, 0);
- this.cmbLogo.DataSource = dtNew;
- this.cmbLogo.ValueMember = "LogoID";
- this.cmbLogo.DisplayMember = "LogoNameCode";
- }
- 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 txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
- {
- try
- {
- if (this.txtBarcode.ReadOnly)
- {
- return;
- }
- if ((int)e.KeyChar == 13) // 按了回车键
- {
- this.btnSave.Visible = false;
- if (this.txtBarcode.Text.Trim() == "")
- {
- MessageBox.Show("产品条码不能为空", this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Focus();
- return;
- }
- // 异步处理,获取信息
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_2405";
- cre.Name = "FinishedHandoverBarcode";
- cre.Properties["Barcode"] = this.txtBarcode.Text.Trim();
- cre.Properties["HandoverFlag"] = 2;
- // 调用服务器端获取数据集
- ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxyNew.Service.HandleRequest(cre);
- }));
- if (!(sre.Status == Constant.ServiceResultStatus.Success))
- {
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- if (Convert.ToInt32(sre.Result) > 0 && sre.Data.Tables[0].Rows.Count > 0)
- {
- this.dgvProduction.DataSource = sre.Data.Tables[0];
- _dataSourceTable = sre.Data.Tables[0];
- this.btnSave.Visible = true;
- this.btnSave.Enabled = true;
- }
- else
- {
- MessageBox.Show(sre.Message, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.SelectAll();
- return;
- }
- }
- }
- 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 txtOrderNo_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("LogoNameCode='" + this.txtOrderNo.Text.Trim() + "'");
- if (dr.Length > 0)
- {
- this.cmbLogo.SelectedValue = Convert.ToInt32(dr[0]["LogoID"]);
- }
- 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);
- }
- }
- /// <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;
- }
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_PM_2405";
- cre.Name = "SetFinishedLogo";
- string barcodes = string.Empty;
- foreach (DataGridViewRow row in this.dgvProduction.Rows)
- {
- barcodes += row.Cells["BarCode"].Value +",";
- }
- cre.Properties["Barcodes"] = barcodes.Substring(0, barcodes.Length-1);
- cre.Properties["LogoID"] = Convert.ToInt32(this.cmbLogo.SelectedValue);
- // 异步处理
- ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxyNew.Service.HandleRequest(cre);
- }));
- if (Convert.ToInt32(sre.Result) < 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.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 btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <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 && !"-1".Equals(this.cmbLogo.SelectedValue + ""))
- {
- 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
- }
- }
|