public BindingList<PhanQuyenDTO> LayDanhSach() { BindingList<PhanQuyenDTO> danhSach = new BindingList<PhanQuyenDTO>(); OleDbConnection cn; cn = DataProvider.KetNoi(); string strSQL; strSQL = "Select * From SysDanhMucPhanQuyen"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); OleDbDataReader dr; dr = cmd.ExecuteReader(); while (dr.Read()) { PhanQuyenDTO itemDTO = new PhanQuyenDTO(); itemDTO.Id = (int)dr["Id"]; itemDTO.IdNguoiDung = (int)dr["IdNguoiDung"]; itemDTO.IdChucNang = (int)dr["IdChucNang"]; itemDTO.IdPhanHe = (int)dr["IdPhanHe"]; itemDTO.Doc = (bool)dr["Doc"]; itemDTO.Them = (bool)dr["Them"]; itemDTO.Sua = (bool)dr["Sua"]; itemDTO.Xoa = (bool)dr["Xoa"]; danhSach.Add(itemDTO); } return danhSach; }
public void Sua(PhanQuyenDTO itemDTO) { OleDbConnection cn; cn = DataProvider.KetNoi(); string strSQL; strSQL = "Update SysDanhMucPhanQuyen Set Doc = ?, Them = ?, Sua = ?, Xoa = ? Where Id = ?"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); cmd.Parameters.Add("@Doc", OleDbType.Boolean).Value = itemDTO.Doc; cmd.Parameters.Add("@Them", OleDbType.Boolean).Value = itemDTO.Them; cmd.Parameters.Add("@Sua", OleDbType.Boolean).Value = itemDTO.Sua; cmd.Parameters.Add("@Xoa", OleDbType.Boolean).Value = itemDTO.Xoa; cmd.Parameters.Add("@Id", OleDbType.Numeric).Value = itemDTO.Id; cmd.ExecuteNonQuery(); cn.Close(); }
private void gvDanhSachPhanQuyen_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e) { if (gvDanhSachPhanQuyen.FocusedRowHandle > -1) { try { PhanQuyenDTO itemDTO = new PhanQuyenDTO(); PhanQuyenBUS itemBUS = new PhanQuyenBUS(); itemDTO.Doc = bool.Parse(gvDanhSachPhanQuyen.GetFocusedRowCellValue("Doc").ToString()); itemDTO.Them = bool.Parse(gvDanhSachPhanQuyen.GetFocusedRowCellValue("Them").ToString()); itemDTO.Sua = bool.Parse(gvDanhSachPhanQuyen.GetFocusedRowCellValue("Sua").ToString()); itemDTO.Xoa = bool.Parse(gvDanhSachPhanQuyen.GetFocusedRowCellValue("Xoa").ToString()); itemDTO.Id = int.Parse(gvDanhSachPhanQuyen.GetFocusedRowCellValue("Id").ToString()); itemBUS.Sua(itemDTO); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void Them(PhanQuyenDTO itemDTO) { OleDbConnection cn; cn = DataProvider.KetNoi(); string strSQL; strSQL = "Insert into SysDanhMucPhanQuyen (IdNguoiDung, IdChucNang, IdPhanHe, Doc, Them, Sua, Xoa) values (?, ?, ?, ?, ?, ?, ?)"; OleDbCommand cmd = new OleDbCommand(strSQL, cn); cmd.Parameters.Add("@IdNguoiDung", OleDbType.Numeric).Value = itemDTO.IdNguoiDung; cmd.Parameters.Add("@IdChucNang", OleDbType.Numeric).Value = itemDTO.IdChucNang; cmd.Parameters.Add("@IdPhanHe", OleDbType.Numeric).Value = itemDTO.IdPhanHe; cmd.Parameters.Add("@Doc", OleDbType.Boolean).Value = itemDTO.Doc; cmd.Parameters.Add("@Them", OleDbType.Boolean).Value = itemDTO.Them; cmd.Parameters.Add("@Sua", OleDbType.Boolean).Value = itemDTO.Sua; cmd.Parameters.Add("@Xoa", OleDbType.Boolean).Value = itemDTO.Xoa; cmd.ExecuteNonQuery(); cn.Close(); }
public void Them(PhanQuyenDTO itemDTO) { PhanQuyenDAO itemDAO = new PhanQuyenDAO(); itemDAO.Them(itemDTO); }
public void Sua(PhanQuyenDTO itemDTO) { PhanQuyenDAO itemDAO = new PhanQuyenDAO(); itemDAO.Sua(itemDTO); }