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; using System.Windows.Forms; namespace Dongke.IBOSS.PRD.Client.SystemModule { public partial class F_MST_1602 : Form { #region 成员变量 private string OrderCodeOne; // 编辑状态 private Constant.FormMode _editStatus; //table1 还是 table2 private int Orders; //保存详细订单数据 ArrayList arrayList1 = new ArrayList(); #endregion #region 构造函数 public F_MST_1602() { InitializeComponent(); } public F_MST_1602(Constant.FormMode frmStatus, ArrayList arrayList, int Order) { InitializeComponent(); _editStatus = frmStatus; arrayList1 = arrayList; // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户 if (frmStatus == Constant.FormMode.Add) { FromStatus = "Add"; this.Text = "新建"; } else if (frmStatus == Constant.FormMode.Edit) { FromStatus = "Edit"; this.Text = "编辑"; this.txtOrderCode.Enabled = true; Orders = Order; string OrderCode = arrayList[0].ToString(); if (!string.IsNullOrEmpty(OrderCode)) { this.txtNumbers.Visible = true; this.c_Label2.Visible = true; OrderCodeOne = OrderCode; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1601"; if (OrderCode == "2") { cre.Name = "GetOrderDetails"; } else { cre.Name = "GetOrder"; } cre.Properties["ORDERSCODE"] = OrderCode; cre.Properties["GOODSCODE"] = ""; cre.Properties["ORDERSNAME"] = ""; cre.Properties["VALUEFLAG"] = ""; ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre); if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success) { if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0) { //订单号 this.txtOrderCode.Text = OrderCode; ////订单名称 this.txtOrderName.Text = sre.Data.Tables[0].Rows[0]["ORDERSNAME"].ToString(); //数量 this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].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(); if (Order == 2) { this.txtOrderName.Enabled = false; this.txtNumbers.Enabled = false; this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].ToString(); this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].ToString(); } else { txtCustomerCode.Visible = false; lblMAC.Visible = false; c_Label1.Visible = false; txtLayoutCode.Visible = false; } } else { // 提示未查找到数据 MessageBox.Show(Messages.MSG_CMN_I002, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } // 工具栏按钮文本赋值 this.btnSave.Text = ButtonText.BTN_SAVE; this.btnCancel.Text = ButtonText.BTN_CLOSE; } #endregion #region 属性 /// /// 页面状态 /// public string FromStatus { get; set; } #endregion #region 事件 private void c_Label3_Click(object sender, EventArgs e) { } //保存事件 private void btnSave_Click(object sender, EventArgs e) { try { if (Orders == 2) { //客户编码 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.txtLayoutCode.Text.ToString())) { //必须输入 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "版面编码"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.txtLayoutCode.Focus(); return; } //订单名称 if (string.IsNullOrEmpty(this.txtOrderName.Text.ToString())) { //必须输入 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单名称"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.txtOrderName.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; } //订单号 if (string.IsNullOrEmpty(this.txtOrderCode.Text.ToString())) { //必须输入 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单号"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.txtOrderCode.Focus(); return; } //数量 if (string.IsNullOrEmpty(this.txtNumbers.Text.ToString())) { //必须输入 MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "数量"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); this.txtNumbers.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.AddOrderInfo(); this.Clear(); } if (_editStatus == Constant.FormMode.Edit) { this.btnSave.Enabled = false; this.btnCancel.Enabled = false; this.EditOrder(); this.Close(); } } catch (Exception ex) { // 对异常进行共通处理 ExceptionManager.HandleEventException(this.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex); } } #endregion #region 私有方法 //保存方法 private void AddOrderInfo() { int valueflag = 1; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1601"; cre.Name = "AddOrderInfo"; cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text; cre.Properties["ORDERSNAME"] = this.txtOrderName.Text; cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text; cre.Properties["LAYOUTCODE"] = this.txtLayoutCode.Text; cre.Properties["NUMBERS"] = this.txtNumbers.Text; if (this.ccbvalueflag.SelectedIndex == 0) { valueflag = 1; } if (this.ccbvalueflag.SelectedIndex == 1) { valueflag = 0; } cre.Properties["VALUEFLAG"] = valueflag; 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; } } //编辑方法 private void EditOrder() { if (Orders == 2) { int valueflag = 1; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1601"; cre.Name = "AddOrderInfo"; if (this.ccbvalueflag.SelectedIndex == 0) { valueflag = 1; } if (this.ccbvalueflag.SelectedIndex == 1) { valueflag = 0; } cre.Properties["VALUEFLAG"] = valueflag; cre.Properties["FromStatus"] = FromStatus.ToString(); cre.Properties["ORDERS"] = Orders; cre.Properties["ORDERSDETAILID"] = arrayList1[2].ToString(); cre.Properties["ORDERSNAME"] = this.txtOrderName.Text; cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text; cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text; cre.Properties["LAYOUTCODE"] = this.txtLayoutCode.Text; 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 (Orders == 1) { int valueflag = 1; ClientRequestEntity cre = new ClientRequestEntity(); cre.NameSpace = "F_MST_1601"; cre.Name = "AddOrderInfo"; if (this.ccbvalueflag.SelectedIndex == 0) { valueflag = 1; } if (this.ccbvalueflag.SelectedIndex == 1) { valueflag = 0; } cre.Properties["VALUEFALG"] = valueflag; cre.Properties["FromStatus"] = FromStatus.ToString(); cre.Properties["ORDERS"] = Orders; cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text; cre.Properties["ORDERCODEONE"] = OrderCodeOne; cre.Properties["ORDERNAME"] = this.txtOrderName.Text; cre.Properties["NUMBERS"] = this.txtNumbers.Text; 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; } } } private void Clear() { this.txtOrderCode.Clear(); this.txtOrderName.Clear(); this.txtLayoutCode.Clear(); this.txtCustomerCode.Clear(); this.txtNumbers.Clear(); this.ccbvalueflag.SelectedText = ""; } #endregion private void F_MST_1602_Load(object sender, EventArgs e) { } private void txtCustomerCode_TextChanged(object sender, EventArgs e) { } private void lblMAC_Click(object sender, EventArgs e) { } } }