Exemplo n.º 1
0
 private void btnluu_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (!Checkghi())
         {
             return;
         }
         if (!CheckUpdate)
         {
             var hs = new SinhVien
             {
                 MaSV     = int.Parse(txtmasinhvien.Text),
                 HoSV     = txthotendem.Text,
                 TenSV    = txttensinhvien.Text,
                 NgaySinh = cbongaysinh.Text,
                 IdLop    = _idlop,
             };
             InsertData.ThemSinhVien(hs);
             Themmoisinhvien(sender, hs, cbolop.Text, cbokhoa.Text);
             MessageBox.Show(@"Đã Thêm mới một sinh viên");
         }
         else
         {
             var hs1 = new SinhVien
             {
                 MaSV     = int.Parse(txtmasinhvien.Text),
                 HoSV     = txthotendem.Text,
                 TenSV    = txttensinhvien.Text,
                 NgaySinh = cbongaysinh.Text,
                 IdLop    = _idlop
             };
             if (UpdateData.UpdateSv(hs1))
             {
                 MessageBox.Show(@"Chỉnh sửa thành công", @"Thông báo");
                 CheckUpdate = false;
             }
             else
             {
                 MessageBox.Show(@"Sai thông tin lớp", @"Thông báo");
             }
             Close();
         }
     }
     catch (Exception ex)
     {
         Log2File.LogExceptionToFile(ex);
     }
 }