private void btn_Save_Click(object sender, EventArgs e) { if (TrangThai == 0)// Trạng thái thêm mới { if (txb_Name.Text != "") { string querry = " Insert into LoaiThanhVien values(N'" + txb_Name.Text + "',N'" + txb_GhiChu.Text + "')"; DataProvider.instanse.ExecuteNonquerry(querry); foreach (CheckBox item in listCB) { int id_LTV = LoaiThanhVienDAO.GetIdCuoi(); if (item.Checked == true) { QuyenSDDAO.AddQuyen_LoaiTV(id_LTV, int.Parse(item.Name.ToString())); } } MessageBox.Show("Thêm dữ liệu thành công"); TrangThai1 = 0; LoadForm(); } else { lb_ThongBao.Text = "Bạn chưa nhập thông tin "; lb_ThongBao.Show(); } } else if (TrangThai == 1)//Trạng thái sửa { if (txb_Name.Text != "") { string querry = "update LoaiThanhVien set Name = N'" + txb_Name.Text + "',GhiChu=N'" + txb_GhiChu.Text + "' where ID_LoaiTV =" + dtgv_LoaiThanhVien.CurrentRow.Cells["ID_LoaiTV"].Value.ToString(); DataProvider.instanse.ExecuteNonquerry(querry); for (int i = 0; i < listCB.Count; i++) { if (listCB[i].Checked == list[i]) { } else if (listCB[i].Checked == true & list[i] == false) { QuyenSDDAO.AddQuyen_LoaiTV(int.Parse(dtgv_LoaiThanhVien.CurrentRow.Cells["Id_LoaiTV"].Value.ToString()), int.Parse(listCB[i].Name.ToString())); } else if (listCB[i].Checked == false & list[i] == true) { QuyenSDDAO.DeleteQuyen_LoaiTV(int.Parse(dtgv_LoaiThanhVien.CurrentRow.Cells["Id_LoaiTV"].Value.ToString()), int.Parse(listCB[i].Name.ToString())); } } MessageBox.Show("Sửa dữ liệu thành công"); TrangThai1 = 0; LoadForm(); } else { lb_ThongBao.Text = "Bạn chưa nhập thông tin "; lb_ThongBao.Show(); } } }
public List <LoaiThanhVienDTO> LoadLoaiOfTV() { LoaiThanhVienDAO tvDAO = new LoaiThanhVienDAO(); return(tvDAO.LoadLoaiOfTvien()); }