Example #1
0
        protected void Singup(object sender, EventArgs e)
        {
            //Storing Info
            string[] address = new string[10];
            //Personal info
            address[0] = (string)Fname.Text;
            address[1] = (string)Lname.Text;
            address[2] = (string)phone.Text;
            //Address info
            address[3] = (string)addressNumber.Text;
            address[4] = (string)addressStreet.Text;
            address[5] = (string)city.Text;
            address[6] = (string)state.Text;
            address[7] = (string)uname.Text;
            address[8] = (string)passwd.Text;
            address[9] = (string)TextBox1.Text;
            //Getting the Address together in the form the database wants
            string fullAddress = address[3] + ", " + address[4] + ", " + address[5] + ", " + ", " + address[6];

            loginDataSetTableAdapters.customerTableAdapter singup = new loginDataSetTableAdapters.customerTableAdapter();
            ////Using the DataSet with the sing up method
            singup.registerUser(address[0], address[1], fullAddress, address[2], address[7], address[8], address[9]);
            Response.Redirect("/login.aspx");
            #region Old way

            /*
             * string conString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = " + Server.MapPath("~/ebookstoredb.mdb");
             * using (OleDbConnection conn = new OleDbConnection(conString))
             * {
             *  conn.Open();
             *
             *  String query = "INSERT INTO customer ([Fname],[Lname],[Address],[Phone],[uname],[passwd],[email]) values(@first , @last , @address , @phone , @uname, @passwd, @email)";
             *  using (OleDbCommand cmd = new OleDbCommand(query, conn))
             *  {
             *      cmd.Parameters.AddWithValue("@first", address[0]);
             *      cmd.Parameters.AddWithValue("@last", address[1]);
             *      cmd.Parameters.AddWithValue("@address", fullAddress);
             *      cmd.Parameters.AddWithValue("@phone", address[2]);
             *      cmd.Parameters.AddWithValue("@uname", address[7]);
             *      cmd.Parameters.AddWithValue("@passwd", address[8]);
             *      cmd.Parameters.AddWithValue("@email", address[9]);
             *      cmd.ExecuteNonQuery();
             *  }
             *  conn.Close();
             *  Response.Write("<script> alert('Your sign up was Successful'); " +
             *                 "window.location.assign('/default.aspx');" +
             *                 "</script>");
             * } */
            #endregion
        }
Example #2
0
        protected void LoginFunction(object sender, EventArgs e)
        {
            string uname = (string)username.Text;
            string pwd   = (string)passwd.Text;

            //Using a dataSet for the login
            loginDataSetTableAdapters.customerTableAdapter login = new loginDataSetTableAdapters.customerTableAdapter();
            if (Convert.ToInt32(login.trylogin(uname, pwd)) > 0)
            {
                Session["ID"] = login.getUsersID(uname);
                Response.Redirect("Default.aspx");
            }
            else
            {
                console.Text = "Please try again";
            }
            #region OldWay

            /*
             * string conString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = " + Server.MapPath("~/ebookstoredb.mdb");
             * using (OleDbConnection conn = new OleDbConnection(conString))
             * {
             *  conn.Open();
             *
             *  String query = "SELECT * FROM customer WHERE uname = @username AND passwd = @passwd";
             *  using (OleDbCommand cmd = new OleDbCommand(query, conn))
             *  {
             *      cmd.Parameters.AddWithValue("@username", uname);
             *      cmd.Parameters.AddWithValue("@passwd", passwd.Text);
             *      int? result = (int?)cmd.ExecuteScalar();
             *      if (result != null)
             *      {
             *          Session["username"] = uname;
             *          Response.Redirect("Default.aspx");
             *      }
             *      else
             *      {
             *          console.Text = "Please try again";
             *      }
             *  }
             *  conn.Close();*/
            #endregion
        }