/// <summary>
        /// 更新
        /// </summary>
        /// <param name="linkManEntity">实体</param>
        /// <param name="statusCode">状态码</param>
        /// <returns>影响行数</returns>
        public int Update(LinkManEntity linkManEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查用户名是否重复
            string[] names  = { LinkManTable.FieldCustomerId, LinkManTable.FieldName, LinkManTable.FieldDeleteMark, };
            string[] values = { linkManEntity.CustomerId.ToString(), linkManEntity.Name, "0" };
            if (this.Exists(names, values, linkManEntity.Id))
            {
                // 用户名已重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                returnValue = this.UpdateEntity(linkManEntity);

                if (returnValue == 0)
                {
                    statusCode = StatusCode.ErrorDeleted.ToString();
                }
                else
                {
                    statusCode = StatusCode.OKUpdate.ToString();
                }
            }

            return(returnValue);
        }
        /// <summary>
        ///  得到指定客户Id的主联系人
        /// </summary>
        /// <param name="customerId">客户Id</param>
        /// <returns>联系人实体</returns>
        public LinkManEntity GetMainByCustomerId(string customerId)
        {
            string[]      names         = { LinkManTable.FieldCustomerId, LinkManTable.FieldMainLinkMan, LinkManTable.FieldDeleteMark, LinkManTable.FieldEnabled };
            string[]      values        = { customerId, "1", "0", "1" };
            LinkManEntity linkManEntity = BaseEntity.Create <LinkManEntity>(this.GetDT(names, values));

            return(linkManEntity);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="linkManEntity">实体</param>
        public int UpdateEntity(LinkManEntity linkManEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, linkManEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(LinkManTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(LinkManTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(LinkManTable.FieldModifiedOn);
            sqlBuilder.SetWhere(LinkManTable.FieldId, linkManEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
        /// <summary>
        /// 新增实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <param name="statusMessage">返回状态消息</param>
        /// <returns>主鍵</returns>
        public string Add(UserInfo userInfo, LinkManEntity entity, out string statusCode, out string statusMessage)
        {
            string returnValue = string.Empty;

            statusCode = string.Empty;

            using (IDbProvider rdiDbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
            {
                try
                {
                    rdiDbProvider.Open(RDIFrameworkDbConection);
                    LogManager.Instance.Add(rdiDbProvider, userInfo, this.serviceName, "新增实体", MethodBase.GetCurrentMethod());

                    using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
                    {
                        try
                        {
                            dbProvider.Open(BusinessDbConnection);
                            LinkManManager manager = new LinkManManager(dbProvider, userInfo);
                            returnValue   = manager.Add(entity, out statusCode);
                            statusMessage = manager.GetStateMessage(statusCode);
                        }
                        catch (Exception ex)
                        {
                            CiExceptionManager.LogException(rdiDbProvider, userInfo, ex);
                            throw ex;
                        }
                        finally
                        {
                            dbProvider.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    CiExceptionManager.LogException(rdiDbProvider, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    rdiDbProvider.Close();
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="linkManEntity">实体</param>
        /// <returns>主键</returns>
        public string Add(LinkManEntity linkManEntity, out string statusCode)
        {
            string returnValue = string.Empty;

            if (this.Exists(new string[] { LinkManTable.FieldCustomerId, LinkManTable.FieldName, CustomerTable.FieldDeleteMark }, new string[] { linkManEntity.CustomerId.ToString(), linkManEntity.Name, "0" }))
            {
                returnValue = string.Empty;
                statusCode  = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(linkManEntity);
                statusCode  = StatusCode.OKAdd.ToString();
            }
            return(returnValue);

            ;
        }
        private void BindEditData()
        {
            currentCustomerEntity = customerService.GetEntity(base.UserInfo, currentCustomerId);

            if (currentCustomerEntity != null)
            {
                //得到主联系人
                currentLinkManEntity = linkMainService.GetMainByCustomerId(base.UserInfo, currentCustomerEntity.Id.ToString());
                //绑定客户信息界面
                txtFullName.Text         = currentCustomerEntity.FullName;
                txtShortName.Text        = currentCustomerEntity.ShortName;
                txtCompanyName.Text      = currentCustomerEntity.CompanyName;
                txtCompanyAddress.Text   = currentCustomerEntity.CompanyAddress;
                txtPostalCode.Text       = currentCustomerEntity.PostalCode;
                txtCompanyPhone.Text     = currentCustomerEntity.CompanyPhone;
                txtCompanyFax.Text       = currentCustomerEntity.CompanyFax;
                txtWebAddress.Text       = currentCustomerEntity.WebAddress;
                txtBank.Text             = currentCustomerEntity.Bank;
                txtBankAccount.Text      = currentCustomerEntity.BankAccount;
                txtBankroll.Text         = currentCustomerEntity.Bankroll.ToString();
                txtTurnover.Text         = currentCustomerEntity.Turnover.ToString();
                txtLicenceNo.Text        = currentCustomerEntity.LicenceNo;
                txtLocalTaxNo.Text       = currentCustomerEntity.LocalTaxNo;
                txtNationalTaxNo.Text    = currentCustomerEntity.NationalTaxNo;
                txtDescription.Text      = currentCustomerEntity.Description;
                cboStatus.SelectedValue  = currentCustomerEntity.Status;
                cboSatisfy.SelectedValue = currentCustomerEntity.Satisfy;
                cboCredit.SelectedValue  = currentCustomerEntity.Credit;
                dtEstablishDate.Text     = BusinessLogic.ConvertToDateToString(currentCustomerEntity.EstablishDate == null ? string.Empty : currentCustomerEntity.EstablishDate.ToString());
                if (currentLinkManEntity != null && currentLinkManEntity.Id > 0)
                {
                    //绑定主联系人界面
                    txtName.Text             = currentLinkManEntity.Name;
                    txtDepartment.Text       = currentLinkManEntity.Department;
                    cboPostion.SelectedValue = currentLinkManEntity.Postion;
                    cboSex.SelectedValue     = currentLinkManEntity.Sex;
                    txtMobilePhone.Text      = currentLinkManEntity.MobilePhone;
                    txtEmail.Text            = currentLinkManEntity.Email;
                    txtQQ.Text       = currentLinkManEntity.QQ;
                    txtInterest.Text = currentLinkManEntity.Interest;
                }
            }
        }
Beispiel #7
0
 private void BindEditData()
 {
     if (!string.IsNullOrEmpty(currentLinkManId.Trim()))
     {
         currentLinkManEntity     = linkMainService.GetEntity(base.UserInfo, currentLinkManId);
         txtName.Text             = currentLinkManEntity.Name;
         chkMainLinkMan.Checked   = BusinessLogic.ConvertIntToBoolean(currentLinkManEntity.MainLinkMan);
         cboSex.SelectedValue     = currentLinkManEntity.Sex;
         cboPostion.SelectedValue = currentLinkManEntity.Postion;
         txtDepartment.Text       = currentLinkManEntity.Department;
         txtMobilePhone.Text      = currentLinkManEntity.MobilePhone;
         txtTelephone.Text        = currentLinkManEntity.Telephone;
         txtHomePhone.Text        = currentLinkManEntity.HomePhone;
         txtOfficeFax.Text        = currentLinkManEntity.OfficeFax;
         txtIDCard.Text           = currentLinkManEntity.IDCard;
         txtOfficeAddress.Text    = currentLinkManEntity.OfficeAddress;
         txtQQ.Text          = currentLinkManEntity.QQ;
         txtEmail.Text       = currentLinkManEntity.Email;
         txtInterest.Text    = currentLinkManEntity.Interest;
         txtDescription.Text = currentLinkManEntity.Description;
         txtMajor.Text       = currentLinkManEntity.Major;
         txtSchool.Text      = currentLinkManEntity.School;
         cboEducationalBackground.SelectedValue = currentLinkManEntity.EducationalBackground;
         cboDegree.SelectedValue    = currentLinkManEntity.Degree;
         txtHomeZipCode.Text        = currentLinkManEntity.HomeZipCode;
         txtHomeFax.Text            = currentLinkManEntity.HomeFax;
         txtHomeAddress.Text        = currentLinkManEntity.HomeAddress;
         txtNation.Text             = currentLinkManEntity.Nation;
         cboParty.SelectedValue     = currentLinkManEntity.Party;
         txtNativePlace.Text        = currentLinkManEntity.NativePlace;
         txtNationality.Text        = currentLinkManEntity.Nationality;
         cboBloodType.SelectedValue = currentLinkManEntity.BloodType;
         if (currentLinkManEntity.BirthdayType == 1)
         {
             radGregorianCalendar.Checked = true;
         }
         else
         {
             radLunarCalendar.Checked = true;
         }
         dtBirthday.Text = BusinessLogic.ConvertToDateToString(currentLinkManEntity.Birthday == null ? string.Empty : currentLinkManEntity.Birthday.ToString());
     }
 }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="linkManEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, LinkManEntity linkManEntity)
 {
     SetEntityExpand(sqlBuilder, linkManEntity);
     sqlBuilder.SetValue(LinkManTable.FieldCustomerId, linkManEntity.CustomerId);
     sqlBuilder.SetValue(LinkManTable.FieldName, linkManEntity.Name);
     sqlBuilder.SetValue(LinkManTable.FieldSex, linkManEntity.Sex);
     sqlBuilder.SetValue(LinkManTable.FieldPostion, linkManEntity.Postion);
     sqlBuilder.SetValue(LinkManTable.FieldDepartment, linkManEntity.Department);
     sqlBuilder.SetValue(LinkManTable.FieldMainLinkMan, linkManEntity.MainLinkMan);
     sqlBuilder.SetValue(LinkManTable.FieldMobilePhone, linkManEntity.MobilePhone);
     sqlBuilder.SetValue(LinkManTable.FieldTelephone, linkManEntity.Telephone);
     sqlBuilder.SetValue(LinkManTable.FieldShortNumber, linkManEntity.ShortNumber);
     sqlBuilder.SetValue(LinkManTable.FieldIDCard, linkManEntity.IDCard);
     sqlBuilder.SetValue(LinkManTable.FieldOfficeAddress, linkManEntity.OfficeAddress);
     sqlBuilder.SetValue(LinkManTable.FieldOfficeFax, linkManEntity.OfficeFax);
     sqlBuilder.SetValue(LinkManTable.FieldHomePhone, linkManEntity.HomePhone);
     sqlBuilder.SetValue(LinkManTable.FieldEducation, linkManEntity.Education);
     sqlBuilder.SetValue(LinkManTable.FieldSchool, linkManEntity.School);
     sqlBuilder.SetValue(LinkManTable.FieldDegree, linkManEntity.Degree);
     sqlBuilder.SetValue(LinkManTable.FieldHomeZipCode, linkManEntity.HomeZipCode);
     sqlBuilder.SetValue(LinkManTable.FieldHomeAddress, linkManEntity.HomeAddress);
     sqlBuilder.SetValue(LinkManTable.FieldHomeFax, linkManEntity.HomeFax);
     sqlBuilder.SetValue(LinkManTable.FieldNativePlace, linkManEntity.NativePlace);
     sqlBuilder.SetValue(LinkManTable.FieldParty, linkManEntity.Party);
     sqlBuilder.SetValue(LinkManTable.FieldNation, linkManEntity.Nation);
     sqlBuilder.SetValue(LinkManTable.FieldNationality, linkManEntity.Nationality);
     sqlBuilder.SetValue(LinkManTable.FieldMajor, linkManEntity.Major);
     sqlBuilder.SetValue(LinkManTable.FieldEducationalBackground, linkManEntity.EducationalBackground);
     sqlBuilder.SetValue(LinkManTable.FieldBirthdayType, linkManEntity.BirthdayType);
     sqlBuilder.SetValue(LinkManTable.FieldBirthday, linkManEntity.Birthday);
     sqlBuilder.SetValue(LinkManTable.FieldBloodType, linkManEntity.BloodType);
     sqlBuilder.SetValue(LinkManTable.FieldQQ, linkManEntity.QQ);
     sqlBuilder.SetValue(LinkManTable.FieldEmail, linkManEntity.Email);
     sqlBuilder.SetValue(LinkManTable.FieldInterest, linkManEntity.Interest);
     sqlBuilder.SetValue(LinkManTable.FieldDescription, linkManEntity.Description);
     sqlBuilder.SetValue(LinkManTable.FieldDeleteMark, linkManEntity.DeleteMark);
     sqlBuilder.SetValue(LinkManTable.FieldEnabled, linkManEntity.Enabled);
     sqlBuilder.SetValue(LinkManTable.FieldSortCode, linkManEntity.SortCode);
 }
        /// <summary>
        /// 取得实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public LinkManEntity GetEntity(UserInfo userInfo, string id)
        {
            LinkManEntity entity = null;

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
            {
                try
                {
                    dbProvider.Open(BusinessDbConnection);
                    LinkManManager manager = new LinkManManager(dbProvider, userInfo);
                    entity = manager.GetEntity(id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }
            return(entity);
        }
 // 这个是声明扩展方法
 partial void SetEntityExpand(SQLBuilder sqlBuilder, LinkManEntity linkManEntity);
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="linkManEntity">实体</param>
        public string AddEntity(LinkManEntity linkManEntity)
        {
            string sequence = string.Empty;

            if (linkManEntity.SortCode == null || linkManEntity.SortCode == 0)
            {
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                linkManEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, LinkManTable.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(LinkManTable.FieldId, linkManEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(LinkManTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(LinkManTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (linkManEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            linkManEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(LinkManTable.FieldId, linkManEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, linkManEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(LinkManTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(LinkManTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(LinkManTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(LinkManTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(LinkManTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(LinkManTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="linkManEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(LinkManEntity linkManEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(linkManEntity));
 }
        private void SaveEditData()
        {
            if (CheckValueIsEmpty())
            {
                // 设置鼠标繁忙状态,并保留原先的状态
                Cursor holdCursor = this.Cursor;
                this.Cursor = Cursors.WaitCursor;

                currentCustomerEntity.CustomerClassID = BusinessLogic.ConvertToInt(CurrentEntityId);
                currentCustomerEntity.FullName        = txtFullName.Text.Trim();
                currentCustomerEntity.ShortName       = txtShortName.Text.Trim();
                currentCustomerEntity.CompanyName     = txtCompanyName.Text.Trim();
                currentCustomerEntity.Satisfy         = string.IsNullOrEmpty(cboSatisfy.SelectedValue.ToString()) ? 3 : BusinessLogic.ConvertToInt(cboSatisfy.SelectedValue);
                currentCustomerEntity.Credit          = string.IsNullOrEmpty(cboCredit.SelectedValue.ToString()) ? 3 : BusinessLogic.ConvertToInt(cboCredit.SelectedValue);
                currentCustomerEntity.CompanyAddress  = txtCompanyAddress.Text.Trim();
                currentCustomerEntity.PostalCode      = txtPostalCode.Text.Trim();
                currentCustomerEntity.CompanyPhone    = txtCompanyPhone.Text.Trim();
                currentCustomerEntity.CompanyFax      = txtCompanyFax.Text.Trim();
                currentCustomerEntity.WebAddress      = txtWebAddress.Text.Trim();
                currentCustomerEntity.EstablishDate   = BusinessLogic.ConvertToDateTime(dtEstablishDate.Text);
                currentCustomerEntity.LicenceNo       = txtLicenceNo.Text.Trim();
                currentCustomerEntity.Chieftain       = txtChieftain.Text.Trim();
                currentCustomerEntity.Bankroll        = BusinessLogic.ConvertToInt(txtBankroll.Text.Trim());
                currentCustomerEntity.Turnover        = BusinessLogic.ConvertToInt(txtTurnover.Text.Trim());
                currentCustomerEntity.Bank            = txtBank.Text.Trim();
                currentCustomerEntity.BankAccount     = txtBankAccount.Text.Trim();
                currentCustomerEntity.LocalTaxNo      = txtLocalTaxNo.Text.Trim();
                currentCustomerEntity.NationalTaxNo   = txtNationalTaxNo.Text.Trim();
                currentCustomerEntity.Status          = string.IsNullOrEmpty(cboStatus.SelectedValue.ToString()) ? 1 : BusinessLogic.ConvertToInt(cboStatus.SelectedValue);
                currentCustomerEntity.Description     = txtDescription.Text.Trim();

                string statusCode    = string.Empty;
                string statusMessage = string.Empty;
                int    returnValue   = customerService.Update(base.UserInfo, currentCustomerEntity, out statusCode, out statusMessage);
                string information   = statusMessage;
                if (returnValue > 0)
                {
                    this.Changed = true;
                    if (currentLinkManEntity == null || currentLinkManEntity.Id <= 0)
                    {
                        currentLinkManEntity = new LinkManEntity();
                    }
                    currentLinkManEntity.CustomerId  = BusinessLogic.ConvertToInt(currentCustomerId);
                    currentLinkManEntity.MainLinkMan = 1;
                    currentLinkManEntity.Name        = txtName.Text.Trim();
                    currentLinkManEntity.Department  = txtDepartment.Text.Trim();
                    currentLinkManEntity.Postion     = BusinessLogic.ConvertToString(cboPostion.SelectedValue);
                    currentLinkManEntity.Sex         = BusinessLogic.ConvertToString(cboSex.SelectedValue);
                    currentLinkManEntity.MobilePhone = txtMobilePhone.Text.Trim();
                    currentLinkManEntity.Email       = txtEmail.Text.Trim();
                    currentLinkManEntity.QQ          = txtQQ.Text.Trim();
                    currentLinkManEntity.Interest    = txtInterest.Text.Trim();
                    string reValue = string.Empty;
                    if (currentLinkManEntity.Id == null || currentLinkManEntity.Id <= 0)
                    {
                        reValue = linkMainService.Add(base.UserInfo, currentLinkManEntity, out statusCode, out statusMessage);
                    }
                    else
                    {
                        reValue = linkMainService.Update(base.UserInfo, currentLinkManEntity, out statusCode, out statusMessage).ToString();
                    }
                    if (BusinessLogic.ConvertToInt32(reValue) <= 0)
                    {
                        information += "\n主联系人" + statusMessage;
                    }
                }

                MessageBoxHelper.ShowInformationMsg(information);

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

                if (this.Changed)
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
            }
        }
        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();
                }
            }
        }
Beispiel #15
0
        private void SaveData(bool close)
        {
            if (string.IsNullOrEmpty(txtName.Text.Trim()))
            {
                MessageBoxHelper.ShowWarningMsg(txtName.Tag.ToString() + "不能为空!");
                txtName.Focus();
                return;
            }

            // 设置鼠标繁忙状态,并保留原先的状态
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            LinkManEntity linkManEntity = new LinkManEntity
            {
                CustomerId            = BusinessLogic.ConvertToInt(currentCustomerId),
                Name                  = txtName.Text.Trim(),
                MainLinkMan           = chkMainLinkMan.Checked ? 1 : 0,
                Sex                   = cboSex.SelectedValue.ToString(),
                Postion               = cboPostion.SelectedValue.ToString(),
                Department            = txtDepartment.Text.Trim(),
                MobilePhone           = txtMobilePhone.Text.Trim(),
                Telephone             = txtTelephone.Text.Trim(),
                HomePhone             = txtHomePhone.Text.Trim(),
                OfficeFax             = txtOfficeFax.Text.Trim(),
                IDCard                = txtIDCard.Text.Trim(),
                OfficeAddress         = txtOfficeAddress.Text.Trim(),
                QQ                    = txtQQ.Text.Trim(),
                Email                 = txtEmail.Text.Trim(),
                Interest              = txtInterest.Text.Trim(),
                Description           = txtDescription.Text.Trim(),
                Major                 = txtMajor.Text.Trim(),
                School                = txtSchool.Text.Trim(),
                EducationalBackground = cboEducationalBackground.SelectedValue.ToString(),
                Degree                = cboDegree.SelectedValue.ToString(),
                HomeZipCode           = txtHomeZipCode.Text.Trim(),
                HomeFax               = txtHomeFax.Text.Trim(),
                HomeAddress           = txtHomeAddress.Text.Trim(),
                NativePlace           = txtNativePlace.Text.Trim(),
                Party                 = cboParty.SelectedValue.ToString(),
                Nation                = txtNation.Text.Trim(),
                Nationality           = txtNationality.Text.Trim(),
                BloodType             = cboBloodType.SelectedValue.ToString(),
                BirthdayType          = 1
            };

            if (radLunarCalendar.Checked)
            {
                linkManEntity.BirthdayType = 2; //农历生日
            }
            linkManEntity.Birthday = BusinessLogic.ConvertToDateTime(dtBirthday.Text);
            string statusCode    = string.Empty;
            string statusMessage = string.Empty;
            string linkManId     = linkMainService.Add(base.UserInfo, linkManEntity, out statusCode, out statusMessage);

            if (linkManId.Trim().Length > 0)
            {
                this.Changed = true;
            }
            MessageBoxHelper.ShowInformationMsg(statusMessage);
            // 设置鼠标默认状态,原来的光标状态
            this.Cursor = holdCursor;

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