Example #1
0
        //保存
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (validationProvider.Validate())
                {
                    if (Type == DBOperateType.Insert)
                    {
                        Customers = new CoCustomers();
                        Customers.Valid = true;
                    }

                    Customers.Code = txtCode.Text.Trim();
                    Customers.Name = txtName.Text.Trim();
                    Customers.FullName = txtFullName.Text.Trim();
                    Customers.SiteID = (btneditSite.Tag as CoSite).ID;
                    Customers.LinkMan1 = txtLinkMan1.Text.Trim();
                    Customers.Tel1 = txtTel1.Text.Trim();
                    Customers.Phone1 = txtPhone1.Text.Trim();
                    Customers.LinkMan2 = txtLinkMan2.Text.Trim();
                    Customers.Tel2 = txtTel2.Text.Trim();
                    Customers.Phone2 = txtPhone2.Text.Trim();
                    Customers.QQ = txtQQ.Text.Trim();
                    Customers.Fax = txtFax.Text.Trim();
                    Customers.MSN = txtMSN.Text.Trim();
                    Customers.Mail = txtMail.Text.Trim();
                    Customers.SettlementType = lookUpSettlementType.EditValue.ToString();
                    Customers.CustomersType = lookUpCustomersType.EditValue.ToString();
                    Customers.SendPlace = txtSendPlace.Text.Trim();
                    Customers.Address = txtAddress.Text.Trim();
                    if (lookUpServiceEmployeeCode.EditValue == null)
                        Customers.ServiceEmployeeID = null;
                    else
                        Customers.ServiceEmployeeID = (int)lookUpServiceEmployeeCode.EditValue;
                    CoEmployee employee = FrequentlyUsedData.GetEmployeeByDepartment(AppendType.None, 1, false).Find(obj => obj.ID == Customers.ServiceEmployeeID);
                    Customers.ServiceEmployeeName = employee == null ? "" : employee.Name;
                    Customers.PayeeName = txtPayeeName.Text.Trim();
                    Customers.PayeePhone = txtPayeePhone.Text.Trim();
                    Customers.BankName = txtBankName.Text.Trim();
                    Customers.BankAccount = txtBankAccount.Text.Trim();
                    Customers.IsTransfer = cheIsTransfer.Checked;
                    Customers.TransferNO = txtTransferNO.Text.Trim();
                    Customers.QueryWork = txtQueryWord.Text.Trim();
                    Customers.Remark = txtRemark.Text.Trim();
                    Customers.IsSMS = cheIsSMS.Checked;
                    Customers.IsPrepaid = cheIsPrepaid.Checked;
                    Customers.IsSpecial = cheIsSpecial.Checked;
                    Customers.ModifyUser = Identity.CurrentUser.UserName;
                    Customers.ModifyDate = DateTime.Now;

                    if (Type == DBOperateType.Insert)
                        WcfServiceHelper.Client.InsertCustomers(Customers);
                    else
                        WcfServiceHelper.Client.UpdateCustomers(Customers);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ControlsHelper.ShowErrorMessage("保存失败", ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Example #2
0
 public FrmCustomersEdit(DBOperateType type, CoCustomers customers)
 {
     InitializeComponent();
     Type = type;
     Customers = customers;
 }