Exemplo n.º 1
0
        /// <summary>
        /// 将界面控件中的值,绑定给关联对象。
        /// </summary>
        private void BindFormlToObject()
        {
            if (!DataValid.IsNullOrInt(DrpSex.SelectedValue.ToString()))
            {
                throw new CustomException("“性别”的编号,不是一个有效的整数,请您重新输入。");
            }

            if (!DataValid.IsNullOrDateTime(TxtDateOfBirth.Text))
            {
                throw new CustomException("“出生日期”不是一个有效格式的日期,正确格式应为“" + DateTime.Now.ToString("yyyy-MM-dd") + "”,请您重新输入。");
            }

            if (!DataValid.IsNullOrInt(DrpDepartment.SelectedValue.ToString()))
            {
                throw new CustomException("“所在部门”的自动编号,不是一个有效的整数,请您重新输入。");
            }

            employee.BadgeId                      = DataValid.GetNullOrString(TxtBadgeId.Text);                                                                                                                                        // 工号
            employee.Name                         = DataValid.GetNullOrString(TxtName.Text);                                                                                                                                           // 姓名
            employee.Sex                          = Sex.GetDataById(DataValid.GetNullOrInt(DrpSex.SelectedValue.ToString()).Value);                                                                                                    // 性别
            employee.DateOfBirth                  = DataValid.GetNullOrDateTime(TxtDateOfBirth.Text);                                                                                                                                  // 出生日期
            employee.IDCardId                     = DataValid.GetNullOrString(TxtIDCardId.Text);                                                                                                                                       // 身份证号
            employee.Nationa                      = DataValid.GetNullOrString(TxtNationa.Text);                                                                                                                                        // 民族
            employee.PoliticalLandscape           = DataValid.GetNullOrString(TxtPoliticalLandscape.Text);                                                                                                                             // 政治面貌
            employee.MaritalStatus                = DataValid.GetNullOrString(TxtMaritalStatus.Text);                                                                                                                                  // 婚姻状况
            employee.PlaceOfHouseholdRegistration = DataValid.GetNullOrString(TxtPlaceOfHouseholdRegistration.Text);                                                                                                                   // 户口所在地
            employee.Department                   = (DataValid.GetNullOrInt(DrpDepartment.SelectedValue.ToString()) != null) ? DepartmentBLL.GetDataById(DataValid.GetNullOrInt(DrpDepartment.SelectedValue.ToString()).Value) : null; // 所在部门
            employee.ResidenceAddress             = DataValid.GetNullOrString(TxtResidenceAddress.Text);                                                                                                                               // 现居住住址
            employee.GraduateSchool               = DataValid.GetNullOrString(TxtGraduateSchool.Text);                                                                                                                                 // 毕业学校
            employee.FieldOfStudy                 = DataValid.GetNullOrString(TxtFieldOfStudy.Text);                                                                                                                                   // 所学专业
            employee.GraduationDate               = DataValid.GetNullOrString(TxtGraduationDate.Text);                                                                                                                                 // 毕业时间
            employee.AcademicQualifications       = DataValid.GetNullOrString(TxtAcademicQualifications.Text);                                                                                                                         // 学历
            employee.ContactPhone                 = DataValid.GetNullOrString(TxtContactPhone.Text);                                                                                                                                   // 联系电话
            employee.EmergencyContacts            = DataValid.GetNullOrString(TxtEmergencyContacts.Text);                                                                                                                              // 紧急联系人
            employee.EmergencyTelephone           = DataValid.GetNullOrString(TxtEmergencyTelephone.Text);                                                                                                                             // 紧急电话
        }