示例#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 btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (SalesDBEntities1 objEntity = new SalesDBEntities1())
                {
                    userDetail objpro = objEntity.userDetails.FirstOrDefault(Pro => Pro.userName == txtUserName.Text);
                    if (objpro != null)
                    {
                        liVal.Text = "User Name Already Exists. <br/> Please Enter different Name.";
                        return;
                    }
                    else
                    {
                        userDetail objProNew = new userDetail();
                        if (ddlAccount.SelectedValue != "0")
                        {
                            objProNew.accountID = Convert.ToDecimal(ddlAccount.SelectedValue);
                        }
                        if (ddlStore.SelectedValue != "0")
                        {
                            objProNew.storeID = Convert.ToDecimal(ddlStore.SelectedValue);
                        }
                        if (ddlUserType.SelectedValue != "0")
                        {
                            objProNew.userGroupID = Convert.ToDecimal(ddlUserType.SelectedValue);
                        }
                        objProNew.state         = txtState.Text;
                        objProNew.isActive      = true;
                        objProNew.CreatedDate   = DateTime.Now;
                        objProNew.addressLine1  = txtAddLine1.Text;
                        objProNew.addressLine2  = txtAddressLine2.Text;
                        objProNew.city          = txtCity.Text;
                        objProNew.firstName     = txtFName.Text;
                        objProNew.lastName      = txtLName.Text;
                        objProNew.CreatedBy     = Convert.ToDecimal(Session["userID"]);
                        objProNew.contactNumber = txtContact.Text;
                        objProNew.userName      = txtUserName.Text;
                        objProNew.userPass      = StringCipher.EncryptStringAES(txtPass.Text);
                        objProNew.DOB           = Convert.ToDateTime(txtDOB.Text);
                        objEntity.userDetails.Add(objProNew);
                        objEntity.SaveChanges();

                        string filename = objProNew.userID.ToString() + ".jpg";
                        flPhoto.SaveAs(Server.MapPath("~/userData/userPic/" + filename));


                        Response.Redirect("~/adUsers.aspx", false);
                    }
                }
            }
            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.";
                }
            }
        }
示例#4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                decimal userID = Convert.ToDecimal(Session["userID"]);
                using (SalesDBEntities1 objEntity = new SalesDBEntities1())
                {
                    userDetail objProNew = objEntity.userDetails.FirstOrDefault(Pro => Pro.userID == userID);
                    if (objProNew != null)
                    {
                        objProNew.state = txtState.Text;

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

                        objProNew.contactNumber = txtContact.Text;
                        objProNew.userPass      = StringCipher.EncryptStringAES(txtPass.Text);
                        objProNew.DOB           = Convert.ToDateTime(txtDOB.Text);

                        objEntity.SaveChanges();

                        string filename = objProNew.userID.ToString() + ".jpg";
                        flPhoto.SaveAs(Server.MapPath("~/userData/userPic/" + filename));


                        Response.Redirect("~/adUsers.aspx", false);
                    }
                }
            }
            catch (Exception ex)
            {
                appOperations.LogException(ex, "User Save");
                liVal.Text = ex.Message;
            }
        }