Esempio n. 1
0
 /*USED IN THE USER CREATION PROCESS
   * FUNCTION         :This method create a new user in the DB
   * RETURN           :TRUE if the user is created, FALSE orthewise
   * MORE             :Before calling this method, the "login" of the new user
   *                  will be previously validate with the method "VALIDATELOGIN(string login) above
   **/
 public bool CreateNewUserCAD(UserClass user)
 {
     bool updated = false;
     DataSet bdvirtual = new DataSet();
     try
     {
         SqlDataAdapter da = new SqlDataAdapter("select *from UserTable", c);
         da.Fill(bdvirtual, "UserTable");
         DataTable tabla = new DataTable();
         tabla = bdvirtual.Tables["UserTable"];
         DataRow nuevaFila = tabla.NewRow();
         nuevaFila[0] = 2;
         nuevaFila[1] = user.FirstName;
         nuevaFila[2] = user.LastName;
         nuevaFila[3] = user.DateOfBirth;
         nuevaFila[4] = user.UserName;
         nuevaFila[5] = user.Password;
         nuevaFila[6] = user.Email;
         nuevaFila[7] = user.Country;
         tabla.Rows.Add(nuevaFila);
         SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
         da.Update(bdvirtual, "UserTable");
         updated = true;
     }
     catch (SqlException exp){updated = false;}
     finally{c.Close();}
     return updated;
 }
Esempio n. 2
0
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            UserClass user = new UserClass();

              /*  user.FirstName = "Firmin";
            user.LastName = "Firmino";
            user.UserName = create*/
        }
Esempio n. 3
0
 protected void ModifyData_Click(object sender, EventArgs e)
 {
     int userID = Convert.ToInt32(Session["idUser"].ToString().Trim());
     UserClass user = new UserClass(userID);
     user.UserName=UserName.Text;
     user.FirstName=FirstName.Text;
     user.LastName=LastName.Text;
     user.Email = Email.Text;
     user.DateOfBirth=Convert.ToDateTime(DateOfBirth.Text);
     user.Country=Country.Text;
     user.updateUserInfo();
 }
Esempio n. 4
0
 public UserClass(int newIdUser)
 {
     idUser = newIdUser;
     UserClass user = new UserClass();
     user=getUserInformation();
     UserName = user.UserName;
     FirstName = user.FirstName;
     LastName = user.LastName;
     Password = user.Password;
     Email = user.Email;
     DateOfBirth = user.DateOfBirth;
     Country = user.Country;
 }
Esempio n. 5
0
 protected void ChangeUserPassword_ChangedPassword(object sender, EventArgs e)
 {
     if(ChangeUserPassword.NewPassword==ChangeUserPassword.ConfirmNewPassword)
     {
         int userID = Convert.ToInt32(Session["idUser"].ToString().Trim());
         UserClass user = new UserClass(userID);
         if (ChangeUserPassword.CurrentPassword == user.Password)
         {
            user.Password = ChangeUserPassword.NewPassword;
            user.updateUserInfo();
         }
     }
 }
Esempio n. 6
0
        //Constructor of copy
        public UserClass(UserClass user)
        {
            userName = user.UserName;

            firstName = user.FirstName;

            lastName = user.LastName;

            password = user.Password;

            email = user.Email;

            dateOfBirth = user.DateOfBirth;

            country = user.Country;
        }
Esempio n. 7
0
 protected void RegisterButton_Click(object sender, EventArgs e)
 {
     UserClass tempUser = new UserClass();
     String nick=UserName.Text;
     String password=Password.Text;
     String password2=ConfirmPassword.Text;
     String name=FirstName.Text;
     String subname=LastName.Text;
     String email=Email.Text;
     DateTime birth = Convert.ToDateTime(DateOfBirth.Text);
     String country=Country.Text;
     if (tempUser.ValidateLogin(nick))
     {
         UserClass newUser = new UserClass(nick, subname, name, email, password, birth, country);
         newUser.CreateNewUser();
     }
 }
Esempio n. 8
0
 private void showData()
 {
     int userID = Convert.ToInt32(Session["idUser"].ToString().Trim());
     UserClass user = new UserClass(userID);
     FirstName.Text = user.FirstName;
     LastName.Text = user.LastName;
     Email.Text = user.Email;
     Country.Text = user.Country;
     user.getUserInformation();
     UserName.Text=user.UserName;
     FirstName.Text=user.FirstName;
     LastName.Text=user.LastName;
     Email.Text=user.Email;
     DateTime dt = user.DateOfBirth;
     DateOfBirth.Text = String.Format("{0:dd/MM/yyyy}", dt);
     Country.Text=user.Country;
 }
Esempio n. 9
0
 /*USED WHEN A USER EDIT HIS INFORMATIONS
  * DETAILS      :This function retrieve the informations of the user from the DB
  *              and print them.
  * RETURN       :An object UserClass with all the user information.
  * */
 public UserClass getUserInformation()
 {
     UserCAD userBD = new UserCAD();
     UserClass user = new UserClass();
     user = userBD.getUserInformationCAD(IdUser);
     return user;
 }
Esempio n. 10
0
 /*USED IN THE MODIFICATION OF THE USER'S INFORMATIONS:
 * DETAILS      : This function modify the user information in the DB.
 *              The user already exist in the DB.
 * RETURN       :TRUE if the information are updated, FALSE otherwise.
 * */
 public bool updateUserInfoCAD(UserClass usuario)
 {
     bool updated = false;
     //UserClass user = usuario;
     DataSet bdvirtual = new DataSet();
     try
     {
         SqlDataAdapter da = new SqlDataAdapter("Select * from UserTable where idUser =\'" + usuario.IdUser + "\'", c);
         da.Fill(bdvirtual, "UserTable");
         DataTable t = new DataTable();
         t = bdvirtual.Tables["UserTable"];
         t.Rows[0]["userName"] = usuario.UserName;
         t.Rows[0]["firstName"] = usuario.FirstName;
         t.Rows[0]["lastName"] = usuario.LastName;
         t.Rows[0]["password"] = usuario.Password;
         t.Rows[0]["email"] = usuario.Email;
         t.Rows[0]["dateOfbirth"] = usuario.DateOfBirth;
         t.Rows[0]["country"] = usuario.Country;
         SqlCommandBuilder cbuilder = new SqlCommandBuilder(da);
         da.Update(bdvirtual, "UserTable");
         updated = true;
     }
     catch (Exception ex){updated = false;}
     finally{c.Close();}
     return updated;
 }
Esempio n. 11
0
        /*USED WHEN A USER EDIT HIS INFORMATIONS
         * DETAILS      :This function retrieve the informations of the user from the DB
         *              and print them.
         * RETURN       :An object UserClass with all the user information.
         * */
        public UserClass getUserInformationCAD(int IDuser)
        {
            UserClass usuario = new UserClass();

            try
            {
                c.Open();

                SqlCommand com = new SqlCommand("Select * from userTable where idUser =\'" +IDuser+"\'", c);

                SqlDataReader dr = com.ExecuteReader();

                dr.Read();

                usuario.LastName = dr["lastName"].ToString();
                usuario.FirstName = dr["firstName"].ToString();
                usuario.DateOfBirth = (DateTime)dr["dateOfBirth"];
                usuario.UserName = dr["userName"].ToString();
                usuario.Email = dr["email"].ToString();
                usuario.Password = dr["password"].ToString();
                usuario.Country = dr["country"].ToString();
            }
            catch (SqlException exp)
            {
                throw new Exception(exp.Message, exp);
            }
            finally
            {
                c.Close();
            }

            return usuario;
        }