Example #1
0
 public CResult<bool> AddPeople(WebPeopleBasicInfo webPeople)
 {
     var people = new PeopleBasicInfo() {
         WorkerNum = webPeople.WorkerNum,
         PeopleName = webPeople.PeopleName,
         DateOfBirth = webPeople.DateOfBirth,
         Gender = webPeople.Gender,
         Age = webPeople.Age,
         IDCardNum = webPeople.IDCardNum,
         IsMarried = webPeople.IsMarried,
         PoliticalStatus = webPeople.PoliticalStatus,
         Nation = webPeople.Nation,
         HouseholdRegisterAddress = webPeople.HouseholdRegisterAddress,
         HouseholdRegisterType = webPeople.HouseholdRegisterType,
         HouseholdRegisterPostCode = webPeople.HouseholdRegisterPostCode,
         CurrentAddress = webPeople.CurrentAddress,
         PhoneNum = webPeople.PhoneNum,
         CurrentAddressPostCode = webPeople.CurrentAddressPostCode,
         EducationGrade = webPeople.EducationGrade,
         GraduationSchool = webPeople.GraduationSchool,
         Profession = webPeople.Profession,
         EmergencyContactPerson = webPeople.EmergencyContactPerson,
         EmergencyContactPersonPhone = webPeople.EmergencyContactPersonPhone,
         EmergencyContactPersonRelation = webPeople.EmergencyContactPersonRelation
     };
     var result = new PeopleDAL().InsertPeople(people);
     if (result) {
         return new CResult<bool>(true);
     } else {
         return new CResult<bool>(false, ErrorCode.SaveDataFailed);
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren(ValidationConstraints.Enabled) == false) {
                return;
            }
            var webPeople = new WebPeopleBasicInfo() {
                WorkerNum = this.txtWorkerNum.Text,
                PeopleName = this.txtName.Text,
                Gender = this.rbtnMan.Checked ? this.rbtnMan.Text : this.rbtnWoman.Text,
                DateOfBirth = this.dtpDateOfBirth.Value.Date,
                IDCardNum = this.txtIDCardNum.Text,
                IsMarried = this.rbtnMarried.Checked,
                PoliticalStatus = this.cbxPoliticalStatus.Text,
                Nation = this.cbxNation.Text,
                HouseholdRegisterAddress = this.txtHouseholdRegisterAddress.Text,
                HouseholdRegisterType = this.rbtnPeasant.Checked ? this.rbtnPeasant.Text : this.rbtnNotPeasant.Text,
                HouseholdRegisterPostCode = this.txtHouseholdRegisterPostCode.Text,
                CurrentAddress = this.txtCurrentAddress.Text,
                PhoneNum = this.txtPhoneNum.Text,
                CurrentAddressPostCode = this.txtCurrentAddressPostCode.Text,
                EducationGrade = this.cbxEducationGrade.Text,
                GraduationSchool = this.txtGraduationSchool.Text,
                Profession = this.txtProfession.Text,
                EmergencyContactPerson = this.txtEmergencyContactPerson.Text,
                EmergencyContactPersonPhone = this.txtEmergencyContactPersonPhone.Text,
                EmergencyContactPersonRelation = this.txtEmergencyContactPersonRelation.Text,
            };
            int age;
            if (int.TryParse(this.txtAge.Text, out age)) {
                webPeople.Age = age;
            }

            var result = new PeopleBLL().AddPeople(webPeople);
            if (result.Code > 0) {
                MessageBox.Show(result.Message, SystemInfo.ErrorReminderStr, MessageBoxButtons.OK);
                return;
            } else {
                MessageBox.Show(SystemInfo.SuccessReminderStr, SystemInfo.ReminderStr, MessageBoxButtons.OK);
                this.Dispose();
                if (callbackEvent != null) {
                    callbackEvent.Invoke();
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren(ValidationConstraints.Enabled) == false) {
                return;
            }

            var webPeople = new WebPeopleBasicInfo() {
                PeopleID = this._currentPeopleID,
                WorkerNum = this.txtWorkerNum.Text,
                PeopleName = this.txtName.Text,
                Gender = this.rbtnMan.Checked ? this.rbtnMan.Text : this.rbtnWoman.Text,
                DateOfBirth = this.dtpDateOfBirth.Value,
                //Age = int.Parse(this.txtAge.Text),
                IDCardNum = this.txtIDCardNum.Text,
                IsMarried = this.rbtnMarried.Checked,
                PoliticalStatus = this.cbxPoliticalStatus.Text,
                Nation = this.cbxNation.Text,
                HouseholdRegisterAddress = this.txtHouseholdRegisterAddress.Text,
                HouseholdRegisterType = this.rbtnPeasant.Checked ? this.rbtnPeasant.Text : this.rbtnNotPeasant.Text,
                HouseholdRegisterPostCode = this.txtHouseholdRegisterPostCode.Text,
                CurrentAddress = this.txtCurrentAddress.Text,
                PhoneNum = this.txtPhoneNum.Text,
                CurrentAddressPostCode = this.txtCurrentAddressPostCode.Text,
                EducationGrade = this.cbxEducationGrade.Text,
                GraduationSchool = this.txtGraduationSchool.Text,
                Profession = this.txtProfession.Text,
                EmergencyContactPerson = this.txtEmergencyContactPerson.Text,
                EmergencyContactPersonPhone = this.txtEmergencyContactPersonPhone.Text,
                EmergencyContactPersonRelation = this.txtEmergencyContactPersonRelation.Text,
            };
            int age;
            if (int.TryParse(this.txtAge.Text, out age)) {
                webPeople.Age = age;
            }
            var result = new PeopleBLL().UpdatePeople(webPeople);

            MessageHelper.ShowSaveDbResultMessage(result);
        }
Example #4
0
        public CResult<WebPeopleBasicInfo> GetPeopleByID(int peopleID)
        {
            if (peopleID <= 0) {
                return new CResult<WebPeopleBasicInfo>(null, ErrorCode.ParameterError);
            }

            var domainModel = new PeopleDAL().GetPeopleBasicInfoByID(peopleID);
            if (domainModel == null) {
                return new CResult<WebPeopleBasicInfo>(null, ErrorCode.PeopleNotExist);
            } else {
                var result = new WebPeopleBasicInfo() {
                    PeopleID = domainModel.PeopleID,
                    WorkerNum = domainModel.WorkerNum,
                    PeopleName = domainModel.PeopleName,
                    DateOfBirth = domainModel.DateOfBirth,
                    Gender = domainModel.Gender,
                    Age = domainModel.Age,
                    IDCardNum = domainModel.IDCardNum,
                    IsMarried = domainModel.IsMarried,
                    PoliticalStatus = domainModel.PoliticalStatus,
                    Nation = domainModel.Nation,
                    HouseholdRegisterAddress = domainModel.HouseholdRegisterAddress,
                    HouseholdRegisterType = domainModel.HouseholdRegisterType,
                    HouseholdRegisterPostCode = domainModel.HouseholdRegisterPostCode,
                    CurrentAddress = domainModel.CurrentAddress,
                    PhoneNum = domainModel.PhoneNum,
                    CurrentAddressPostCode = domainModel.CurrentAddressPostCode,
                    EducationGrade = domainModel.EducationGrade,
                    GraduationSchool = domainModel.GraduationSchool,
                    Profession = domainModel.Profession,
                    EmergencyContactPerson = domainModel.EmergencyContactPerson,
                    EmergencyContactPersonPhone = domainModel.EmergencyContactPersonPhone,
                    EmergencyContactPersonRelation = domainModel.EmergencyContactPersonRelation
                };
                return new CResult<WebPeopleBasicInfo>(result);
            }
        }