public void ThemVaiTro(CQuyen q, List <CQuyenHan> qh) { Provider dao = new Provider(); try { dao.Connect(); string sql = string.Format("INSERT dbo.K_PERMISION( ID, Name, Description, ACTIVE )VALUES ( '{0}',N'{1}',N'{2}',{3})" , q.ID, q.Name, q.Description, q.ACTIVE == true ? 1 : 0); CommandType type = CommandType.Text; dao.ExeCuteNonQuery(type, sql); foreach (var item in qh) { sql = string.Format("INSERT dbo.K_Permision_Detail( PER_ID ,Object_ID ,AllowAdd ,AllowDelete ,AllowEdit ,Active ,AllowView)" + "VALUES('{0}', '{1}', {2}, {3}, {4}, {5}, {6})" , item.PER_ID, item.Object_ID, item.AllowAdd == true ? 1 : 0, item.AllowDelete == true ? 1 : 0, item.AllowEdit == true ? 1 : 0, item.Active == true ? 1 : 0, item.AllowView == true ? 1 : 0); type = CommandType.Text; dao.ExeCuteNonQuery(type, sql); } } catch (SqlException ex) { throw ex; } finally { dao.DisConnect(); } }
public void SuaVaiTro(CQuyen q, List <CQuyenHan> qh) { Provider dao = new Provider(); try { dao.Connect(); string sql = string.Format("UPDATE dbo.K_PERMISION SET Name ='{0}', Description=N'{1}',ACTIVE='{2}'WHERE ID='{3}'" , q.Name, q.Description, q.ACTIVE, q.ID); CommandType type = CommandType.Text; dao.ExeCuteNonQuery(type, sql); foreach (var item in qh) { sql = string.Format("UPDATE dbo.K_Permision_Detail SET AllowAdd='{0}',AllowDelete='{1}',AllowEdit='{2}',AllowView='{3}',Active='{4}'WHERE PER_ID='{5}'AND Object_ID='{6}'" , item.AllowAdd, item.AllowDelete, item.AllowEdit, item.AllowView, item.Active, item.PER_ID, item.Object_ID); type = CommandType.Text; dao.ExeCuteNonQuery(type, sql); } } catch (SqlException ex) { throw ex; } finally { dao.DisConnect(); } }
public static void ThemVaiTro(CQuyen q, List <CQuyenHan> qh) { try { PhanQuyen dao = new PhanQuyen(); dao.ThemVaiTro(q, qh); } catch (SqlException ex) { throw ex; } }
private void BtnSua_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { lc = new fLuaChon(2); DialogResult rs = lc.ShowDialog(); if (rs == DialogResult.OK)//Vai trò { string _ID = gvPermision.GetFocusedRowCellValue("ID").ToString(); string _Name = gvPermision.GetFocusedRowCellValue("Name").ToString(); string _Description = gvPermision.GetFocusedRowCellValue("Description").ToString(); bool _ACTIVE = bool.Parse(gvPermision.GetFocusedRowCellValue("ACTIVE").ToString()); CQuyen q = new CQuyen ( _ID, _Name, _Description, _ACTIVE ); fSuaVaiTro vt = new fSuaVaiTro(false, q); vt.ShowDialog(); return; } else if (rs == DialogResult.Yes)//Người dùng { string _UserID = gvUser.GetFocusedRowCellValue("UserID").ToString(); string _UserName = gvUser.GetFocusedRowCellValue("UserName").ToString(); string _Password = gvUser.GetFocusedRowCellValue("Password").ToString(); string _GroupID = gvUser.GetFocusedRowCellValue("Group_ID").ToString(); string _Description = gvUser.GetFocusedRowCellValue("Description").ToString(); string _PartID = gvUser.GetFocusedRowCellValue("PartID").ToString(); bool _Active = bool.Parse(gvUser.GetFocusedRowCellValue("Active").ToString()); CUser us = new CUser ( _UserID, _UserName, _Password, _GroupID, _Description, _PartID, _Active ); fSuaNguoiDung nd = new fSuaNguoiDung(false, us); nd.ShowDialog(); return; } }
public fSuaVaiTro(bool isAdd = true, CQuyen q = null) { InitializeComponent(); if (isAdd == false && q == null) { XtraMessageBox.Show("ERROR : Dữ liệu không được cung cấp để thực hiện hành động !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); } if (isAdd == true) { table = BUS_PhanQuyen.LoadPhanQuyen("admin"); Text = "Thêm Vai Trò"; } else { editq = q; table = BUS_PhanQuyen.LoadPhanQuyen(q.ID); Text = "Sửa thông tin vai trò"; } add = isAdd; gcRule.DataSource = table; Init(); }