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;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Dongke.IBOSS.PRD.Client.SystemModule
{
public partial class F_MST_1302 : Form
{
#region 成员变量
// 编辑状态
private Constant.FormMode _editStatus;
//记录金蝶代码
private string KingdeeCodeOne;
private string lognameOne;
private string GLAZETYPEOne;
private string GUID;
#endregion
#region 构造函数
public F_MST_1302()
{
InitializeComponent();
}
public F_MST_1302(Constant.FormMode frmStatus, string KingdeeCode, string logname,string GLAZETYPE,string GoodsCode)
{
InitializeComponent();
_editStatus = frmStatus;
// 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
if (frmStatus == Constant.FormMode.Add)
{
FromStatus = "Add";
this.Text = "新建";
}
else if (frmStatus == Constant.FormMode.Edit)
{
FromStatus = "Edit";
this.Text = "编辑";
KingdeeCodeOne = KingdeeCode;
if (!string.IsNullOrEmpty(KingdeeCode))
{
//CustomerCodeOne = CustomerCode;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1301";
cre.Name = "GetKingdeeCode";
cre.Properties["KingdeeCode"] = KingdeeCode;
cre.Properties["GoodsCode"] = GoodsCode;
cre.Properties["GoodsName"] = "";
cre.Properties["LogoName"] = "";
cre.Properties["GlazeType"] = "";
lognameOne = logname;
GLAZETYPEOne = GLAZETYPE;
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
{
DataRow item = sre.Data.Tables[0].Rows[0];
//金蝶代码
this.txtKingdeeCode.Text = KingdeeCode;
//产品编码
this.scbGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
GUID= sre.Data.Tables[0].Rows[0]["GUID"].ToString();
}
}
}
// 工具栏按钮文本赋值
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
}
#endregion
#region 属性
///
/// 页面状态
///
public string FromStatus
{
get;
set;
}
#endregion
#region 事件
///
/// 保存事件
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
//商品编码
if (string.IsNullOrEmpty(this.scbGoodsCode.Text.ToString()))
{
//必须输入
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商品编码"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.scbGoodsCode.Focus();
return;
}
//金蝶代码
if (string.IsNullOrEmpty(this.txtKingdeeCode.Text.ToString()))
{
//必须输入
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "金蝶代码"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.txtKingdeeCode.Focus();
return;
}
//商标
if (this.ddlLogoName.Text == "")
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.ddlLogoName.Focus();
return;
}
//釉料类别
if (this.ddlGlazeTypeID.Text == "")
{
//商标
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "釉料类别"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.ddlGlazeTypeID.Focus();
return;
}
//int returnCustomerID = Constant.INT_IS_ZERO;
//_CustomerEntity = this.SetCustomerEntity();
if (_editStatus == Constant.FormMode.Add)
{
// 新建用户,返回新建的用户ID
this.btnSave.Enabled = false;
this.btnCancel.Enabled = false;
this.AddCustomerInfo();
}
if (_editStatus == Constant.FormMode.Edit)
{
this.btnSave.Enabled = false;
this.btnCancel.Enabled = false;
this.EditCustomer();
this.Close();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 退出事件
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
}
///
/// 页面加载事件
///
///
///
private void F_MST_1302_Load(object sender, EventArgs e)
{
try
{
this.ddlGlazeTypeID.ClearValue();
this.ddlLogoName.ClearValue();
this.loadDataSource();
this.ddlGlazeTypeID.SelectedText = GLAZETYPEOne;
int logindex = ddlLogoName.FindStringExact(lognameOne);
this.ddlLogoName.SelectedIndex = logindex;
int index = ddlGlazeTypeID.FindStringExact(GLAZETYPEOne);
this.ddlGlazeTypeID.SelectedIndex = index;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 下拉框获取数据
///
private void loadDataSource()
{
try
{
DataTable dtGlazeType = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, Constant.INT_IS_ONE);
if (dtGlazeType != null)
{
ddlGlazeTypeID.DisplayMember = "DictionaryValue";
ddlGlazeTypeID.ValueMember = "DictionarylD";
ddlGlazeTypeID.DataSource = dtGlazeType;
}
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1301";
cre.Name = "GetLogoName";
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
{
DataTable dtLogoName = sre.Data.Tables[0];
if (dtLogoName != null)
{
ddlLogoName.DisplayMember = "LogoNameCode";
ddlLogoName.ValueMember = "LogoID";
ddlLogoName.DataSource = dtLogoName;
}
}
}
catch (Exception ex)
{
throw ex;
}
#endregion
}
private void Clear()
{
this.scbGoodsCode.ClearValue();
this.txtKingdeeCode.Clear();
this.ddlLogoName.SelectedText = "";
this.ddlGlazeTypeID.SelectedText = "";
}
private void AddCustomerInfo()
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1301";
cre.Name = "AddKingdeeCode";
if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
{
if (this.scbGoodsCode.CheckedPKMember.Contains(","))
{
cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
}
else
{
cre.Properties["GOODSCODE"] = scbGoodsCode.Text;
}
}
cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text.Trim();
cre.Properties["KINGDEECODEONE"] = "";
cre.Properties["FromStatus"] = FromStatus.ToString();
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
if (sre.OtherStatus > 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
this.Clear();
this.txtKingdeeCode.Focus();
this.ddlGlazeTypeID.ClearValue();
this.ddlLogoName.ClearValue();
return;
}
else if (Convert.ToInt32(sre.OtherStatus) == -1001)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
"存在相同数据"),
"",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
}
private void EditCustomer()
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1301";
cre.Name = "AddKingdeeCode";
if (!string.IsNullOrWhiteSpace(this.scbGoodsCode.Text))
{
cre.Properties["GOODSCODE"] = this.scbGoodsCode.Text;
}
cre.Properties["GLAZETYPE"] = this.ddlGlazeTypeID.Text;
cre.Properties["LOGONAME"] = this.ddlLogoName.Text;
cre.Properties["KINGDEECODE"] = this.txtKingdeeCode.Text.Trim();
cre.Properties["KINGDEECODEONE"] = KingdeeCodeOne.Trim();
cre.Properties["FromStatus"] = FromStatus.ToString();
cre.Properties["GUID"] = GUID;
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
this.btnSave.Enabled = true;
this.btnCancel.Enabled = true;
if (sre.OtherStatus > 0)
{
DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
return;
}
else if (Convert.ToInt32(sre.OtherStatus) == -1001)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
"存在相同金蝶代码"),
"",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
}
}
}