private void Del() { if (txtTenNhom.Text.Trim().Equals("Admin") == false) { nhomBL ctr = new nhomBL(); string stennhom = ""; stennhom = txtTenNhom.Text.Trim(); string iid = ""; try { iid = txtID.Text.Trim(); } catch { } if (iid.Equals("") == false && iid.Equals("-1") == false) { if (MessageBox.Show("Xác nhận xóa nhóm người dùng?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (ctr.Delete(iid).Trim().Equals("") == true) { TreeNode node = treeNhom.Nodes.Find(txtID.Text, true)[0]; treeNhom.Nodes.Remove(node); _ctrlog.Append(Data.use, "Xóa nhóm người dùng: " + stennhom); MessageBox.Show("Xóa nhóm người dùng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { MessageBox.Show("Bạn không thể xóa nhóm người dùng này.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void HienThiTT(string sid) { nhom obj = new nhom(); nhomBL ctr = new nhomBL(); obj = ctr.GetByID(sid); try { treeQuyen.Enabled = false; txtGhiChu.Enabled = true; txtGhiChu.Text = obj.mota.Trim(); txtID.Text = sid.ToString().Trim(); txtTenNhom.Text = obj.tennhom; if (txtTenNhom.Text.Trim().Equals("Admin") == false) { txtTenNhom.Enabled = true; } else { txtTenNhom.Enabled = false; txtGhiChu.Enabled = false; treeQuyen.Enabled = false; } HienThiDSQuyen(sid); treeQuyen.Enabled = true; } catch { } }
private void Save() { //TreeNode nodequyencha = treeQuyen.Nodes.Find("0", true)[0]; quyen_nhomBL ctrquyennhom = new quyen_nhomBL(); lst = new List <quyen_nhom>(); lst = GetListQuyenOfNhom(treeQuyen.Nodes); nhomBL ctr = new nhomBL(); nhom obj = new nhom(); obj = GetData(); string kq = ""; if (obj != null) { if (txtID.Text.Trim().Equals("-1") == true) //Thêm mới { kq = ctr.Insert(obj); if (kq.Trim().Equals("") == true) { ctrquyennhom.DeletebyIDNhom(obj.idnhom); for (int i = 0; i < lst.Count; i++) { lst[i].idnhom = obj.idnhom; ctrquyennhom.Insert(lst[i]); } TreeNode nodecha = treeNhom.Nodes.Find("-1", true)[0]; nodecha.Nodes.Add(obj.idnhom, obj.tennhom); _ctrlog.Append(Data.use, "Thêm mới nhóm người dùng: " + obj.tennhom); MessageBox.Show("Thêm mới nhóm người dùng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); HienThiTT(treeNhom.SelectedNode.Name.Trim()); } } else //Sửa { kq = ctr.Update(obj); if (kq.Trim().Equals("") == true) { ctrquyennhom.DeletebyIDNhom(obj.idnhom); for (int i = 0; i < lst.Count; i++) { lst[i].idnhom = obj.idnhom; ctrquyennhom.Insert(lst[i]); } TreeNode node = new TreeNode(); node = treeNhom.Nodes.Find(obj.idnhom.Trim(), true)[0]; node.Text = obj.tennhom.Trim(); treeNhom.SelectedNode = node; _ctrlog.Append(Data.use, "Cập nhật nhóm người dùng: " + obj.tennhom); MessageBox.Show("Cập nhật nhóm người dùng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); HienThiTT(treeNhom.SelectedNode.Name.Trim()); } } } }
private void HienThiDSNhom() { DataTable dt = new DataTable(); try { nhomBL ctr = new nhomBL(); dt = ctr.GetAll(); //TreeNode nodecha = treeNhom.Nodes.Add("-1", "DANH MỤC NHÓM NGƯỜI DÙNG"); for (int i = 0; i < dt.Rows.Count; i++) { TreeNode node = treeNhom.Nodes.Add(dt.Rows[i]["idnhom"].ToString().Trim(), dt.Rows[i]["tennhom"].ToString().Trim()); } } catch { } treeNhom.ExpandAll(); }
private void Save() { string kq = ""; nhomBL ctrnhom = new nhomBL(); quyennguoidungBL ctrquyennd = new quyennguoidungBL(); nhom_nhanvienBL ctrNhom_NhanVien = new nhom_nhanvienBL(); List <nhom_nhanvien> lstNhom_NhanVien = new List <nhom_nhanvien>(); lstNhom_NhanVien = GetListNhom_NhanVien(); string sidnhanvien = ""; try { sidnhanvien = c1FlexGrid1[c1FlexGrid1.RowSel, "idnhanvien"].ToString().Trim(); } catch { } string staikhoan = ""; try { staikhoan = c1FlexGrid1[c1FlexGrid1.RowSel, "taikhoan"].ToString().Trim(); } catch { } string stennhanvien = ""; try { stennhanvien = c1FlexGrid1[c1FlexGrid1.RowSel, "hoten"].ToString().Trim(); } catch { } //Xóa quyền người dùng thuộc nhóm cũ DataTable dt = new DataTable(); dt = ctrNhom_NhanVien.GetByIDNhanVien(sidnhanvien); for (int k = 0; k < dt.Rows.Count; k++) { ctrquyennd.DeleteByIDNhomUse(sidnhanvien, dt.Rows[k]["idnhom"].ToString().Trim()); } ctrNhom_NhanVien.DeleteByIDNhanVien(sidnhanvien); if (lstNhom_NhanVien != null) { for (int i = 0; i < lstNhom_NhanVien.Count; i++) { kq = ctrNhom_NhanVien.Insert(lstNhom_NhanVien[i]); if (kq.Trim().Equals("") == true) { List <quyennguoidung> lstquyennd = new List <quyennguoidung>(); lstquyennd = GetListQuyen(lstNhom_NhanVien[i].idnhom); if (lstquyennd != null) { for (int j = 0; j < lstquyennd.Count; j++) { //Xóa tất cả các quyền thuộc nhóm mới (nếu trùng quyền đã có với quyền thuộc nhóm) ctrquyennd.DeleteByIDMenuvsUse(sidnhanvien, lstquyennd[j].idmenu); kq = ctrquyennd.Insert(lstquyennd[j]); } } nhom objnhom = new nhom(); objnhom = ctrnhom.GetByID(lstNhom_NhanVien[i].idnhom); string stennhom = ""; try { stennhom = objnhom.tennhom.Trim(); } catch { stennhom = "-/-"; } _ctrlog.Append(Data.use, "Phân quyền người dùng: " + stennhanvien + "(" + staikhoan + ") thuộc nhóm: " + stennhom); } } } if (kq.Trim().Equals("") == true && sidnhanvien.Trim().Equals("") == false) { MessageBox.Show("Cập nhật thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }