/*******************************************************************************
* 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 属性
///
/// 商标ID
///
public int? LogoID
{
set
{
_logoid = value;
}
get
{
return _logoid;
}
}
///
/// 商标编码
///
public string LogoCode
{
set
{
_logoCode = value;
}
get
{
return _logoCode;
}
}
///
/// 商标名称
///
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 事件
///
/// 窗体加载事件
///
///
///
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();
//}
}
}
///
/// 保存按钮事件
///
///
///
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 == 0)
{
// 提示信息
MessageBox.Show("保存失败",
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 回车符事件
///
///
///
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);
}
}
}
}