| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- 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_1402 : FormBase
- {
- #region 成员变量
- //记录客户id
- private string CustomeridOne;
- // 编辑状态
- private Constant.FormMode _editStatus;
- #endregion
- #region 构造函数
- public F_MST_1402()
- {
- InitializeComponent();
- }
- public F_MST_1402(Constant.FormMode frmStatus,string Customerid)
- {
- InitializeComponent();
- _editStatus = frmStatus;
- // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
- if (frmStatus == Constant.FormMode.Add)
- {
- FromStatus = "Add";
- this.Text = "新建";
- }
- else if (frmStatus == Constant.FormMode.Edit)
- {
- CustomeridOne = Customerid;
- FromStatus = "Edit";
- this.Text = "编辑";
- if (!string.IsNullOrEmpty(Customerid))
- {
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_MST_1401";
- cre.Name = "GetCustomer";
- cre.Properties["Customerid"] = Customerid;
- cre.Properties["CustomerCode"] = "";
- cre.Properties["CustomerName"] = "";
- cre.Properties["GOODSCODE"] = "";
- cre.Properties["GOODSNAME"] = "";
- cre.Properties["VALUEFLAG"] = "";
- ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
- if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
- {
- //客户编码
- this.txtCustomerCode.Text = sre.Data.Tables[0].Rows[0]["CustomerCode"].ToString() ;
- //客户名称
- this.txtCustomerName.Text = sre.Data.Tables[0].Rows[0]["CUSTOMERNAME"].ToString();
- //有效标识
- if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "是")
- {
- this.ccbvalueflag.SelectedIndex = 0;
- }
- else if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "否")
- {
- this.ccbvalueflag.SelectedIndex = 1;
- }
- //备注
- this.txtRemarks.Text = sre.Data.Tables[0].Rows[0]["REMARKS"].ToString();
- this.txtGoodsCode.Text = sre.Data.Tables[0].Rows[0]["GOODSCODE"].ToString();
- }
- }
- }
- // 工具栏按钮文本赋值
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 页面状态
- /// </summary>
- public string FromStatus
- {
- get;
- set;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 保存事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 (string.IsNullOrEmpty(this.txtCustomerCode.Text.ToString()))
- {
- //必须输入
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户编码"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtCustomerCode.Focus();
- return;
- }
- //客户名称
- if (string.IsNullOrEmpty(this.txtCustomerName.Text.ToString()))
- {
- //必须输入
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户名称"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- this.txtCustomerName.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.AddCustomerInfo();
- this.Clear();
- }
- 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);
- }
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 保存方法
- /// </summary>
- /// <returns></returns>
- private void AddCustomerInfo()
- {
- int valueflag = 1;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_MST_1401";
- cre.Name = "AddCustomer";
- cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
- cre.Properties["CUSTOMERNAME"] = this.txtCustomerName.Text;
- cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
- if (this.ccbvalueflag.SelectedIndex == 0)
- {
- valueflag = 1;
- }
- if (this.ccbvalueflag.SelectedIndex == 1)
- {
- valueflag = 0;
- }
- cre.Properties["VALUEFLAG"] = valueflag;
- cre.Properties["REMARKS"] = this.txtRemarks.Text;
- 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;
- }
- }
- /// <summary>
- /// 编辑方法
- /// </summary>
- public void EditCustomer()
- {
- int valueflag = 1;
- ClientRequestEntity cre = new ClientRequestEntity();
- cre.NameSpace = "F_MST_1401";
- cre.Name = "AddCustomer";
- cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
- cre.Properties["CUSTOMERNAME"] = this.txtCustomerName.Text;
- cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
- if (this.ccbvalueflag.SelectedIndex == 0)
- {
- valueflag = 1;
- }
- if (this.ccbvalueflag.SelectedIndex == 1)
- {
- valueflag = 0;
- }
- cre.Properties["VALUEFLAG"] = valueflag;
- cre.Properties["REMARKS"] = this.txtRemarks.Text;
- cre.Properties["FromStatus"] = FromStatus.ToString();
- cre.Properties["CUSTOMERID"] = CustomeridOne;
- 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;
- }
- }
- /// <summary>
- /// 清空方法
- /// </summary>
- public void Clear()
- {
- this.txtCustomerCode.Clear();
- this.txtCustomerName.Clear();
- this.txtGoodsCode.Clear();
- this.ccbvalueflag.SelectedText = "";
- this.txtRemarks.Clear();
- }
- #endregion
- private void F_MST_1402_Load(object sender, EventArgs e)
- {
- }
- }
- }
|