예제 #1
0
        // GET: Admin/User
        public ActionResult Index()
        {
            var usersAccess = new UsersAccess();
            var users       = usersAccess.ReadUsers();

            return(View(users));
        }
예제 #2
0
        public ActionResult Trash()
        {
            var usersAccess = new UsersAccess();
            var users       = usersAccess.GetUsersInTrash();

            return(View(users));
        }
예제 #3
0
 public ActionResult Create(Users users)
 {
     if (ModelState.IsValid)
     {
         var user = new UsersAccess();
         users.Password = Encryptor.MD5Hash(users.Password);
         var sess = (UserLogin)Session[CommonConstant.USER_SESSION];
         users.CreatedBy    = sess.Username;
         users.CreatedDate  = DateTime.Now;
         users.ModifiedBy   = sess.Username;
         users.ModifiedDate = DateTime.Now;
         long id = user.CreateUser(users);
         if (id > 0)
         {
             return(RedirectToAction("Index", "User"));
         }
         else if (id == 0)
         {
             ModelState.AddModelError("", "Tên tài khoản đã tồn tại");
         }
         else
         {
             ModelState.AddModelError("", "Thêm người dùng thất bại");
         }
     }
     return(View("Create"));
 }
예제 #4
0
        public ActionResult Update(int id)
        {
            var usersAccess = new UsersAccess();
            var user        = usersAccess.GetUserById(id);

            return(View(user));
        }
예제 #5
0
        public ActionResult Status(int id)
        {
            var usersAccess = new UsersAccess();
            var sess        = (UserLogin)Session[CommonConstant.USER_SESSION];

            usersAccess.Status(id, sess.Username);
            return(RedirectToAction("Index"));
        }
예제 #6
0
 public AddMembersWindow(int chatroomId)
 {
     InitializeComponent();
     this.users      = new UsersAccess();
     this.messenger  = new MessengerAccess();
     this.chatroomId = chatroomId;
     GetAllUsers();
 }
예제 #7
0
        public static void Initialize(TestContext context)
        {
            testHelpers = new TestHelpers();
            usersAccess = new UsersAccess();
            db          = ContextProvider.Instance.DB;

            testHelpers.ClearData();
            testHelpers.InsertTestData();
        }
예제 #8
0
        public ActionResult ReTrash(int id)
        {
            var usersAccess = new UsersAccess();
            var user        = usersAccess.GetUserById(id);
            var sess        = (UserLogin)Session[CommonConstant.USER_SESSION];

            user.ModifiedBy = sess.Username;
            usersAccess.ReTrash(id);
            return(RedirectToAction("Trash"));
        }
예제 #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int EmployeeID = Convert.ToInt32(cmbEmployees.EditValue);
            var x          = db.Users.Find(EmployeeID);

            if (x != null)
            {
                XtraMessageBox.Show("هذا الموظف مسجل كمستخدم بالفعل", "تنبيه", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (!valPassword.Validate())
            {
                return;
            }

            var  emp = db.Employees.Find(EmployeeID);
            User u   = new User()
            {
                EmployeeID = Convert.ToInt32(cmbEmployees.EditValue),
                UserName   = cmbEmployees.Text,
                Password   = txtPassword.Text,
                CardNumber = emp.CardNumber,
            };

            db.Users.Add(u);
            db.SaveChanges();

            UsersAccess ua = new UsersAccess()
            {
                UserID               = u.EmployeeID,
                AddNewTrainee        = Convert.ToBoolean(AddNewTraineeCheckEdit.EditValue),
                SearchMen            = Convert.ToBoolean(SearchMenCheckEdit.EditValue),
                SearchWomen          = Convert.ToBoolean(SearchWomenCheckEdit.EditValue),
                AddOffer             = Convert.ToBoolean(AddOfferCheckEdit.EditValue),
                EditOffer            = Convert.ToBoolean(EditOfferCheckEdit.EditValue),
                ShowTrainees         = Convert.ToBoolean(ShowTraineesCheckEdit.EditValue),
                CancelTraineeProfile = Convert.ToBoolean(CancelTraineeProfileCheckEdit.EditValue),
                AddIncomeOutCome     = Convert.ToBoolean(AddIncomeOutComeCheckEdit.EditValue),
                Settings             = Convert.ToBoolean(SettingsCheckEdit.EditValue),
                EditTraineeProfile   = Convert.ToBoolean(EditTraineeProfileCheckEdit.EditValue),
                Reports              = Convert.ToBoolean(ReportsCheckEdit.EditValue),
                NewIncomeOutCome     = Convert.ToBoolean(NewIncomeOutComeCheckEdit.EditValue),
                AddNewUser           = Convert.ToBoolean(AddNewUserCheckEdit.EditValue),
                EditUsers            = Convert.ToBoolean(EditUsersCheckEdit.EditValue),
                DeleteTrainee        = Convert.ToBoolean(DeleteTraineeCheckEdit.EditValue),
                FreezeTrainee        = Convert.ToBoolean(FreezeTraineeCheckEdit.EditValue)
            };

            db.UsersAccesses.Add(ua);
            db.SaveChanges();
            XtraMessageBox.Show("تم إضافة المستخدم", "إضافة", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
예제 #10
0
 public static int SqlBulkCopyBatchInsert(List <Users> list, int count)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.SqlBulkCopyBatchInsert(list, count));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="order">列名,分页排序字段,可支持多字段,多顺序</param>
 /// <param name="whereStr">以 where 开头</param>
 /// <returns></returns>
 public static IList <Users> SelectPage(string cloumns, string order, string whereStr, int pageIndex, int pageSize, out int rowCount)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.SelectPage(cloumns, order, whereStr, pageIndex, pageSize, out rowCount));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="whereStr">以where 开始</param>
 /// <returns></returns>
 public static IList <Users> Select(string whereStr)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.Select(whereStr));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #13
0
 public static Users SelectObject(int id)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.SelectObject(id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #14
0
 public static int Update(Users obj)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.Update(obj));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #15
0
 public static int Delete(int id)
 {
     try
     {
         using (var access = new UsersAccess())
         {
             return(access.Delete(id));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #16
0
        public ActionResult Delete(int id)
        {
            var usersAccess = new UsersAccess();
            var user        = usersAccess.GetUserById(id);
            var sess        = (UserLogin)Session[CommonConstant.USER_SESSION];

            user.ModifiedBy = sess.Username;
            var result = usersAccess.DeleteUser(id);

            if (result)
            {
                ViewBag.Message = "Xóa " + user.Username + " thành công";
            }
            return(RedirectToAction("Index"));
        }
예제 #17
0
        public MainWindow()
        {
            InitializeComponent();
            AuthenticationDialogWindow authenticationDialog = new AuthenticationDialogWindow();

            authenticationDialog.ShowDialog();
            this.user = authenticationDialog.User;

            if (this.user == null)
            {
                Environment.Exit(0);
            }

            this.messenger = new MessengerAccess();
            this.users     = new UsersAccess();
            GenerateAllChatrooms();
            this.chatHub = new ChatHub();
        }
예제 #18
0
        public ActionResult News()
        {
            var             manager = UsersAccess.getUserManager();
            ApplicationUser user    = manager.FindById(User.Identity.GetUserId());

            if (user != null)
            {
                if (user.UnreadNewsCount > 0)
                {
                    user.UnreadNewsCount = 0;
                    manager.UpdateAsync(user);
                    db.SaveChanges();
                }
            }

            var newsList = db.News.ToList();

            return(View(newsList));
        }
 public ActionResult SignIn(SignInModel signInModel)
 {
     if (ModelState.IsValid)
     {
         var user = new UsersAccess();
         // kiểm tra người dùng là admin hay customer
         var check = user.GetUserByUsername(signInModel.Username);
         if (check.Authorization == 1)
         {
             var result = user.SignIn(signInModel.Username, Encryptor.MD5Hash(signInModel.Password));
             if (result == 1)
             {
                 var u           = user.GetUserByUsername(signInModel.Username);
                 var userSession = new UserLogin();
                 userSession.Username = u.Username;
                 userSession.UserId   = u.Id;
                 Session.Add(CommonConstant.USER_SESSION, userSession);
                 return(RedirectToAction("Index", "Home"));
             }
             else if (result == 0)
             {
                 ModelState.AddModelError("", "Tài khoản không tồn tại");
             }
             else if (result == 2)
             {
                 ModelState.AddModelError("", "Tài khoản đã bị khóa");
             }
             else if (result == -1)
             {
                 ModelState.AddModelError("", "Tài khoản hoặc mật khẩu không đúng");
             }
             else
             {
                 ModelState.AddModelError("", "Đăng nhập không thành công");
             }
         }
         else
         {
             ModelState.AddModelError("", "Bạn không có quyền đăng nhập");
         }
     }
     return(View("Index"));
 }
예제 #20
0
        public ActionResult Update(Users users)
        {
            if (ModelState.IsValid)
            {
                var user = new UsersAccess();
                if (!string.IsNullOrEmpty(users.Password))
                {
                    users.Password = Encryptor.MD5Hash(users.Password);
                }

                var sess = (UserLogin)Session[CommonConstant.USER_SESSION];
                users.ModifiedBy = sess.Username;
                bool result = user.UpdateUser(users);
                if (result)
                {
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "Cập nhật người dùng thất bại");
                }
            }
            return(View("Update"));
        }
예제 #21
0
        public void BaseUsuariosContenidoTest()
        {
            UsersAccess usersAccess = new UsersAccess();

            Assert.IsTrue(!string.IsNullOrEmpty(usersAccess.ListarUnUsuario().Nombre));
        }
예제 #22
0
 protected ApplicationUser getUser()
 {
     return(UsersAccess.getUserManager().FindById(User.Identity.GetUserId()));
 }
예제 #23
0
 public UserController()
 {
     usersAccess           = new UsersAccess();
     skillController       = new SkillController();
     applicationController = new ApplicationController();
 }
예제 #24
0
        public void BaseUsuariosConexionTest()
        {
            UsersAccess usersAccess = new UsersAccess();

            Assert.IsTrue(usersAccess.TestConnection());
        }
예제 #25
0
        public List <Users> ListarUsuarios()
        {
            UsersAccess usersAccess = new UsersAccess();

            return(usersAccess.ListarUsuarios());
        }
예제 #26
0
 public AuthenticationDialogWindow()
 {
     InitializeComponent();
     this.users = new UsersAccess();
 }
예제 #27
0
 public CivMoneyUsers()
 {
     _usersDataBaseAccess = new UsersAccess(new CivMoneyContextFactory());
 }