コード例 #1
0
 private void InitThongTinGiaDinh(PMNS.Entities.Models.ThongTinGiaDinh giaDinh)
 {
     if (giaDinh != null)
     {
         lblHoTenBo.Text           = giaDinh.hoTenCha;
         lblHoTenMe.Text           = giaDinh.hoTenMe;
         lblNamSinhBo.Text         = giaDinh.namSinhCha.ToString("yyyy");
         lblNamSinhme.Text         = giaDinh.namSinhMe.ToString("yyyy");
         lblNgheNghiepBo.Text      = giaDinh.ngheNghiepCha;
         lblNgheNghiepMe.Text      = giaDinh.ngheNghiepMe;
         lblHoTenVoChong.Text      = giaDinh.hoTenVoChong;
         lblNgheNghiepVoChong.Text = giaDinh.ngheNghiepVoChong;
         lblNamSinhVoChong.Text    = Convert.ToDateTime(giaDinh.namSinhVoChong).ToString("yyyy");
         txtConCai.Text            = giaDinh.thongTinConCai;
     }
     else
     {
         lblHoTenBo.Text           = "Chưa Cập Nhật";
         lblHoTenMe.Text           = "Chưa Cập Nhật";
         lblNamSinhBo.Text         = "Chưa Cập Nhật";
         lblNamSinhme.Text         = "Chưa Cập Nhật";
         lblNgheNghiepBo.Text      = "Chưa Cập Nhật";
         lblNgheNghiepMe.Text      = "Chưa Cập Nhật";
         lblHoTenVoChong.Text      = "Chưa Cập Nhật";
         lblNgheNghiepVoChong.Text = "Chưa Cập Nhật";
         lblNamSinhVoChong.Text    = "Chưa Cập Nhật";
         txtConCai.Text            = "Chưa Cập Nhật";
     }
 }
コード例 #2
0
 private void btnFunction_Click(object sender, EventArgs e)
 {
     if (empDetails.ThongTinGiaDinhs.Count != 0)
     {
         try
         {
             empDetails.ThongTinGiaDinhs.FirstOrDefault().hoTenCha          = txtHoTenCha.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().namSinhCha        = datetimeNgaySinhCha.Value;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().ngheNghiepCha     = txtNgheNghiepCha.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().hoTenMe           = txtHoTenMe.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().namSinhMe         = dateTimeNgaySinhMe.Value;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().ngheNghiepMe      = txtNgheNghiepMe.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().hoTenVoChong      = txtHoTenVoChong.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().ngheNghiepVoChong = txtNgheNghiepVoChong.Text;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().namSinhVoChong    = datetimeNgaySinhCV.Value;
             empDetails.ThongTinGiaDinhs.FirstOrDefault().thongTinConCai    = txtConCai.Text;
             thongTinGiaDinhServices.CommitThongTinGiaDinh();
             MessageBox.Show("Đã Chỉnh Sửa Thông Tin Thành Công!", "Thông Báo!", MessageBoxButtons.OK);
             this.Close();
         }
         catch (Exception ex)
         {
             if (UserProfile.permission == 1)
             {
                 MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show("Đã Có Lỗi! Vui Lòng Kiểm Tra Thông Tin Đầu Vào!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         try
         {
             var familyInfo = new Entities.Models.ThongTinGiaDinh
             {
                 hoTenCha          = txtHoTenCha.Text,
                 namSinhCha        = datetimeNgaySinhCha.Value,
                 ngheNghiepCha     = txtNgheNghiepCha.Text,
                 hoTenMe           = txtHoTenMe.Text,
                 namSinhMe         = dateTimeNgaySinhMe.Value,
                 ngheNghiepMe      = txtNgheNghiepMe.Text,
                 hoTenVoChong      = txtHoTenVoChong.Text,
                 namSinhVoChong    = datetimeNgaySinhCV.Value,
                 ngheNghiepVoChong = txtNgheNghiepVoChong.Text,
                 thongTinConCai    = txtConCai.Text
             };
             empDetails.ThongTinGiaDinhs.Add(familyInfo);
             thongTinGiaDinhServices.CommitThongTinGiaDinh();
             MessageBox.Show("Đã Thêm Thông Tin Thành Công!", "Thông Báo!", MessageBoxButtons.OK);
             this.Close();
         }
         catch (Exception ex)
         {
             if (UserProfile.permission == 1)
             {
                 MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 MessageBox.Show("Đã Có Lỗi! Vui Lòng Kiểm Tra Thông Tin Đầu Vào!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }