Пример #1
0
    //获取数据(ab为页面获取的页码)
    public void getdata(int pagenum)
    {
        Database data = new Database();
        DataSet  dsu_s, dsb;

        dsu_s = data.query("select bno from U_S WHERE uid = '" + id + "'");
        //dso = data.query("select ono, seller, buyer, bno from OrderRelationship WHERE seller = '" + id + "'");

        // 取得总页数
        int a = dsu_s.Tables["base"].Rows.Count % 4;

        if (a > 0)
        {
            pagecount = dsu_s.Tables["base"].Rows.Count / 4 + 1;
        }
        else
        {
            pagecount = dsu_s.Tables["base"].Rows.Count / 4;
        }
        //将页面传递的页码赋给pagecurrent
        if (pagenum > 0 && pagenum <= pagecount)
        {
            pagecurrent = pagenum;
        }
        int num = 0;

        for (int i = ((pagecurrent - 1) * 4); i < dsu_s.Tables["base"].Rows.Count; i++)
        {
            if (num >= 4)
            {
                break;
            }

            bo[num]         = new bookorder();
            bo[num].bno     = dsu_s.Tables["base"].Rows[i]["bno"].ToString();
            bo[num].seller  = id.ToString();
            dsb             = data.query("select bname, btime, bprice, bpicture from Stack WHERE bno = '" + Convert.ToInt32(bo[num].bno) + "'");
            bo[num].name    = dsb.Tables["base"].Rows[0]["bname"].ToString();
            bo[num].time    = dsb.Tables["base"].Rows[0]["btime"].ToString();
            bo[num].price   = dsb.Tables["base"].Rows[0]["bprice"].ToString();
            bo[num].picture = dsb.Tables["base"].Rows[0]["bpicture"].ToString();
            dsb.Clear();
            num++;
        }
        dsu_s.Clear();
    }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (booksDataContext data = new booksDataContext())
                {
                    // this was used to add the details to the order table on the database
                    order NewOrder = new order();
                    NewOrder.orderaddress1 = TextBoxOrderAddress1.Text;
                    NewOrder.orderaddress2 = TextBoxOrderAddress2.Text;
                    NewOrder.ordertown     = TextBoxOrderTown.Text;
                    NewOrder.countyid      = Convert.ToInt32(DropDownList1.SelectedValue);
                    NewOrder.orderpostcode = TextBoxOrderPostCode.Text;

                    NewOrder.orderpaid = false;
                    NewOrder.ordersent = false;

                    NewOrder.username  = Page.User.Identity.Name;
                    NewOrder.orderdate = DateTime.Now;

                    data.orders.InsertOnSubmit(NewOrder);
                    data.SubmitChanges();

                    //this links to the basket in the cart session from the values still stored in the cart session

                    List <int> books = (List <int>)Session["Cart"];
                    foreach (int bookid in books)
                    {
                        bookorder newbookorder = new bookorder();
                        newbookorder.orderid = newbookorder.orderid;
                        newbookorder.bookid  = bookid;
                        data.bookorders.InsertOnSubmit(newbookorder);
                    }
                    data.SubmitChanges();
                }
            }
            catch (Exception)
            {
                Response.Redirect("~/error.aspx");
            }
            //to send the user to the order entered on the database page to imnform that it was entered and no errors occured
            Response.Redirect("~/Payments/ordersucess.aspx");
        }