Ejemplo n.º 1
0
        protected void btn_signIn_Click(object sender, EventArgs e)
        {
            SystemLogin logs  = new SystemLogin();
            List <User> users = logs.GetAllUser();

            foreach (User user in users)
            {
                if (user.UserName.Equals(txt_username.Text))
                {
                    if (user.Password.Equals(txt_password.Text))
                    {
                        Session["User"] = user;
                        Server.Transfer("ClaimList.aspx", true);
                    }
                    else
                    {
                        lblError.Text = "Wrong Password";
                    }

                    break;
                }
                else
                {
                    lblError.Text = "Username is not exists";
                }
            }
        }
Ejemplo n.º 2
0
        private void _GridViewBind()
        {
            ClaimDetail = (Claim)ViewState["Claim"];
            if (ClaimDetail.Expenses == null)
            {
                SystemLogin sl = new SystemLogin();
                foreach (Claim cl in sl.GetAllClaim())
                {
                    if (cl.ID == Convert.ToInt32(HFClaimID.Value))
                    {
                        ClaimDetail = cl;
                    }
                }
            }
            else if (ClaimDetail.Expenses != null)
            {
                if (ClaimDetail.Expenses.Count == 0)
                {
                    // ClaimDetail.Expenses.Add(new Expenses());
                }

                this.pnlAddEdit.Visible = true;
                gw_ForEdit.DataSource   = ClaimDetail.Expenses;
                gw_ForEdit.DataBind();
            }
            else
            {
                this.pnlAddEdit.Visible = false;
            }
        }
Ejemplo n.º 3
0
 public void Add(SystemLogin login)
 {
     if (login != null)
     {
         _dbContext.SystemLogins.Add(login);
     }
 }
Ejemplo n.º 4
0
        //public HomeController(IUnitOfWork unitOfWork)
        //{
        //  //_unitOfWork = unitOfWork;
        //  this._unitOfWork = unitOfWork;

        //}


        public ActionResult Index()
        {
            SystemLogin sys = new SystemLogin();

            ViewBag.login = sys.Get();

            return(View());
        }
Ejemplo n.º 5
0
        public void testLoginNameisnull()
        {
            SystemLogin        s  = new SystemLogin();
            SystemLoginService sl = new SystemLoginService();

            s = sl.GetModel("ad");
            Assert.IsTrue(s == null);
        }
Ejemplo n.º 6
0
        public void TestMethod1()
        {
            SystemLogin        s  = new SystemLogin();
            SystemLoginService sl = new SystemLoginService();

            s = sl.GetModel("admin");
            Assert.IsTrue(s != null);
            Console.WriteLine(s.LoginName);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 判断密码和账号是否匹配
 /// </summary>
 /// <param name="loginname"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public bool LoginNameAndPasswordIsMatch(string loginname, string password)
 {
     sl = sls.GetModel(loginname);
     if (sl.Password == password)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
        public void Update(SystemLogin login)
        {
            var updatelogin = _dbContext.SystemLogins.Find(login.Id);

            if (updatelogin != null)
            {
                updatelogin.LoginName = login.LoginName;
                updatelogin.Password  = login.Password;
                updatelogin.IsLock    = login.IsLock;
                updatelogin.UserId    = login.UserId;
            }
        }
Ejemplo n.º 9
0
 //账号是否存在
 public bool IsExist(string loginName)
 {
     sl = sls.GetModel(loginName);
     if (sl != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 10
0
        public void TestAddLogin()
        {
            SystemLogin        sl  = new SystemLogin();
            SystemLoginService sls = new SystemLoginService();

            sl.LoginName = "aaaaa";
            sl.Password  = "******";
            sl.IsLock    = 1;
            sls.Add(sl);
            int result = sls.SaveChanges();

            Assert.IsTrue(result == 1);
        }
Ejemplo n.º 11
0
        public SystemLogin GetModel(string loginName)
        {
            SystemLogin sl = new SystemLogin();

            try
            {
                sl = _dbContext.SystemLogins.Single(l => l.LoginName == loginName);
                return(sl);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sl"></param>
        /// <returns></returns>
        public int Update(SystemLogin sl)
        {
            sls.Update(sl);
            int result = sls.SaveChanges();

            if (result != 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 添加一个账号
        /// </summary>
        /// <param name="sl"></param>
        /// <returns></returns>
        public int AddLogin(SystemLogin sl)
        {
            sls.Add(sl);
            int reuslt = sls.SaveChanges();

            if (reuslt != 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
        public DataResult <User> Register(UserRegistrationRequestDto registrationRequest)
        {
            if (!registrationRequest.Password.Equals(registrationRequest.PasswordConfirmation))
            {
                return(new DataResult <User>(DataResultType.ValidationError,
                                             "The password and confirmation password must be the same."));
            }

            var saltBytes = new byte[128];

            new RNGCryptoServiceProvider().GetBytes(saltBytes);

            var systemLogin = new SystemLogin
            {
                CreatedDate            = DateTime.Now,
                EmailAddress           = registrationRequest.EmailAddress,
                PasswordHash           = Convert.ToBase64String(GetSaltedHash(registrationRequest.Password, saltBytes)),
                PasswordSalt           = Convert.ToBase64String(saltBytes),
                EmailConfirmationToken = registrationRequest.ConfirmationToken,
                IsEmailConfirmed       = false
            };

            _databaseContext.SystemLogins.Add(systemLogin);
            _databaseContext.SaveChanges();
            if (systemLogin.SystemLoginId == 0)
            {
                return(new DataResult <User>(DataResultType.UnableToCreateRecord, "Unable to create system login"));
            }

            var user = new User
            {
                CreatedDate   = DateTime.Now,
                SystemLoginId = systemLogin.SystemLoginId,
                FirstName     = registrationRequest.FirstName,
                Surname       = registrationRequest.Surname,
                DateOfBirth   = registrationRequest.DateOfBirth,
                SystemRoleId  = (int)SystemRoles.Unknown,
                BranchId      = 1
            };

            _databaseContext.Users.Add(user);
            _databaseContext.SaveChanges();
            if (user.UserId == 0)
            {
                return(new DataResult <User>(DataResultType.UnableToCreateRecord, "Unable to create user"));
            }

            return(new DataResult <User>(user, new DataResult(DataResultType.Success, "Successfully created user")));
        }
Ejemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["User"] == null)
                {
                    Server.Transfer("LoginPage.aspx", true);
                }

                SystemLogin logs = new SystemLogin();
                Claims            = logs.GetAllClaim();
                Session["Claims"] = Claims;
                _GridViewBind();
            }
        }
Ejemplo n.º 16
0
        private Claim _GetClaim(int ID)
        {
            if (Claims == null)
            {
                SystemLogin logs = new SystemLogin();
                Claims            = logs.GetAllClaim();
                Session["Claims"] = Claims;
            }

            Claim claim = new Claim();

            foreach (Claim c in Claims)
            {
                if (c.ID == ID)
                {
                    claim = c;
                }
            }

            return(claim);
        }
Ejemplo n.º 17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ClaimDetail = (Claim)ViewState["Claim"];

            if (lblID.Text == "0")
            {
                Expenses expenses = new Expenses();
                expenses.ClaimID = ClaimDetail.ID;
                expenses.User    = ClaimDetail.User;
                _AssignData(expenses);
            }
            else
            {
                foreach (Expenses expenses in ClaimDetail.Expenses)
                {
                    if (expenses.Id.ToString() == lblID.Text)
                    {
                        _AssignData(expenses);
                        //expenses.Id = Convert.ToInt32(txtID.Text);

                        break;
                    }
                }
            }

            SystemLogin sl = new SystemLogin();

            foreach (Claim cl in sl.GetAllClaim())
            {
                if (ClaimDetail.ID == cl.ID)
                {
                    ClaimDetail = cl;
                }
            }

            ViewState["Claim"] = ClaimDetail;
            mp1.Hide();
            _GridViewBind();
            Response.Redirect("ClaimForm.aspx");
        }
Ejemplo n.º 18
0
        private void btndeleteuser_Click(object sender, EventArgs e)
        {
            //获取当前选择记录id
            int         userId = Convert.ToInt32(this.dgvUserSetting.CurrentRow.Cells[0].Value);
            SystemLogin login  = sll.GetLoginModel(this.dgvUserSetting.CurrentRow.Cells[9].Value.ToString());
            int         reuslt = sul.Delete(userId);

            if (reuslt == 1)
            {
                //删除账号
                if (login != null)
                {
                    sll.Delete(login.Id);
                    MessageBox.Show("删除成功!");
                    RefreshUserList();
                }
            }
            else
            {
                MessageBox.Show("删除失败!");
            }
        }
Ejemplo n.º 19
0
        private void btnLockedAccount_Click(object sender, EventArgs e)
        {
            //判断当前账号是否启用,若启用,则提示是否禁用账户,如未启用,则提示是否启用
            //获取当前选择的数据
            string loginname = dgvAccountSetting.CurrentRow.Cells[1].Value.ToString();

            sl = sll.GetLoginModel(loginname);
            if (sl.IsLock == 1)
            {
                sl.IsLock = 0;
                sll.Update(sl);
                MessageBox.Show("账号已被禁用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //刷新数据
                DisplayLoginNameList();
            }
            else
            {
                sl.IsLock = 1;
                sll.Update(sl);
                MessageBox.Show("账号已启用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DisplayLoginNameList();
            }
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["User"] == null)
                {
                    Server.Transfer("LoginPage.aspx", true);
                }

                ClaimDetail = (Claim)Session["Claim"];

                SystemLogin sl = new SystemLogin();
                foreach (Claim cl in sl.GetAllClaim())
                {
                    if (cl.ID == ClaimDetail.ID)
                    {
                        ClaimDetail = cl;
                    }
                }

                HFClaimID.Value    = ClaimDetail.ID.ToString();
                ViewState["Claim"] = ClaimDetail;
                _PopulateClaimDetails();
                if (ClaimDetail.Expenses == null)
                {
                    ClaimDetail.Expenses = new List <Expenses>();
                    ClaimDetail.Expenses.Sort();

                    ViewState["Expenses"] = ClaimDetail.Expenses;
                }

                _GridViewBind();
                _PopulateDetails(new Expenses());

                btnAddExpenses.Enabled = ClaimDetail.ID > 0;
            }
        }