Esempio n. 1
0
        protected async void btnSumbit_Click(object sender, EventArgs e)
        {
            string text   = (String)Session["bookID"];
            var    result = await service.Volumes.Get(text).ExecuteAsync();

            DataModels.CreatePost cp = new DataModels.CreatePost();
            cp.title     = result.VolumeInfo.Title;
            cp.bookID    = result.Id;
            cp.price     = float.Parse(txtPrice.Text);
            cp.condition = DropDownCondition.Text;

            DataModels.Users tempUser = (DataModels.Users)Session["user"];
            int id = tempUser.userID;

            DataTiers.postTier pt = new DataTiers.postTier();

            try
            {
                pt.insertPost(cp, id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Response.Redirect("CreatePost3.aspx");
            }
            Session.Remove("bookID");
            if (!Response.IsRequestBeingRedirected)
            {
                Response.Redirect("Success.aspx");
            }
        }
Esempio n. 2
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            DataTiers.passwordHash ph = new DataTiers.passwordHash(txtPassword.Text);

            DataTiers.userTier ut   = new DataTiers.userTier();
            DataModels.Users   user = new DataModels.Users();
            user.email    = txtUserName.Text;
            user.username = txtUserName.Text;



            try
            {
                Tuple <string, string> temp = ut.login(user);
                if (ph.Verify(temp.Item1, temp.Item2, txtPassword.Text))
                {
                    user            = ut.getInfo(user);
                    Session["User"] = user;
                    Session["ID"]   = user.userID;
                    Response.Redirect("MyAccount.aspx");
                }
                else
                {
                    Label1.Text = "Incorrect password or email";
                }
            }
            catch (Exception ex)
            {
                Label1.Text = "Incorrect password or email";
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 3
0
        protected void btnSumbit_Click(object sender, EventArgs e)
        {
            DataTiers.passwordHash ph = new DataTiers.passwordHash(txtPassword.Text);

            DataTiers.userTier ut   = new DataTiers.userTier();
            DataModels.Users   user = new DataModels.Users();
            user.email    = txtEmail.Text;
            user.username = txtUsername.Text;
            user.salt     = ph.Salt;
            user.hash     = ph.Hash;
            user.major    = txtMajor.Text;


            try
            {
                if (ut.userExist(user) == false)
                {
                    ut.insertUser(user);
                    Response.Redirect("Success.aspx");
                }
                else
                {
                    // lblError.Text = "<strong>Warning: </strong>The username or email already exists";
                    CustomValidator1.ErrorMessage = "<strong>Warning: </strong>The username or email already exists";
                    CustomValidator1.IsValid      = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 4
0
        private void GetData()
        {
            DataModels.Users tempUser = (DataModels.Users)Session["user"];

            DataTable table = new DataTable();

            // get the connection
            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["MyData"].ToString()))
            {
                // write the sql statement to execute
                string query = "SELECT posts.PostID, posts.Title, posts.Condition, posts.Price FROM posts where posts.userID = '" + tempUser.userID + "'";
                // instantiate the command object to fire
                using (MySqlCommand cmd = new MySqlCommand(query, conn))
                {
                    // get the adapter object and attach the command object to it
                    using (MySqlDataAdapter ad = new MySqlDataAdapter(cmd))
                    {
                        // fire Fill method to fetch the data and fill into DataTable
                        ad.Fill(table);
                    }
                }
            }
            // specify the data source for the GridView
            GridView1.DataSource = table;
            // bind the data now
            GridView1.DataBind();
        }
Esempio n. 5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DataTiers.postTier    pt   = new DataTiers.postTier();
            DataModels.CreatePost post = (DataModels.CreatePost)Session["thePost"];


            DataModels.Users tempUser = (DataModels.Users)Session["user"];
            int id = tempUser.userID;


            try
            {
                pt.insertPost(post, id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Response.Redirect("createPost.aspx");
            }
            Session.Remove("thePost");
            Response.Redirect("Success.aspx");

            /*
             *      string query = "INSERT INTO posts (title, author, course, department) " +
             *         "VALUES ('" + lblTitle.Text + "','" + lblAuthor.Text + "','" + lblCoarse.Text + "','" + lblDepartment.Text + "');";
             *
             *      MySqlCommand cmd = new MySqlCommand(query,conn);
             *
             *      conn.Open();
             *      cmd.ExecuteNonQuery();
             *      conn.Close();
             */
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataModels.Users tempUser = (DataModels.Users)Session["user"];
            lblUsername.Text = tempUser.username;
            lblEmail.Text    = tempUser.email;
            lblMajor.Text    = tempUser.major;



            if (!IsPostBack)
            {
                GetData();
            }
        }
Esempio n. 7
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            DataModels.Users tempUser = (DataModels.Users)Session["user"];

            MySqlCommand cmd = new MySqlCommand("Update posts set posts.Condition = '" + e.NewValues[2] + "', Price = '" + float.Parse(e.NewValues[3].ToString()) + "' where posts.postID = '" + e.NewValues[0] + "'", conn);

            conn.Open();
            cmd.ExecuteNonQuery();

            GridView1.Rows[e.RowIndex].Cells[1].Visible = true;

            GridView1.EditIndex = -1;
            GetData();
            conn.Close();
        }