private void btnAddNew_Click(object sender, EventArgs e) { try { if (this.CheckDataBeforeInsert() == true) { DateTime? NullDatetime = null; //thong tin SystemUsers aSystemUsersEN.UserGroup = cboUserGroup.SelectedIndex + 1; aSystemUsersEN.Email = txtEmail.Text; aSystemUsersEN.Username = txtUsername.Text; aSystemUsersEN.Name = txtName.Text; aSystemUsersEN.Phone = txtMobile.Text; aSystemUsersEN.Password = StringUtility.md5(txtUsername.Text + "12345678"); aSystemUsersEN.Birthday = dtpBirthday.EditValue == null ? NullDatetime : dtpBirthday.DateTime; aSystemUsersEN.Identifier1 = txtIdentifier1.Text; aSystemUsersEN.Identifier2 = txtIdentifier2.Text; aSystemUsersEN.Identifier3 = txtIdentifier3.Text; aSystemUsersEN.Image = (Byte[])new ImageConverter().ConvertTo(pbxImage.Image, typeof(Byte[])); aSystemUsersEN.Gender = Convert.ToInt32(lueGender.EditValue); aSystemUsersEN.IDRefAnotherSystem = 1;// de tam aSystemUsersEN.IDRefMailSystem = 1; //de tam aSystemUsersEN.Type = cboType.SelectedIndex + 1; aSystemUsersEN.Status = cboStatus.SelectedIndex + 1; aSystemUsersEN.Disable = Convert.ToBoolean(cboDisable.Text); aSystemUsersEN.Identifier1CreatedDate = dtpIdentifier1.EditValue == null ? NullDatetime : dtpIdentifier1.DateTime; aSystemUsersEN.Identifier2CreatedDate = dtpIdentifier2.EditValue == null ? NullDatetime : dtpIdentifier2.DateTime; aSystemUsersEN.Identifier3CreatedDate = dtpIdentifier3.EditValue == null ? NullDatetime : dtpIdentifier3.DateTime; aSystemUsersEN.PlaceOfIssue1 = txtPlaceOfIssue1.Text; aSystemUsersEN.PlaceOfIssue2 = txtPlaceOfIssue2.Text; aSystemUsersEN.PlaceOfIssue3 = txtPlaceOfIssue3.Text; //thong tin SystemUserExts aSystemUsersEN.aSystemUserExts.BirthPlace = txtBirthPlace.Text; aSystemUsersEN.aSystemUserExts.Hometown = txtHometown.Text; aSystemUsersEN.aSystemUserExts.Address = txtAddress.Text; aSystemUsersEN.aSystemUserExts.InsuranceNumber = txtInsuranceNumber.Text; aSystemUsersEN.aSystemUserExts.YearJob = dtpYearJob.EditValue == null ? NullDatetime : dtpYearJob.DateTime; aSystemUsersEN.aSystemUserExts.YearPayroll = dtpYearPayroll.EditValue == null ? NullDatetime : dtpYearPayroll.DateTime; aSystemUsersEN.aSystemUserExts.YearUnemploymentInsurance = dtpYearUnemploymentInsuarance.EditValue == null ? NullDatetime : dtpYearUnemploymentInsuarance.DateTime; aSystemUsersEN.aSystemUserExts.DifferenceContact = ""; aSystemUsersEN.aSystemUserExts.Type = cboSystemUserExtsType.SelectedIndex + 1; aSystemUsersEN.aSystemUserExts.Status = cboSystemUserExtsStatus.SelectedIndex + 1; aSystemUsersEN.aSystemUserExts.Disable = Convert.ToBoolean(cboSystemUserExtsDisable.Text); aSystemUsersEN.aSystemUserExts.Recruitment = txtRecruitment.Text; aSystemUsersEN.aSystemUserExts.PermanentResidence = txaPermanentResidence.Text; aSystemUsersEN.aSystemUserExts.CommunistPartyDate = dtpCommunistPartyDate.EditValue == null ? NullDatetime : dtpCommunistPartyDate.DateTime; aSystemUsersEN.aSystemUserExts.YouthUnionDate = dtpYouthUnionDate.EditValue == null ? NullDatetime : dtpYouthUnionDate.DateTime; aSystemUsersEN.aSystemUserExts.EnlistmentDate = dtpEnlistmentDate.EditValue == null ? NullDatetime : dtpEnlistmentDate.DateTime; aSystemUsersEN.aSystemUserExts.DemobilizedDate = dtpDemobilizedDate.EditValue == null ? NullDatetime : dtpDemobilizedDate.DateTime; aSystemUsersEN.aSystemUserExts.YearDepartment = dtpYearDepartment.EditValue == null ? NullDatetime : dtpYearDepartment.DateTime; bool martyrsFamily = chkMartysFamily.Checked == true ? true : false; bool woundedFamily = chkWoundedFamily.Checked == true ? true : false; bool laborFamily = chkLaborFamily.Checked == true ? true : false; aSystemUsersEN.aSystemUserExts.MartyrsFamily = martyrsFamily; aSystemUsersEN.aSystemUserExts.WoundedFamily = woundedFamily; aSystemUsersEN.aSystemUserExts.LaborFamily = laborFamily; aSystemUsersEN.aSystemUserExts.HightestAppellation = txtHightestAppellation.Text; ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO(); aReceptionTaskBO.AddSystemUserInformation(aSystemUsersEN); if (ckbIsEmailSync.Checked == true) { SystemUsersBO aSystemUsersBO = new SystemUsersBO(); int ret = aSystemUsersBO.InsertEmailToDatabase(txtUsername.Text, txtPassword.Text, Properties.Resources.Domain1); if (ret <= 0) { MessageBox.Show("Chưa tạo đồng bộ được email"); } } MessageBox.Show("Thêm mới thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception ex) { MessageBox.Show("frmTsk_SystemUser_Infromation.btnAddNew_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }