Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Page.User.Identity.IsAuthenticated == false)
                    Response.Redirect("~/Admincp/Login.aspx");

                User user = new UserRepo().GetUserByUsername(ToSQL.EmptyNull(Page.User.Identity.Name));
                if (user != null && user.LastLogin !=null)
                {
                    lbLastlogin.Text = user.LastLogin.Value.ToString("MM-dd-yyyy hh:mm");
                }
            }
        }
Esempio n. 2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     UserRepo userrepo =new UserRepo();
     lbMessage.Text = "";
     if (userrepo.DoesUsernameExist(txtUserName.Text))
     {
         lbMessage.Text = "Username already exists!";
         lbMessage.ForeColor = System.Drawing.Color.Red;
         txtUserName.Text = "";
         return;
     }
     if (userrepo.DoesEmailExist(txtEmail.Text))
     {
         lbMessage.Text = "Email already exists!";
         lbMessage.ForeColor = System.Drawing.Color.Red;
         txtEmail.Text = "";
         return;
     }
     User user = new User();
     user.FirstName = txtFirstName.Text;
     user.LastName = txtLastName.Text;
     user.Username = txtUserName.Text;
     user.Key = ConfigurationManager.AppSettings["KeyUser"];
     user.Password = Security.Encrypt(user.Key, txtPassword.Text);
     user.Phone = txtPhone.Text;
     user.Email = txtEmail.Text;
     user.Address = new Address();
     user.Address.Street1 = txtStreet1.Text;
     user.Address.Street2 = txtStreet2.Text;
     user.Address.City = txtCity.Text;
     user.Address.State = txtState.Text;
     user.Address.Country = txtCountry.Text;
     user.Address.ZipCode = txtZipCode.Text;
     user.DateCreated = DateTime.Now;
     user.IsActive = true;
     user.IsAdmin = false;
     if ((new UserRepo()).CreateUser(user) > 0)
     {
         Response.Redirect("~/Admincp/Management-User.aspx");
     }
 }