private Chuong_DTO GetInfoChapter() { Chuong_DTO chuong = new Chuong_DTO(); chuong.MaMH_Chuong = cbxSubject.EditValue.ToString(); return(chuong); }
private void btnReport_Click(object sender, EventArgs e) { Chuong_DTO chuong = GetInfoChapter(); dgvChapter.DataSource = chuongBUS.GetListChapterRP(chuong); tbxSumChapter.Text = Convert.ToString(gvChapter.DataRowCount); }
//Kiểm tra trước khi lưu public bool CheckBeforeSave(Chuong_DTO chuong_DTO) { if (chuong_DTO.TenChuong.Equals("")) { MessageBox.Show("Tên Chương không hợp lệ!"); return(false); } return(true); }
private void btnDelete_Click(object sender, System.EventArgs e) { Chuong_DTO c = GetInfoChapter(); if (MessageBox.Show("Bạn có muốn xoá Chương : " + tbxChapter.Text + " không?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cBUS.DelChapter(c); InfoSubject_Load(sender, e); } }
//Lấy Thông tin Chuong private Chuong_DTO GetInfoChapter() { Chuong_DTO c = new Chuong_DTO(); c.MaChuong = tbxIdChapter.Text; c.TenChuong = tbxChapter.Text; c.MaMH_Chuong = cbxSubject.EditValue.ToString(); c.QuanTrong = (cbxImportant.Text == "Đúng") ? 1 : 0; return(c); }
//Xoá chương trong CSDL public bool DelChapter(Chuong_DTO chuong_DTO) { string sql = string.Format("delete from Chuong where MaChuong = '{0}'", chuong_DTO.MaChuong); if (connData.RunSQL(sql)) { MessageBox.Show("Xoá thông tin Chương thành công!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } return(false); }
//Sửa chương trong CSDL public bool EditChapter(Chuong_DTO chuong_DTO) { if (CheckBeforeSave(chuong_DTO)) { string sql = string.Format("update Chuong set TenChuong = N'{1}',QuanTrong={2} where MaChuong = '{0}'", chuong_DTO.MaChuong, chuong_DTO.TenChuong, chuong_DTO.QuanTrong); if (connData.RunSQL(sql)) { MessageBox.Show("Sửa thông tin Chương thành công! ", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } } return(false); }
//Thêm chương trong CSDL public bool AddChapter(Chuong_DTO chuong_DTO) { if (CheckBeforeSave(chuong_DTO)) { string sql = string.Format("insert into Chuong (MaChuong, TenChuong, MaMH_Chuong, QuanTrong)" + "values ('{0}',N'{1}','{2}',{3})", chuong_DTO.MaChuong, chuong_DTO.TenChuong, chuong_DTO.MaMH_Chuong, chuong_DTO.QuanTrong); if (connData.RunSQL(sql)) { MessageBox.Show("Thêm thành công", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } } return(false); }
private void btnSave_Click(object sender, System.EventArgs e) { Chuong_DTO c = GetInfoChapter(); if (add) { cBUS.AddChapter(c); InfoSubject_Load(sender, e); } if (update) { cBUS.EditChapter(c); InfoSubject_Load(sender, e); } }
public DataTable GetListChapterRP(Chuong_DTO chuong) { string sql = "select MaChuong, TenChuong, (case QuanTrong when 'true' then N'Đúng' else 'Sai' end) as QuanTrong from Chuong where MaMH_Chuong = '" + chuong.MaMH_Chuong + "'"; return(connData.GetData(sql)); }