| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_PM_2118.cs
- * 2.功能描述:工序商标
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2015/11/12 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Reflection;
- using System.Text;
- 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;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.PMModule
- {
- public partial class F_PM_2118 : DKFormBase
- {
- #region 成员变量
- private string _currentbarcode = "";//当前产品条码
- private int? _logoid = null; // 商标ID
- private string _logoCode = "";//商标编码
- private string _logoName = "";//商标编码
- private string _barcode = ""; //产品条码
- private int? defaultlogoid = null;
- #endregion
- #region 属性
- /// <summary>
- /// 商标ID
- /// </summary>
- public int? LogoID
- {
- set
- {
- _logoid = value;
- }
- get
- {
- return _logoid;
- }
- }
- /// <summary>
- /// 商标编码
- /// </summary>
- public string LogoCode
- {
- set
- {
- _logoCode = value;
- }
- get
- {
- return _logoCode;
- }
- }
- /// <summary>
- /// 商标名称
- /// </summary>
- public string LogoName
- {
- set
- {
- _logoName = value;
- }
- get
- {
- return _logoName;
- }
- }
- #endregion
- #region 构造函数
- public F_PM_2118()
- {
- InitializeComponent();
- this.btnClose.Text = ButtonText.BTN_CLOSE;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.Text = "商标";
- }
- public F_PM_2118(int logoid)
- {
- InitializeComponent();
- this.btnClose.Text = ButtonText.BTN_CLOSE;
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.Text = "商标";
- this.LogoID = logoid;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_PM_2118_Load(object sender, EventArgs e)
- {
- // 加载商标数据源
- DataSet dsResultLogo = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- //return SystemModuleProxy.Service.GetAllLogoInfo();
- return SystemModuleProxy.Service.GetLogoInfo();
- }));
- if (dsResultLogo != null && dsResultLogo.Tables[0].Rows.Count > 0)
- {
- //DataView dv = dsResultLogo.Tables[0].DefaultView;
- //dv.RowFilter = "ValueFlag=1";
- this.cmbLogo.DataSource = dsResultLogo.Tables[0];
- this.cmbLogo.ValueMember = "LogoID";
- this.cmbLogo.DisplayMember = "LogoNameCode";
- defaultlogoid = Convert.ToInt32(this.cmbLogo.SelectedValue);
- //this.cmbLogo.SelectedValue = this.LogoID;
- //DataTable dt = this.cmbLogo.DataSource as DataTable;
- //DataRow[] dr = dt.Select("logoID='" + this.LogoID + "'");
- //if (dr.Length > 0)
- //{
- // this.LogoCode = dr[0]["LogoCode"].ToString();
- // this.LogoName = dr[0]["LogoName"].ToString();
- //}
- }
- }
- /// <summary>
- /// 保存按钮事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- if(this.txtOrgLogo.Text.Trim()=="")
- {
- // 提示信息
- MessageBox.Show("请先扫描条码",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtOrgLogo.Text = "";
- this.txtLogo.Text = "";
- this.txtBarcode.Text = "";
- this.txtBarcode.Focus();
- return;
- }
- DataTable dt = this.cmbLogo.DataSource as DataTable;
- if(dt==null || dt.Rows.Count==0)
- {
- // 提示信息
- MessageBox.Show("请先设置商标",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtOrgLogo.Text = "";
- this.txtLogo.Text = "";
- this.txtBarcode.Text = "";
- this.txtBarcode.Focus();
- return;
- }
- int logoid = Convert.ToInt32(cmbLogo.SelectedValue);
- int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.SaveBarCodeLogo(this._barcode,logoid);
- }));
- if (returnValue > 0)
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "新建" + this.Text, "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this._barcode = "";
- this.txtOrgLogo.Text = "";
- this.txtLogo.Text = "";
- this.cmbLogo.SelectedIndex = 0;
- this.txtBarcode.Text = "";
- //this.DialogResult = DialogResult.OK;
- }
- else if (returnValue == -2)
- {
- // 提示信息
- MessageBox.Show("条码不存在",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (returnValue == -3)
- {
- // 提示信息
- MessageBox.Show("已交接的产品不能变更商标",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else if (returnValue == -5)
- {
- // 提示信息
- MessageBox.Show("该商标已超过生产计划允许变更数量,不能变更商标",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- // 提示信息
- MessageBox.Show("保存失败",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- 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.txtLogo.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("LogoCode='" + this.txtLogo.Text.Trim() + "'");
- if (dr.Length > 0)
- {
- this.LogoID = Convert.ToInt32(dr[0]["LogoID"]);
- this.cmbLogo.SelectedValue = this.LogoID;
- }
- else
- {
- DataRow[] dr2 = dt.Select("isdefault='1'");
- if (dr2.Length > 0)
- {
- this.LogoID = Convert.ToInt32(dr2[0]["LogoID"]);
- this.cmbLogo.SelectedValue = this.LogoID;
- }
- else
- {
- this.LogoID = this.defaultlogoid;
- this.cmbLogo.SelectedValue = this.LogoID;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- #endregion
- private void txtBarcode_KeyPress_1(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();
- this.txtBarcode.Focus();
- return;
- }
- DataSet dsCheckBarcode = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return PMModuleProxy.Service.GetBarCodeLogoID(this.txtBarcode.Text.Trim());
- }));
- if (dsCheckBarcode != null && dsCheckBarcode.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
- {
- this._barcode = this.txtBarcode.Text.Trim();
- this.txtOrgLogo.Text = dsCheckBarcode.Tables[0].Rows[0]["logoname"].ToString() + "[" + dsCheckBarcode.Tables[0].Rows[0]["logocode"].ToString() + "]";
-
- //this.cmbLogo.SelectedValue = dsCheckBarcode.Tables[0].Rows[0]["logoid"].ToString();
- }
- else
- {
- MessageBox.Show("无效条码",
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.txtBarcode.Text = "";
- this.txtOrgLogo.Text = "";
- this.txtLogo.Text = "";
- this._barcode = "";
- this.cmbLogo.SelectedValue = defaultlogoid;
- return;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|