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;
namespace Dongke.IBOSS.PRD.Client.SystemModule
{
public partial class F_MST_1702 : Form
{
#region 成员变量
//记录版面id
private string LayoutidOne;
// 编辑状态
private Constant.FormMode _editStatus;
private string logocodes;
private string goodscodes;
#endregion
#region 构造函数
public F_MST_1702()
{
InitializeComponent();
}
public F_MST_1702(Constant.FormMode frmStatus, string goodscode,string logocode,string valueflag)
{
InitializeComponent();
_editStatus = frmStatus;
// 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
if (frmStatus == Constant.FormMode.Add)
{
FromStatus = "Add";
this.Text = "新建";
DataSet set = SystemModuleProxy.Service.GetLogoInfo();
this.cmbLogos.DataSource = set.Tables[0];
this.cmbLogos.ValueMember = "LOGOCODE";
this.cmbLogos.DisplayMember = "LOGONAME";
}
else if (frmStatus == Constant.FormMode.Edit)
{
FromStatus = "Edit";
this.Text = "编辑";
if (!string.IsNullOrEmpty(goodscode) && !string.IsNullOrEmpty(logocode))
{
logocodes = logocode;
goodscodes = goodscode;
ClientRequestEntity cres = new ClientRequestEntity();
cres.NameSpace = "F_MST_1701";
cres.Name = "GetLogo";
cres.Properties["LOGOCODE"] = logocode.ToString();
ServiceResultEntity sres = SystemModuleProxy.Service.DoRequest(cres);
DataSet set = sres.Data;
this.cmbLogos.DataSource = set.Tables[0];
this.cmbLogos.ValueMember = "LOGOCODE";
this.cmbLogos.DisplayMember = "LOGONAME";
//产品编码
this.txtGoodsCode.Text = goodscode.ToString();
//有效标识
if (valueflag == "是")
{
this.ccbvalueflag.SelectedIndex = 0;
}
else if (valueflag == "否")
{
this.ccbvalueflag.SelectedIndex = 1;
}
}
}
// 工具栏按钮文本赋值
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
}
#endregion
#region 属性
///
/// 页面状态
///
public string FromStatus
{
get;
set;
}
#endregion
#region 事件
//页面加载事件
private void F_MST_1702_Load(object sender, EventArgs e)
{
}
//保存
private void btnSave_Click(object sender, EventArgs e)
{
try
{
//客户编码
if (string.IsNullOrEmpty(this.txtGoodsCode.Text.ToString()))
{
//必须输入
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品编码"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.txtGoodsCode.Focus();
return;
}
//有效标识
if (this.ccbvalueflag.SelectedItem == null)
{
//必须输入
MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "有效标识"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
this.ccbvalueflag.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.AddLauoutInfo();
this.Clear();
}
if (_editStatus == Constant.FormMode.Edit)
{
this.btnSave.Enabled = false;
this.btnCancel.Enabled = false;
this.EditLauout();
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)
{
}
#endregion
#region 私有方法
///
/// 保存方法
///
///
private void AddLauoutInfo()
{
int valueflag = 1;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1701";
cre.Name = "AddGoodsLogoInfo";
cre.Properties["LOGOCODE"] = cmbLogos.SelectedValue.ToString();
cre.Properties["LOGONAME"] = cmbLogos.Text.ToString();
cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text.ToString();
if (this.ccbvalueflag.SelectedIndex == 0)
{
valueflag = 1;
}
if (this.ccbvalueflag.SelectedIndex == 1)
{
valueflag = 0;
}
cre.Properties["VALUEFLAG"] = valueflag.ToString();
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);
return;
}
else if (Convert.ToInt32(sre.OtherStatus) == -1001)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
"存在相同客户编码"),
"",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
}
///
/// 编辑方法
///
public void EditLauout()
{
int valueflag = 1;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1701";
cre.Name = "AddGoodsLogoInfo";
cre.Properties["LOGOCODE"] = cmbLogos.SelectedValue.ToString();
cre.Properties["LOGONAME"] = cmbLogos.Text.ToString();
cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text.ToString();
cre.Properties["OLDLOGOCODE"] = logocodes.ToString();
cre.Properties["OLDGOODSCODE"] = goodscodes.ToString();
if (this.ccbvalueflag.SelectedIndex == 0)
{
valueflag = 1;
}
if (this.ccbvalueflag.SelectedIndex == 1)
{
valueflag = 0;
}
cre.Properties["VALUEFLAG"] = valueflag.ToString();
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);
return;
}
else if (Convert.ToInt32(sre.OtherStatus) == -1001)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
"存在相同版面编码"),
"",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return;
}
}
public void GetLogos(String logocode) {
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1701";
cre.Name = "GetGoodsLogo";
cre.Properties["LOGOCODE"] = logocode;
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
DataSet logoInfo = sre.Data;
if (logoInfo != null && logoInfo.Tables.Count > 0)
{
this.cmbLogos.DataSource = logoInfo.Tables[0];
this.cmbLogos.DisplayMember = "LOGONAME";
this.cmbLogos.ValueMember = "LOGOCODE";
}
}
///
/// 清空方法
///
public void Clear()
{
this.txtGoodsCode.Clear();
this.ccbvalueflag.SelectedText = "";
}
#endregion
}
}