}//checkUserExist() //start password public bool checkPassword() { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings ["pizzaDBSummer2017"].ConnectionString); conn.Open(); string checkuser = "******"; SqlCommand comd = new SqlCommand(checkuser, conn); comd.Parameters.AddWithValue("@username", this.userName); SqlDataReader dr = comd.ExecuteReader(); dr.Read(); if (dr.HasRows) { if (dr["Password"].ToString().Equals(EncryptPassword.encryptString(this.password))) { //if (dr["Password"].ToString().Equals(this.password)) // { dr.Close(); conn.Close(); return(true); } } // dr.Close(); // conn.Close(); return(false); }// get user info 7-13 after reset password
}//close gettuser info public void resetPassord(string newPassword) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings ["pizzaDBSummer2017"].ConnectionString); conn.Open(); string updateStr = "update Customer Set Customer.Password=@password where Customer.UserName=@userName"; SqlCommand comd = new SqlCommand(updateStr, conn); comd.Parameters.AddWithValue("@userName", this.userName); comd.Parameters.AddWithValue("@password", EncryptPassword.encryptString(newPassword)); comd.ExecuteNonQuery(); conn.Close(); }
//methods public void insertData() {//build connect SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings ["pizzaDBSummer2017"].ConnectionString); conn.Open(); string insertString = "insert into Customer(UserName,FName,LName,Email,Country,Password,Age,Gender)values(@UserName, @FName, @LName, @Email, @Country, @Password,@Age,@Gender)"; SqlCommand comd = new SqlCommand(insertString, conn); comd.Parameters.AddWithValue("@UserName", this.userName); comd.Parameters.AddWithValue("@FName", this.fName); comd.Parameters.AddWithValue("@lName", this.lName); comd.Parameters.AddWithValue("@Email", this.email); comd.Parameters.AddWithValue("@Country", this.country); comd.Parameters.AddWithValue("@Password", EncryptPassword.encryptString(this.password)); // comd.Parameters.AddWithValue("@Password", this.password); comd.Parameters.AddWithValue("@Age", this.age); comd.Parameters.AddWithValue("@Gender", this.gender); comd.ExecuteNonQuery(); conn.Close(); }// close insertData method