コード例 #1
0
ファイル: AddUser.aspx.cs プロジェクト: prajjwal21/STP
        protected void Button1_Click(object sender, EventArgs e)
        {
            int      r        = 0;
            string   fName    = fname.Text;
            string   lName    = lname.Text;
            string   eMail    = email.Text;
            long     mobile   = Convert.ToInt64(mob.Text);
            string   add      = address.Text;
            DateTime Dob      = Convert.ToDateTime(dob.Text);
            string   uName    = uname.Text;
            string   password = pwd.Text;
            string   Role     = role.SelectedValue;
            string   Status   = status.SelectedValue;

            r = UsersBO.AddUser(fName, lName, eMail, mobile, Dob, add, Role, Status, uName, password);
            if (r != 1)
            {
                Label1.Text      = "Error In Adding User.";
                Label1.ForeColor = Color.Red;
            }
            else
            {
                r = UsersBO.SendMail(eMail, fName, uName, password);
                if (r == 1)
                {
                    Response.Redirect("~/Admin/ViewUsers");
                }
                else
                {
                    Label1.Text      = "Error In Sending Mail, but User Added Successfully.";
                    Label1.ForeColor = Color.Red;
                }
            }
        }
コード例 #2
0
        public ActionResult PersonalProfile(UsersViewModel user)
        {
            UsersBO newUser = AutoMapper <UsersViewModel, UsersBO> .Map(user);

            userServ.Update(newUser);
            return(RedirectToActionPermanent("PersonalProfile", "Users"));
        }
コード例 #3
0
        public void Update(UsersBO user)
        {
            Users NewUser = AutoMapper <UsersBO, Users> .Map(user);

            Database.UsersUowRepository.Update(NewUser);
            Database.Save();
        }
コード例 #4
0
        public ActionResult DeleteUser(string UserID)
        {
            var result = new UsersBO().DeleteUsers(new Users {
                UserID = UserID
            });

            return(RedirectToAction("Index"));
        }
コード例 #5
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            string name  = TextBox2.Text;
            string email = TextBox3.Text;
            int    phone = Convert.ToInt32(TextBox4.Text);

            UsersBO.AddNewUser(name, email, phone);
        }
コード例 #6
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            int     id = Convert.ToInt32(TextBox1.Text.ToString());
            DataRow r  = UsersBO.GetUserById(id);

            TextBox2.Text = r[5].ToString();
            TextBox3.Text = r[7].ToString();
            TextBox4.Text = r[9].ToString();
        }
コード例 #7
0
        public void Create(UsersBO user)
        {
            Users NewUser = new Users()
            {
                Login = user.Login, Password = user.Password, Email = user.Email
            };

            Database.UsersUowRepository.Create(NewUser);
            Database.Save();
        }
コード例 #8
0
        public static UsersPO UsersBOtoPO(UsersBO from)
        {
            UsersPO to = new UsersPO();

            to.UserID    = from.UserID;
            to.FirstName = from.FirstName;
            to.LastName  = from.LastName;
            to.Email     = from.Email;
            to.City      = from.City;
            to.UserName  = from.UserName;
            to.Password  = from.Password;
            to.RoleID    = from.RoleID;
            to.RoleName  = from.RoleName;

            return(to);
        }
コード例 #9
0
        public ActionResult Create(UsersViewModel user)
        {
            if (ModelState.IsValid)
            {
                UsersBO newUser = AutoMapper <UsersViewModel, UsersBO> .Map(user);

                newUser.IsDelete = false;
                HttpCookie cookie = new HttpCookie("My localhost cookie");
                cookie["ids"]  = autServ.GetUserId(user.Login, user.Password).ToString();
                cookie.Expires = DateTime.Now.AddHours(1);
                Response.Cookies.Add(cookie);
                userServ.Create(newUser);
                return(RedirectToActionPermanent("Index", "Users"));
            }
            return(View("Create"));
        }
コード例 #10
0
        public ActionResult SaveUser(Users user)
        {
            try
            {
                user.LogInStatus = true;
                user.CreatedBy   = USER_ID;
                user.ModifiedBy  = USER_ID;

                var result = new UsersBO().SaveUsers(user, COMPANY_ID);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);
            }
            var lstUsers = new UsersBO().GetList();

            return(View("Index", lstUsers));
        }
コード例 #11
0
        public ActionResult DeleteAccount()
        {
            HttpCookie cookieReq = Request.Cookies["My localhost cookie"];

            int ids = 0;

            if (cookieReq != null)
            {
                ids = Convert.ToInt32(cookieReq["ids"]);
            }
            UsersViewModel oldUser = AutoMapper <UsersBO, UsersViewModel> .Map(userServ.GetUser, (int)ids);

            oldUser.IsDelete = true;

            UsersBO newUser = AutoMapper <UsersViewModel, UsersBO> .Map(oldUser);

            userServ.Update(newUser);
            FormsAuthentication.SignOut();
            return(RedirectToAction("Index", "Home"));
        }
コード例 #12
0
        public ActionResult EditUser(string userID)
        {
            Users user = new Users();

            if (userID == "NEW")
            {
                userID = "";
            }

            if (userID != null && userID.Length > 0)
            {
                user = new UsersBO().GetUsers(new Users {
                    UserID = userID
                });
            }

            ViewBag.BranchList = new BranchBO()
                                 .GetListByCompanyCode(COMPANY_ID);

            user.userBranchList = new UserBranchBO().GetUserBranchSelectedList(user.UserID, COMPANY_ID);

            //ViewBag.userBranchSelectedList = Temp;

            //for (var i = 0; i < Temp.Count; i++)
            //{
            //    var userBranch = new UserBranch();

            //    userBranch.BranchID = Temp[i].BranchID;
            //    userBranch.UserID = Temp[i].UserID;

            //    user.userBranchList.Add(userBranch);
            //}

            user.RoleCodeList = new RolesBO().GetList().Select(x => new SelectListItem
            {
                Value = x.RoleCode,
                Text  = x.RoleDescription
            }).ToList();

            return(View("EditUser", user));
        }
コード例 #13
0
        public ActionResult Index()
        {
            var usersList = new UsersBO().GetList();

            return(View("Index", usersList));
        }
コード例 #14
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     GridView1.DataSource = UsersBO.GetUsers();
     GridView1.DataBind();
 }
コード例 #15
0
ファイル: AccountController.cs プロジェクト: 6624465/EDU
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            model.CompanyCode = "EZY";
            var    BranchDetails = new BranchBO().GetList().Where(x => x.BranchID == model.BranchID).ToList();
            string BranchName    = BranchDetails.Select(x => x.BranchName).FirstOrDefault();

            //if (!string.IsNullOrEmpty(Request.QueryString["companyCode"]))
            //{
            //    var companyCode = UrlEncryptionHelper.Decrypt(Request.QueryString["companyCode"]);
            //    var branchList = new BranchBO().GetList().Where(x => x.CompanyCode == companyCode).ToList();
            //    model.BranchList = new SelectList(branchList, "BranchID", "BranchName");

            //    var compist = new CompanyBO().GetList();
            //    for (var i = 0; i < compist.Count; i++)
            //    {
            //        compist[i].CompanyCode = UrlEncryptionHelper.Encrypt(compist[i].CompanyCode);
            //    }
            //    model.CompaniesList = new SelectList(compist, "CompanyCode", "CompanyName");

            //    return View("Index", model);
            //}

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            var lstUsers = new UsersBO().GetList();

            var currentUser = lstUsers.Where(
                ur => ur.UserID.ToLower() == model.UserID.ToLower() &&
                ur.Password.ToLower() == model.Password.ToLower()).FirstOrDefault();

            var userBranch = new UserBranchBO().GetList(model.UserID)
                             .Where(x => x.BranchID == model.BranchID)
                             .FirstOrDefault();

            if (currentUser != null && userBranch != null)
            {
                FormsAuthentication.SetAuthCookie(currentUser.UserID, false);

                var _CompanyId = model.CompanyCode;
                var SsnObj     = new SessionObject {
                    UserID      = currentUser.UserID,
                    UserName    = currentUser.UserName,
                    Email       = currentUser.Email,
                    RoleCode    = currentUser.RoleCode,
                    BranchId    = model.BranchID,
                    BranchName  = BranchName,
                    CompanyId   = _CompanyId,
                    CompanyName = new CompanyBO().GetList().Where(x => x.CompanyCode == _CompanyId).FirstOrDefault().CompanyName
                };

                USER_OBJECT     = SsnObj;
                USER_SECURABLES = new RoleRightsBO().GetSecurableItemsListByRoleCode(SsnObj.RoleCode);

                Session["UserID"]   = currentUser.UserID;
                Session["UserName"] = currentUser.UserName;
                Session["BranchId"] = model.BranchID;

                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                    !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Education", "Home"));
                }
            }
            else
            {
                //ModelState.AddModelError("", "The user name or password provided is incorrect.");

                ViewBag.ErrMsg = "The user name or password provided is incorrect.";
                LoginViewModel modelObj = new LoginViewModel();

                var compist = new CompanyBO().GetList();
                for (var i = 0; i < compist.Count; i++)
                {
                    compist[i].CompanyCode = UrlEncryptionHelper.Encrypt(compist[i].CompanyCode);
                }
                modelObj.CompaniesList = new SelectList(compist, "CompanyCode", "CompanyName");
                var companyCode = "EZY";
                var branchList  = new BranchBO().GetList().Where(x => x.CompanyCode == companyCode).ToList();
                modelObj.BranchList = new SelectList(branchList, "BranchID", "BranchName").ToList();

                return(View("Index", modelObj));
            }
        }
コード例 #16
0
ファイル: frmLogin.cs プロジェクト: KhucDinhLong/CDXK
        //  UF
        private void Process()
        {
            {
                try
                {
                    Count++;
                    int LogStatus = UsersBO.ValidateUser(txtUserName.Text, SecUtils.GetPassword(txtPassword.Text));
                    if (LogStatus == -1)
                    {
                        SecUtils.InsertLogFail(txtUserName.Text);
                        if (SecUtils.CheckCountLogFail(this, txtUserName.Text) == false)
                        {
                            btnExit_Click(null, null);
                        }
                        MessageBox.Show("Sai Username hoặc Password !", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtPassword.Focus();
                        return;
                    }
                    else if (LogStatus == 0)
                    {
                        MessageBox.Show("User đang bị khóa !", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    else
                    {
                        if (SecUtils.CheckCountLogFail(this, txtUserName.Text) == false)
                        {
                            btnExit_Click(null, null);
                        }
                        if (Global.LockUserID == 0)
                        {
                            UsersModel mU = (UsersModel)UsersBO.Instance.FindByAttribute("LoginName", txtUserName.Text)[0];

                            Global.UserID      = mU.ID;
                            Global.UserGroupID = mU.UserGroupID;
                            Global.UserName    = txtUserName.Text.Trim();
                            Global.IsFullView  = mU.IsFullView;

                            Global.FullName  = mU.FirstName + " " + mU.MiddleName + " " + mU.LastName;
                            Global.ShiftID   = 0;
                            Global.CashierNo = "";

                            status = true; LoginStatus = true;

                            // Gán thông tin lúc đăng nhập
                            Global.LockUserID   = 0;
                            Global.LockUserName = "";
                            Global.DoTime       = DateTime.Now;
                            Global.IsCheckLock  = true;
                            this.Close();
                        }
                        else
                        {
                            UsersModel mU = (UsersModel)UsersBO.Instance.FindByAttribute("LoginName", txtUserName.Text)[0];
                            if (mU.ID == Global.LockUserID)
                            {
                                Global.UserID      = mU.ID;
                                Global.UserGroupID = mU.UserGroupID;
                                Global.UserName    = txtUserName.Text.Trim();
                                Global.IsFullView  = mU.IsFullView;

                                Global.FullName  = mU.FirstName + " " + mU.MiddleName + " " + mU.LastName;
                                Global.ShiftID   = 0;
                                Global.CashierNo = "";

                                status              = true; LoginStatus = true;
                                Global.LockUserID   = 0;
                                Global.LockUserName = "";
                                // Gán thông tin lúc đăng nhập
                                Global.LockUserID   = 0;
                                Global.LockUserName = "";
                                Global.DoTime       = DateTime.Now;
                                Global.IsCheckLock  = true;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show(string.Format("Chương trình đang được sử dụng bởi [{0}] !", Global.LockUserName), "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }