/// <summary>
        /// Fills the form with a user's information
        /// </summary>
        /// <param name="user">A PMT user</param>
        public void fillForm(PMT.User user)
        {
            this.FirstNameTextBox.Text = user.FirstName;
            this.FirstNameLabel.Text   = user.FirstName;
            this.LastNameTextBox.Text  = user.LastName;
            this.LastNameLabel.Text    = user.LastName;
            this.AddressTextBox.Text   = user.Address;
            this.AddressLabel.Text     = user.Address;
            this.CityTextBox.Text      = user.City;
            this.CityLabel.Text        = user.City;
            this.StateTextBox.Text     = user.State;
            this.StateLabel.Text       = user.State;
            this.ZipTextBox.Text       = user.ZipCode;
            this.ZipLabel.Text         = user.ZipCode;
            this.PhoneTextBox.Text     = user.PhoneNumber;
            this.PhoneLabel.Text       = user.PhoneNumber;
            this.EmailTextBox.Text     = user.Email;
            this.EmailLabel.Text       = user.Email;

            //if (this.UsernameTextBox.Enabled)
            this.UsernameTextBox.Text = user.UserName;
            this.UsernameLabel.Text   = user.UserName;

            // select the correct Security in the dropdown
            //if (this.SecurityDropDownList.Enabled)
            SecurityDropDownList.SelectedIndex
                = SecurityDropDownList.Items.IndexOf(
                      SecurityDropDownList.Items.FindByText(user.Role));
            this.SecurityLabel.Text = user.Role;
        }
Esempio n. 2
0
        bool CustomAuthenticate(string username, string password)
        {
            DBDriver db = new DBDriver();
            string   q  = "select count(*) from softeng4.users where userName='******';";

            db.Query = q;
            int k = (int)db.scalar();

            if (k == 0)
            {
                //user does not exist in DB
                ErrorLabel.Text = "You have entered an unknown username.";
                return(false);
            }
            else
            {
                q        = "select count(*) from softeng4.users u where u.userName='******' and u.password='******'";
                db.Query = q;
                k        = (int)db.scalar();
                if (k == 0)
                {
                    //password incorrect
                    ErrorLabel.Text = "You have entered an incorrect password.";
                    return(false);
                }
                else
                {
                    //successful authentication
                    q        = "select u.security s, u.ID id, p.firstName fname, p.lastName lname from softeng4.users u, softeng4.person p where u.ID = p.ID and u.username='******'";
                    db.Query = q;
                    SqlDataReader dr = db.createReader();
                    dr.Read();

                    user = new User(dr["id"].ToString());

                    db.close();

                    // create the cookie
                    Response.Cookies["user"].Values.Add("role", user.Role);
                    Response.Cookies["user"].Values.Add("id", user.ID);
                    Response.Cookies["user"].Values.Add("name", user.UserName);
                    Response.Cookies["user"].Values.Add("fname", user.FirstName);
                    Response.Cookies["user"].Values.Add("lname", user.LastName);

                    return(true);
                }
            }
        }
Esempio n. 3
0
        bool CustomAuthenticate(string username, string password)
        {
            DBDriver db = new DBDriver();
            string q="select count(*) from softeng4.users where userName='******';";
            db.Query = q;
            int k=(int)db.scalar();
            if(k==0)
            {
                //user does not exist in DB
                ErrorLabel.Text = "You have entered an unknown username.";
                return false;
            }
            else
            {
                q="select count(*) from softeng4.users u where u.userName='******' and u.password='******'";
                db.Query = q;
                k=(int)db.scalar();
                if(k==0)
                {
                    //password incorrect
                    ErrorLabel.Text = "You have entered an incorrect password.";
                    return false;
                }
                else
                {
                    //successful authentication
                    q="select u.security s, u.ID id, p.firstName fname, p.lastName lname from softeng4.users u, softeng4.person p where u.ID = p.ID and u.username='******'";
                    db.Query = q;
                    SqlDataReader dr=db.createReader();
                    dr.Read();

                    user = new User(dr["id"].ToString());

                    db.close();

                    // create the cookie
                    Response.Cookies["user"].Values.Add("role",  user.Role);
                    Response.Cookies["user"].Values.Add("id",    user.ID);
                    Response.Cookies["user"].Values.Add("name",  user.UserName);
                    Response.Cookies["user"].Values.Add("fname", user.FirstName);
                    Response.Cookies["user"].Values.Add("lname", user.LastName);

                    return true;
                }
            }
        }
 /// <summary>
 /// fill a user object from the form
 /// </summary>
 /// <param name="user"></param>
 public void fillUser(PMT.User user)
 {
     user.Address     = this.AddressTextBox.Text;
     user.City        = this.CityTextBox.Text;
     user.Email       = this.EmailTextBox.Text;
     user.FirstName   = this.FirstNameTextBox.Text;
     user.LastName    = this.LastNameTextBox.Text;
     user.PhoneNumber = this.PhoneTextBox.Text;
     if (this.AllowChangeSecurity)
     {
         user.Role = this.SecurityDropDownList.SelectedItem.Text;
     }
     user.State   = this.StateTextBox.Text;
     user.ZipCode = this.ZipTextBox.Text;
     if (NewPassword1TextBox.Text.Length > 0)
     {
         user.Password = this.NewPassword1TextBox.Text;
     }
 }