private void LoadForm() { string querry = "Select * from LoaiThanhVien "; DataTable tb = DataProvider.instanse.Executequerry(querry); dtgv_LoaiThanhVien.DataSource = tb; lb_ThongBao.Hide(); txb_Name.Text = ""; txb_Name.Enabled = false; btn_Add.Enabled = true; btn_Edit.Enabled = false; btn_Delete.Enabled = false; btn_Save.Enabled = false; btn_Huy.Enabled = false; listQuyen = QuyenSDDAO.GetListQuyenSD(); if (stt == 0) { GetListQuyen(); } else { GetListQuyen1(); } panle_Quyen.Hide(); panle_Quyen.Enabled = false; ResetListCb();// reset check box stt++; }
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(); } } }
private void GetQuyenSH(int id) // những quyền nào tương ứng với loại tv nào thì hiển thị dấu tích { listQuyen_LoaiTV = QuyenSDDAO.GetListQuyen_LoaiTV(id); foreach (QuyenSD item in listQuyen_LoaiTV) { foreach (CheckBox item1 in listCB) { if (item1.Text == item.TenQuyen) { item1.Checked = true; } } } }