Esempio n. 1
0
        public QUYEN GetDVByMa(string userName)
        {
            QUYEN result = new QUYEN();

            result = context.QUYEN.FirstOrDefault(m => m.User == userName);
            return(result);
        }
Esempio n. 2
0
        public QUYEN GetDVByMa(string userName, string pass)
        {
            QUYEN result = new QUYEN();

            result = context.QUYEN.FirstOrDefault(m => m.User == userName && m.PassWord == pass);
            return(result);
        }
Esempio n. 3
0
        public ActionResult Dangnhap(string tenDangNhap, string matKhau)
        {
            Xuly     xuly       = new Xuly();
            string   matKhauNew = xuly.chuoiMaHoa(matKhau);
            NHANVIEN Listnv     = db.NHANVIENs.SingleOrDefault(n => n.TenDangNhap == tenDangNhap);
            NHANVIEN nv         = Listnv != null ? Listnv : null;

            if (nv != null)
            {
                if (nv.MatKhau == matKhauNew)
                {
                    List <PHANQUYEN>    listPQ         = db.PHANQUYENs.Where(n => n.id_quyen == nv.id_Quyen).ToList();
                    QUYEN               quyen          = db.QUYENs.Find(nv.id_Quyen);
                    ModelQuyenNguoiDung QuyenNguoiDung = new ModelQuyenNguoiDung(nv, quyen);
                    Session["QuyenNguoiDung"] = QuyenNguoiDung;

                    Session["DangNhap"]    = "OK";
                    Session["thongbaoDN"]  = null;
                    Session["NguoiDung"]   = nv.TenDangNhap;
                    Session["NguoiDungHT"] = nv;
                    listTb();
                    return(RedirectToAction("Index", "Home"));
                }
                Session["DangNhap"]   = "NO";
                Session["thongbaoDN"] = "Đăng nhập thất bại";
                return(View());
            }
            else
            {
                Session["DangNhap"]   = "NO";
                Session["thongbaoDN"] = "Đăng nhập thất bại";
                return(View());
            }
        }
Esempio n. 4
0
        public QUYEN GetQuyenByMaNV(int pMa)
        {
            QUYEN result = new QUYEN();

            result = context.QUYEN.FirstOrDefault(m => m.MaNV == pMa);
            return(result);
        }
Esempio n. 5
0
 private void BTN_TONG_Click(object sender, EventArgs e)
 {
     QUYEN.BringToFront();
     chuyen_dong.Height = BTN_TONG.Height;
     chuyen_dong.Top    = BTN_TONG.Top;
     TXT1.Text          = ((Button)sender).Text;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            QUYEN qUYEN = db.QUYENs.Find(id);

            db.QUYENs.Remove(qUYEN);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 7
0
        public int Add(QUYEN p)
        {
            int result = 0;

            context.QUYEN.Add(p);
            result = context.SaveChanges();
            return(result);
        }
 public BOChiTietQuyen()
 {
     ChiTietQuyen  = new CHITIETQUYEN();
     Quyen         = new QUYEN();
     ChucNang      = new CHUCNANG();
     QuyenNhanVien = new QUYENNHANVIEN();
     NhomChucNang  = new NHOMCHUCNANG();
 }
Esempio n. 9
0
        public int Delete(int pMa)
        {
            int   result = 0;
            QUYEN k      = context.QUYEN.FirstOrDefault(m => m.MaNV == pMa);

            context.QUYEN.Remove(k);
            result = context.SaveChanges();
            return(result);
        }
 public ActionResult Edit([Bind(Include = "ID_QUYEN,TENQUYEN")] QUYEN qUYEN)
 {
     if (ModelState.IsValid)
     {
         db.Entry(qUYEN).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TENQUYEN = new SelectList(db.PHANQUYENs, "TENQUYEN", "TENQUYEN", qUYEN.TENQUYEN);
     return(View(qUYEN));
 }
Esempio n. 11
0
 public JsonResult XoaQuyen(string id)
 {
     if (ModelState.IsValid)
     {
         QUYEN quyen = db.QUYENs.Find(Convert.ToInt32(id));
         db.QUYENs.Remove(quyen);
         db.SaveChanges();
         return(Json("Yes", JsonRequestBehavior.AllowGet));
     }
     return(Json("No", JsonRequestBehavior.AllowGet));
 }
Esempio n. 12
0
        public int Update(QUYEN pma, int ma)
        {
            int   result = 0;
            QUYEN k      = context.QUYEN.FirstOrDefault(m => m.MaNV == ma);

            if (k != null)
            {
                k.Quyen1 = pma.Quyen1;
            }
            result = context.SaveChanges();
            return(result);
        }
        public ActionResult Create([Bind(Include = "ID_QUYEN,TENQUYEN")] QUYEN qUYEN)
        {
            if (ModelState.IsValid)
            {
                db.QUYENs.Add(qUYEN);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TENQUYEN = new SelectList(db.PHANQUYENs, "TENQUYEN", "TENQUYEN", qUYEN.TENQUYEN);
            return(View(qUYEN));
        }
Esempio n. 14
0
        public int UpdateHoanChinh(QUYEN pma, int ma)
        {
            int   result = 0;
            QUYEN k      = context.QUYEN.FirstOrDefault(m => m.MaNV == ma);

            if (k != null)
            {
                k.User     = pma.User;
                k.PassWord = pma.PassWord;
            }
            result = context.SaveChanges();
            return(result);
        }
        // GET: Admin/QUYEN/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QUYEN qUYEN = db.QUYENs.Find(id);

            if (qUYEN == null)
            {
                return(HttpNotFound());
            }
            return(View(qUYEN));
        }
        private void btn_Search_Click(object sender, EventArgs e)
        {
            int   ma = Convert.ToInt32(dataGV_DSTaiKhoan.CurrentRow.Cells[1].Value);
            QUYEN q  = new QUYEN
            {
                Quyen1 = combo_Quyen.Text
            };
            int kq = _quyenDao.Update(q, ma);

            if (kq == 1)
            {
                MessageBox.Show("Tạo Quyền Cho  Thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                UC_Quyen_Load(sender, e);
            }
        }
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            int   ma = Convert.ToInt32(dataGV_DSTheoNhom.CurrentRow.Cells[1].Value);
            QUYEN q  = new QUYEN
            {
                Quyen1 = ""
            };
            int kq = _quyenDao.Update(q, ma);

            if (kq == 1)
            {
                MessageBox.Show("Xóa Quyền Của Tài Khoản Thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                UC_Quyen_Load(sender, e);
            }
        }
        // GET: Admin/QUYEN/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            QUYEN qUYEN = db.QUYENs.Find(id);

            if (qUYEN == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TENQUYEN = new SelectList(db.PHANQUYENs, "TENQUYEN", "TENQUYEN", qUYEN.TENQUYEN);
            return(View(qUYEN));
        }
Esempio n. 19
0
        public ActionResult Themmoi(QUYEN quyen)
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && quyenNguoiDung.Quyen.Ten == "Admin")
            {
                if (ModelState.IsValid)
                {
                    db.QUYENs.Add(quyen);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View());
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 20
0
        public ActionResult SuaQuyen(QUYEN quyen)
        {
            ModelQuyenNguoiDung quyenNguoiDung = Session["QuyenNguoiDung"] as ModelQuyenNguoiDung;

            if (quyenNguoiDung != null && quyenNguoiDung.Quyen.Ten == "Admin")
            {
                if (ModelState.IsValid)
                {
                    QUYEN quyenUpdate = db.QUYENs.Find(quyen.Id);
                    quyenUpdate.Ten             = quyen.Ten;
                    quyenUpdate.MoTa            = quyen.MoTa;
                    db.Entry(quyenUpdate).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View());
            }
            return(RedirectToAction("Index", "Home"));
        }
 private void btn_Add_Click(object sender, EventArgs e)
 {
     try
     {
         bool kt          = KiemTra_Control();
         int  kt_UserName = kt_User(txt_userName.Text, combo_TenNV.Text);
         if (kt)
         {
             if (kt_UserName == 0)
             {
                 QUYEN q = new QUYEN
                 {
                     MaNV     = _nhanVienDao.GetDVByMa(combo_TenNV.Text).MaNV,
                     User     = txt_userName.Text,
                     PassWord = txt_Pass.Text,
                     Quyen1   = ""
                 };
                 int kq = _quyenDao.Add(q);
                 if (kq == 1)
                 {
                     MessageBox.Show("Thêm Tài Thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     UC_Quyen_Load(sender, e);
                 }
             }
             else
             {
                 if (kt_UserName == 2)
                 {
                     MessageBox.Show("Tài Khoản Này Đã Tồn Tại. Vui Lòng Nhập UserName Khác", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
             }
         }
         else
         {
             MessageBox.Show("Bạn Chưa Điền Đủ Các Trường", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         MessageBox.Show("Đường Dẫn Bị Lỗi Rồi Đại Vương Ơi (^_^)", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 private void btn_Edit_Click(object sender, EventArgs e)
 {
     try
     {
         int   ma = Convert.ToInt32(dataGV_DSTaiKhoan.CurrentRow.Cells[0].Value);
         QUYEN q  = new QUYEN
         {
             User     = txt_userName.Text,
             PassWord = txt_Pass.Text
         };
         int kq = _quyenDao.UpdateHoanChinh(q, Convert.ToInt32(label_MaNV.Text));
         if (kq == 1)
         {
             MessageBox.Show("Cập Nhật Thông Tin Tài Khoản Thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             UC_Quyen_Load(sender, e);
         }
     }
     catch
     {
         MessageBox.Show("Đường Truyền Bị Lỗi Rồi Đại Vương Ơi(^_^)", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 public ModelQuyenNguoiDung(NHANVIEN nhanvien, QUYEN quyen)
 {
     this.nhanvien = nhanvien;
     this.quyen    = quyen;
 }
Esempio n. 24
0
 public BOQuyenNhanVien()
 {
     Quyen         = new QUYEN();
     QuyenNhanVien = new QUYENNHANVIEN();
     NhanVien      = new NHANVIEN();
 }