Exemple #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (int.TryParse(lblID.Text, out _ID))
     {
     }
     if (int.TryParse(lblIdTrangThai.Text, out _Id))
     {
     }
     if (CheckObject())
     {
         Entities.tblChuongTrinh ct = new Entities.tblChuongTrinh();
         ct.Id             = _ID;
         ct.Idtrangthai    = _Id;
         ct.Machuongtrinh  = txtMaChuongTrinh.Text;
         ct.Tenchuongtrinh = txtTenChuongTrinh.Text;
         if (flag == "add")
         {
             bool check = bllChuongTrinh.insertChuongTrinh(ct);
             if (check)
             {
                 MessageBox.Show("Thêm thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             ReLoad();
         }
         else if (flag == "update")
         {
             bool check = bllChuongTrinh.updateChuongTrinh(ct);
             if (check)
             {
                 MessageBox.Show("Cập nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             ReLoad();
         }
         else if (flag == "delete")
         {
             bool check = bllChuongTrinh.deleteChuongTrinh(ct);
             if (check)
             {
                 MessageBox.Show("Xóa thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             ReLoad();
         }
         ReLoad();
         dgvChuongTrinh_SelectionChanged(sender, e);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (int.TryParse(lblIdTrangThai.Text, out _Idtt))
     {
     }
     if (int.TryParse(lblsiso.Text, out _ss))
     {
     }
     if (int.TryParse(lblidtaikhoan.Text, out _Idtk))
     {
     }
     if (int.TryParse(lblidchuongtrinh.Text, out _Idct))
     {
     }
     if (int.TryParse(lblmakhoa.Text, out _Idkh))
     {
     }
     if (int.TryParse(lblidtinchi.Text, out _Idtc))
     {
     }
     if (int.TryParse(lblidsinhvien.Text, out _Idsv))
     {
     }
     if (int.TryParse(lblidnienkhoa.Text, out _Idnk))
     {
     }
     if (int.TryParse(lblidmonhoc.Text, out _Idmh))
     {
     }
     if (int.TryParse(lblidketqua.Text, out _Idkq))
     {
     }
     if (int.TryParse(lblIdLop.Text, out _Idlp))
     {
     }
     if (int.TryParse(lblIdHocKy.Text, out _Idhk))
     {
     }
     if (int.TryParse(lblidnhom.Text, out _Idnh))
     {
     }
     if (float.TryParse(lbldiemthilan1.Text, out dtl1))
     {
     }
     if (float.TryParse(lbldiemthilan2.Text, out dtl2))
     {
     }
     if (float.TryParse(lbldiemtongket.Text, out dtk))
     {
     }
     if (float.TryParse(lbldiemtrungbinh.Text, out dtb))
     {
     }
     if (DateTime.TryParse(lblnamsinh.Text, out _ns))
     {
     }
     Entities.tblTrangThai tt = new Entities.tblTrangThai();
     tt.Id           = _Idtt;
     tt.Matrangthai  = lblmatrangthai.Text;
     tt.Tentrangthai = cbTenTrangThai.Text;
     Entities.tblChuongTrinh ct = new Entities.tblChuongTrinh();
     ct.Id             = _Idct;
     ct.Idtrangthai    = _Idtt;
     ct.Machuongtrinh  = lblmachuongtrinh.Text;
     ct.Tenchuongtrinh = cbTenChuongTrinh.Text;
     Entities.tblMonHoc mh = new Entities.tblMonHoc();
     mh.Id            = _Idmh;
     mh.Idchuongtrinh = _Idct;
     mh.Idhocky       = _Idhk;
     mh.Idtinchi      = _Idtc;
     mh.Mamonhoc      = lblmamonhoc.Text;
     mh.Tenmonhoc     = lbltenmonhoc.Text;
     Entities.tblLop lp = new Entities.tblLop();
     lp.Id     = _Idlp;
     lp.Idkhoa = _Idkh;
     lp.Malop  = lblmalop.Text;
     lp.Tenlop = cbTenLop.Text;
     lp.Siso   = _ss;
     Entities.tblSinhVien sv = new Entities.tblSinhVien();
     sv.Id          = _Idsv;
     sv.Idlop       = _Idlp;
     sv.Idtaikhoan  = _Idtk;
     sv.Idtrangthai = _Idtt;
     Entities.tblKetQua kq = new Entities.tblKetQua();
     kq.Id            = _Idkq;
     kq.Idsinhvien    = _Idsv;
     kq.Idmonhoc      = _Idmh;
     kq.Diemthilan1   = dtl1;
     kq.Diemthilan2   = dtl2;
     kq.Diemtrungbinh = dtb;
     kq.Diemtongket   = dtk;
     kq.Hanhkiem      = lblhanhkiem.Text;
     kq.Ghichu        = lblghichu.Text;
     Entities.tblTaiKhoan tk = new Entities.tblTaiKhoan();
     tk.Id          = _Idtk;
     tk.Idnhom      = _Idnh;
     tk.Tentaikhoan = lbltentaikhoan.Text;
     tk.Matkhau     = lblmatkhau.Text;
     tk.Hoten       = cbHoTen.Text;
     tk.Namsinh     = _ns;
     tk.Gioitinh    = lblgioitinh.Text;
     tk.Diachi      = lbldiachi.Text;
     tk.Email       = lblemail.Text;
     tk.Dienthoai   = lbldienthoai.Text;
     Entities.tblHocKy hk = new Entities.tblHocKy();
     hk.Id       = _Idhk;
     hk.Mahocky  = lblmahocky.Text;
     hk.Tenhocky = cbTenHocKy.Text;
     Entities.tblKhoa kh = new Entities.tblKhoa();
     kh.Id      = _Idkh;
     kh.Makhoa  = lblmakhoa.Text;
     kh.Tenkhoa = cbTenKhoa.Text;
     if (flag == "update")
     {
         bool check = bllTaiKhoan.updateTaiKhoan(tk);
         bllSinhVien.updateSinhVien(sv);
         bllChuongTrinh.updateChuongTrinh(ct);
         bllTrangThai.updateTrangThai(tt);
         //bllLop.updateLop(lp);
         //bllKhoa.updateKhoa(kh);
         //bllKetQua.updateKetQua(kq);
         //bllMonHoc.updateMonHoc(mh);
         //bllHocKy.updateHocKy(hk);
         if (check)
         {
             MessageBox.Show("Cập nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         ReLoad();
     }
     ReLoad();
     dgvTrangThaiSV_SelectionChanged(sender, e);
 }