예제 #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");
            }
        }
예제 #2
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();
             */
        }