Пример #1
0
        private void getUserDetail()
        {
            try
            {
                decimal userID = Convert.ToDecimal(Session["userID"]);
                using (SalesDBEntities1 objEntity = new SalesDBEntities1())
                {
                    userDetail objProNew = objEntity.userDetails.FirstOrDefault(Pro => Pro.userID == userID);
                    if (objProNew != null)
                    {
                        txtState.Text = objProNew.state;

                        txtAddLine1.Text     = objProNew.addressLine1;
                        txtAddressLine2.Text = objProNew.addressLine2;
                        txtCity.Text         = objProNew.city;
                        txtFName.Text        = objProNew.firstName;
                        txtLName.Text        = objProNew.lastName;

                        txtContact.Text = objProNew.contactNumber;
                        txtPass.Text    = StringCipher.DecryptStringAES(objProNew.userPass);
                        txtDOB.Text     = Convert.ToString(objProNew.DOB);

                        objEntity.SaveChanges();

                        string filename = objProNew.userID.ToString() + ".jpg";
                        imgPic.ImageUrl = "~/userData/userPic/" + filename;
                    }
                }
            }
            catch (Exception ex)
            {
                appOperations.LogException(ex, "User Save");
                liVal.Text = ex.Message;
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            // validate the Captcha to check we're not dealing with a bot
            bool isHuman = ExampleCaptcha.Validate(CaptchaCodeTextBox.Text);

            CaptchaCodeTextBox.Text = null; // clear previous user input

            if (!isHuman)
            {
                lblVal.Text = "Invalid Code.";
                return;
            }
            else
            {
                try
                {
                    using (SalesDBEntities1 objEntity = new SalesDBEntities1())
                    {
                        userDetail objUser = objEntity.userDetails.FirstOrDefault(users => users.userName == txtUserName.Text);
                        if (objUser != null)
                        {
                            if (StringCipher.DecryptStringAES(objUser.userPass) == txtPass.Text)
                            {
                                Session["userID"]   = objUser.userID;
                                Session["userType"] = objUser.userGroupID;
                                Session["userName"] = txtUserName.Text;
                                Session["Name"]     = objUser.firstName;
                                Response.Redirect("~/Dashboard.aspx", false);
                            }
                            else
                            {
                                lblVal.Text = "Please verify your Password";
                            }
                        }
                        else
                        {
                            lblVal.Text = "Please check user name and password.";
                        }
                    }
                }
                catch (Exception ex)
                {
                    appOperations.LogException(ex, "Login -Button Click");
                    lblVal.Text = "Something went wrong.<br/>Please try again later.";
                }
            }
        }