コード例 #1
0
        private void SaveData(bool close)
        {
            if (CheckValueIsEmpty())
            {
                // 设置鼠标繁忙状态,并保留原先的状态
                Cursor holdCursor = this.Cursor;
                this.Cursor = Cursors.WaitCursor;
                var customerEntity = new CustomerEntity
                {
                    Code            = BusinessLogic.NewGuid(),
                    CustomerClassID = BusinessLogic.ConvertToInt(CurrentEntityId),
                    FullName        = txtFullName.Text.Trim(),
                    ShortName       = txtShortName.Text.Trim(),
                    CompanyName     = txtCompanyName.Text.Trim(),
                    Satisfy         = string.IsNullOrEmpty(cboSatisfy.SelectedValue.ToString())
                            ? 3
                            : BusinessLogic.ConvertToInt(cboSatisfy.SelectedValue),
                    Credit = string.IsNullOrEmpty(cboCredit.SelectedValue.ToString())
                            ? 3
                            : BusinessLogic.ConvertToInt(cboCredit.SelectedValue),
                    CompanyAddress = txtCompanyAddress.Text.Trim(),
                    PostalCode     = txtPostalCode.Text.Trim(),
                    CompanyPhone   = txtCompanyPhone.Text.Trim(),
                    CompanyFax     = txtCompanyFax.Text.Trim(),
                    WebAddress     = txtWebAddress.Text.Trim(),
                    EstablishDate  = BusinessLogic.ConvertToDateTime(dtEstablishDate.Text),
                    LicenceNo      = txtLicenceNo.Text.Trim(),
                    Chieftain      = txtChieftain.Text.Trim(),
                    Bankroll       = BusinessLogic.ConvertToInt(txtBankroll.Text.Trim()),
                    Turnover       = BusinessLogic.ConvertToInt(txtTurnover.Text.Trim()),
                    Bank           = txtBank.Text.Trim(),
                    BankAccount    = txtBankAccount.Text.Trim(),
                    LocalTaxNo     = txtLocalTaxNo.Text.Trim(),
                    NationalTaxNo  = txtNationalTaxNo.Text.Trim(),
                    Status         = string.IsNullOrEmpty(cboStatus.SelectedValue.ToString())
                            ? 1
                            : BusinessLogic.ConvertToInt(cboStatus.SelectedValue),
                    Description = txtDescription.Text.Trim()
                };

                string statusCode    = string.Empty;
                string statusMessage = string.Empty;
                string customerId    = customerService.Add(base.UserInfo, customerEntity, out statusCode, out statusMessage);
                string information   = statusMessage;
                if (customerId.Length > 0)
                {
                    this.Changed = true;
                    LinkManEntity linkMainEntity = new LinkManEntity
                    {
                        CustomerId  = BusinessLogic.ConvertToInt(customerId),
                        MainLinkMan = 1,
                        Name        = txtName.Text.Trim(),
                        Department  = txtDepartment.Text.Trim(),
                        Postion     = cboPostion.SelectedValue.ToString(),
                        Sex         = cboSex.SelectedValue.ToString(),
                        MobilePhone = txtMobilePhone.Text.Trim(),
                        Email       = txtEmail.Text.Trim(),
                        QQ          = txtQQ.Text.Trim(),
                        Interest    = txtInterest.Text.Trim()
                    };
                    string value = linkMainService.Add(base.UserInfo, linkMainEntity, out statusCode, out statusMessage);
                    if (value.Length <= 0)
                    {
                        information += "\n主联系人" + statusMessage;
                    }
                }

                MessageBoxHelper.ShowInformationMsg(information);

                // 设置鼠标默认状态,原来的光标状态
                this.Cursor = holdCursor;

                if (this.Changed && close)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            }
        }