protected void Page_Load(object sender, System.EventArgs e)
        {


            if (!IsPostBack)
            {
                if (Request.QueryString["did"] != null)
                {
                    string Pid = Request.QueryString["did"].ToString();

                    string sql = "delete from  [tblBasket] where id=" + Pid;

                    DBConn myDB = new DBConn();

                    myDB.ExecuteNonQuery(sql);
                    myDB.Close();
                }

                if (Session["User"] != null)
                {
                    txtName.Enabled = false;
                    txtName.Text = (string)Session["User"];
                    DBConn db1 = new DBConn();
                    TextBox1.Text = db1.LookUp("select 真实姓名 from tblUser  where UserName='******'", "真实姓名");
                    lblTotalPric.Text = db1.LookUp("select sum(ismoney) as '1' from viwBasket  where tblUser='******'", "1");
                }
                else
                {

                    Response.Write("<script>alert('未登陆禁止订购');window.close();</script>");
                    Response.End();
                    return;
                }

                getData();

                string DBPath = ConfigurationSettings.AppSettings["DataBasePath"];
                string connStr = (DBPath);
                SqlConnection con = new SqlConnection(connStr);
       
                con.Open();
               string  sql1 = "select * from tblMode";
                SqlDataAdapter sda1 = new SqlDataAdapter(sql1, con);

                DataSet ds1 = new DataSet();
                sda1.Fill(ds1, "tblMode");

                foreach (DataRow row in ds1.Tables[0].Rows)
                {
                    this.dplBm.Items.Add(row["名称"].ToString());
                }

            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["did"] != null)
                {
                    string Pid = Request.QueryString["did"].ToString();

                    string sql = "delete from  [tblBasket] where id=" + Pid;

                    DBConn myDB = new DBConn();

                    myDB.ExecuteNonQuery(sql);
                    myDB.Close();
                }

                if (Session["User"] != null)
                {
                    txtName.Enabled = false;
                    txtName.Text    = (string)Session["User"];
                    DBConn db1 = new DBConn();
                    TextBox1.Text     = db1.LookUp("select 真实姓名 from tblUser  where UserName='******'", "真实姓名");
                    lblTotalPric.Text = db1.LookUp("select sum(ismoney) as '1' from viwBasket  where tblUser='******'", "1");
                }
                else
                {
                    Response.Write("<script>alert('未登陆禁止订购');window.close();</script>");
                    Response.End();
                    return;
                }

                getData();

                string        DBPath  = ConfigurationSettings.AppSettings["DataBasePath"];
                string        connStr = (DBPath);
                SqlConnection con     = new SqlConnection(connStr);

                con.Open();
                string         sql1 = "select * from tblMode";
                SqlDataAdapter sda1 = new SqlDataAdapter(sql1, con);

                DataSet ds1 = new DataSet();
                sda1.Fill(ds1, "tblMode");

                foreach (DataRow row in ds1.Tables[0].Rows)
                {
                    this.dplBm.Items.Add(row["名称"].ToString());
                }
            }
        }
Beispiel #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                string Pid     = Request.QueryString["id"].ToString();
                string tblUser = (String)Session["User"];
                DBConn myDB    = new DBConn();

                if (myDB.LookUp("select id from tblFav  where tblUser='******' and Pid=" + Pid, "id") != "")

                {
                    Response.Write("<script>alert('您已经收藏该产品了 ~');</script>");
                    myDB.Close();

                    return;
                }
                string sql = "insert into [tblFav](tblUser,Pid) values ( '" + tblUser + "', '" + Pid + "')";


                myDB.ExecuteNonQuery(sql);
                myDB.Close();

                Response.Write("<script>alert('收藏成功 ~');</script>");
            }
            else
            {
                Response.Write("<script>alert('未登陆无法收藏~');</script>");
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {

                if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != String.Empty)
                {
                    if (Session["User"] != null)
                    {
                        txtName.Enabled = false;
                        txtName.Text = (string)Session["User"];
                        DBConn db1 = new DBConn();
                     TextBox1.Text = db1.LookUp("select 真实姓名 from tblUser  where UserName='******'", "真实姓名")  ;
             
                    }
                    else
                    {

                        Response.Write("<script>alert('未登陆禁止订购');window.close();</script>");
                        Response.End();
                        return;
                    }
                    string strID = Request.QueryString["id"].ToString();
                    strID = CleanString.htmlInputText(strID);
                    ViewState["ID"] = strID;

                    PData();
                    string DBPath = ConfigurationSettings.AppSettings["DataBasePath"];
                    string connStr = (DBPath);

                    SqlConnection con = new SqlConnection(connStr);
                    con.Open();
                    string sql = "select * from tblMode";
                    SqlDataAdapter sda1 = new SqlDataAdapter(sql, con);

                    DataSet ds1 = new DataSet();
                    sda1.Fill(ds1, "tblMode");

                    foreach (DataRow row in ds1.Tables[0].Rows)
                    {
                        this.dplBm.Items.Add(row["名称"].ToString());
                    }


                }
                else
                {
                    Response.Write("<script>");
                    Response.Write("alert('没有这个二手书!!!');");
                    Response.Write("</script>");
                    Response.Redirect("index.aspx");
                    return;
                }
                double dblNum = Int32.Parse(DropDownList1.SelectedValue) * double.Parse(lblPNPrice.Text);
                lblCount.Text = dblNum.ToString("f2");
            }

        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null && Request.QueryString["id"].ToString() != String.Empty)
                {
                    if (Session["User"] != null)
                    {
                        txtName.Enabled = false;
                        txtName.Text    = (string)Session["User"];
                        DBConn db1 = new DBConn();
                        TextBox1.Text = db1.LookUp("select 真实姓名 from tblUser  where UserName='******'", "真实姓名");
                    }
                    else
                    {
                        Response.Write("<script>alert('未登陆禁止订购');window.close();</script>");
                        Response.End();
                        return;
                    }
                    string strID = Request.QueryString["id"].ToString();
                    strID           = CleanString.htmlInputText(strID);
                    ViewState["ID"] = strID;

                    PData();
                    string DBPath  = ConfigurationSettings.AppSettings["DataBasePath"];
                    string connStr = (DBPath);

                    SqlConnection con = new SqlConnection(connStr);
                    con.Open();
                    string         sql  = "select * from tblMode";
                    SqlDataAdapter sda1 = new SqlDataAdapter(sql, con);

                    DataSet ds1 = new DataSet();
                    sda1.Fill(ds1, "tblMode");

                    foreach (DataRow row in ds1.Tables[0].Rows)
                    {
                        this.dplBm.Items.Add(row["名称"].ToString());
                    }
                }
                else
                {
                    Response.Write("<script>");
                    Response.Write("alert('没有这个二手书!!!');");
                    Response.Write("</script>");
                    Response.Redirect("index.aspx");
                    return;
                }
                double dblNum = Int32.Parse(DropDownList1.SelectedValue) * double.Parse(lblPNPrice.Text);
                lblCount.Text = dblNum.ToString("f2");
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["myOrder"] == null)
                {
                    Response.Redirect("index.aspx");
                    return;
                }

                //返回操作
                if (Request.QueryString["key"] == null || Request.QueryString["key"].ToString() == String.Empty)
                {
                    Response.Redirect("index.aspx");
                    return;
                }
                string strBack = Request.QueryString["key"].ToString();
                strBack      = Server.UrlDecode(strBack);
                lblBack.Text = "<a href='index.aspx'>返回</a>";

                Order  myOrder       = (Order)Session["myOrder"];
                string strOID        = myOrder.OID;
                string strPID        = myOrder.PID;
                string strPName      = myOrder.PName;
                string strPNum       = myOrder.PNum;
                string strPPrice     = myOrder.PPrice;
                string strTotalPrice = myOrder.TotalPrice;
                string strTName      = myOrder.TName;
                string strEmail      = myOrder.Email;
                string strPhone      = myOrder.Phone;
                string strPCPrice    = myOrder.PCPrice;//成本


                strOID = getNewOrderID(); //订单号
                string sql  = "";
                DBConn myDB = new DBConn();


                if (strPID == "0")
                {
                    //没有ID 为批量购物的订单
                    //清空购物车,添加批量记录
                    strPName  = "批量购买产品,请查看详情";
                    strPNum   = "0";
                    strPPrice = "0";

                    sql = "select * from [viwBasket] where tblUser='******'order by ID desc";

                    DataSet ds1 = myDB.getDataSet(sql);


                    foreach (DataRow row in ds1.Tables[0].Rows)
                    {
                        string sql1 = "";
                        string tblUser, Pid, isN, isMoney, OrderNo;
                        tblUser = row["tblUser"].ToString();
                        isN     = row["isN"].ToString();
                        isMoney = row["isMoney"].ToString();
                        OrderNo = strOID;
                        Pid     = row["Pid"].ToString();

                        sql1 = "Insert into tblP_Order(tblUser,Pid,isN,isMoney,OrderNo) values ( '" +
                               tblUser + "', '" + Pid + "', '" + isN + "', " + isMoney + ", '" + OrderNo + "')";
                        myDB.ExecuteNonQuery(sql1);

                        myDB.ExecuteNonQuery("Update Products Set PStock = PStock - " + isN + ",PSellNum = PSellNum + " + isN + " WHERE PID = " + Pid);
                    }

                    sql = "delete from [tblBasket] where tblUser='******'";
                    myDB.ExecuteNonQuery(sql);//删除购物车


                    sql = "insert into [Order](OID,PID,PName,PNum,PPrice,TotalPrice,Pubdate,TName,Email,Phone,PCPrice) values('" +
                          strOID + "'," + strPID + ",'" + strPName + "'," + strPNum + "," + strPPrice + "," + strTotalPrice + ",'" +
                          DateTime.Now + "','" + strTName + "','" + strEmail + "','" + strPhone + "',0)";
                }
                else
                {
                    sql = "insert into [Order](OID,PID,PName,PNum,PPrice,TotalPrice,Pubdate,TName,Email,Phone,PCPrice) values('" +
                          strOID + "'," + strPID + ",'" + strPName + "'," + strPNum + "," + strPPrice + "," + strTotalPrice + ",'" +
                          DateTime.Now + "','" + strTName + "','" + strEmail + "','" + strPhone + "'," + strPCPrice + ")";

                    myDB.ExecuteNonQuery("Update Products Set PStock = PStock - " + strPNum + ",PSellNum = PSellNum + " + strPNum + " WHERE PID = " + strPID);
                }


                myDB.ExecuteNonQuery(sql);


                myOrder.OID        = strOID;
                Session["myOrder"] = myOrder;

                if (strPID == "0")
                {
                    lblDetailP.Text = "<a href='P_OderInfo.aspx?id=" + strOID + "' target='_blank'>查看批量购买的产品详情</a>";
                }

                lblOrderID.Text    = strOID;
                lblPName.Text      = strPName;
                lblPNum.Text       = strPNum;
                lblPPrice.Text     = strPPrice;
                lblTotalPrice.Text = strTotalPrice;
                lblTName.Text      = strTName;
                lblEmail.Text      = strEmail;
                lblPhone.Text      = strPhone;
                Label1.Text        = myDB.LookUp("select * from tbluser where UserName='******'", "真实姓名");

                myDB.Close();
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
         if (Session["User"] != null)
            {
                string Pid = Request.QueryString["id"].ToString();
                string tblUser = (String)Session["User"];
                DBConn myDB = new DBConn();

                if (myDB.LookUp("select id from tblFav  where tblUser='******' and Pid=" + Pid, "id") != "")
                 
              {    Response.Write("<script>alert('您已经收藏该产品了 ~');</script>");
              myDB.Close();

                  return;
              }
                string sql = "insert into [tblFav](tblUser,Pid) values ( '" + tblUser + "', '" + Pid + "')";

             
                myDB.ExecuteNonQuery(sql);
                myDB.Close();

                Response.Write("<script>alert('收藏成功 ~');</script>");
            }
            else
            {
                Response.Write("<script>alert('未登陆无法收藏~');</script>");
            }




        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["myOrder"] == null)
                {
                    Response.Redirect("index.aspx");
                    return;
                }

                //返回操作
                if (Request.QueryString["key"] == null || Request.QueryString["key"].ToString() == String.Empty)
                {
                    Response.Redirect("index.aspx");
                    return;
                }
                string strBack = Request.QueryString["key"].ToString();
                strBack = Server.UrlDecode(strBack);
                lblBack.Text = "<a href='index.aspx'>返回</a>";

                Order myOrder = (Order)Session["myOrder"];
                string strOID = myOrder.OID;
                string strPID = myOrder.PID;
                string strPName = myOrder.PName;
                string strPNum = myOrder.PNum;
                string strPPrice = myOrder.PPrice;
                string strTotalPrice = myOrder.TotalPrice;
                string strTName = myOrder.TName;
                string strEmail = myOrder.Email;
                string strPhone = myOrder.Phone;
                string strPCPrice = myOrder.PCPrice;//成本


                strOID = getNewOrderID(); //订单号
                string sql = "";
                DBConn myDB = new DBConn();

              
                    if (strPID == "0")
                    {
                        //没有ID 为批量购物的订单
                        //清空购物车,添加批量记录
                        strPName = "批量购买产品,请查看详情";
                        strPNum = "0";
                        strPPrice = "0";

                        sql = "select * from [viwBasket] where tblUser='******'order by ID desc";

                        DataSet ds1 = myDB.getDataSet(sql);


                        foreach (DataRow row in ds1.Tables[0].Rows)
                        {
                            string sql1 = "";
                            string tblUser, Pid, isN, isMoney, OrderNo;
                            tblUser = row["tblUser"].ToString();
                            isN = row["isN"].ToString();
                            isMoney = row["isMoney"].ToString();
                            OrderNo = strOID;
                            Pid = row["Pid"].ToString();

                            sql1 = "Insert into tblP_Order(tblUser,Pid,isN,isMoney,OrderNo) values ( '" +
                                tblUser + "', '" + Pid + "', '" + isN + "', " + isMoney + ", '" + OrderNo + "')";
                            myDB.ExecuteNonQuery(sql1);


                        }

                        sql = "delete from [tblBasket] where tblUser='******'";
                       myDB.ExecuteNonQuery(sql);//删除购物车
                        

                        sql = "insert into [Order](OID,PID,PName,PNum,PPrice,TotalPrice,Pubdate,TName,Email,Phone,PCPrice) values('" +
                         strOID + "'," + strPID + ",'" + strPName + "'," + strPNum + "," + strPPrice + "," + strTotalPrice + ",'" +
                         DateTime.Now + "','" + strTName + "','" + strEmail + "','" + strPhone + "',0)";
                    

                    }
                    else
                    {
                        sql = "insert into [Order](OID,PID,PName,PNum,PPrice,TotalPrice,Pubdate,TName,Email,Phone,PCPrice) values('" +
                              strOID + "'," + strPID + ",'" + strPName + "'," + strPNum + "," + strPPrice + "," + strTotalPrice + ",'" +
                              DateTime.Now + "','" + strTName + "','" + strEmail + "','" + strPhone + "'," + strPCPrice + ")";


                    }

                    myDB.ExecuteNonQuery(sql);
                  

                    myOrder.OID = strOID;
                    Session["myOrder"] = myOrder;

                    if (strPID == "0") lblDetailP.Text = "<a href='P_OderInfo.aspx?id=" + strOID + "' target='_blank'>查看批量购买的产品详情</a>";

                lblOrderID.Text = strOID;
                lblPName.Text = strPName;
                lblPNum.Text = strPNum;
                lblPPrice.Text = strPPrice;
                lblTotalPrice.Text = strTotalPrice;
                lblTName.Text = strTName;
                lblEmail.Text = strEmail;
                lblPhone.Text = strPhone;
                Label1.Text = myDB.LookUp("select * from tbluser where UserName='******'", "真实姓名");

                      myDB.Close();
            }
        }