コード例 #1
0
        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            flowerShop db = new flowerShop();

            if (e.CommandName == "updateNum")
            {
                string P_str_CartID = Session["UserName"].ToString();
                string P_str_Num    = ((TextBox)e.Item.FindControl("txtBookNum")).Text;
                int    n            = db.ExCmd("update Cart1 set count=" + P_str_Num + " where fid =" + e.CommandArgument + " and CartId=" + P_str_CartID);
                if (n > 0)
                {
                    Bind(P_str_CartID);
                }
            }
            else if (e.CommandName == "DeleteItem")
            {
                string P_str_CartID  = Session["UserName"].ToString();
                string delete_string = "delete Cart1 where fid =" + e.CommandArgument + " and CartId=" + P_str_CartID;
                int    n             = db.ExCmd(delete_string);
                if (n > 0)
                {
                    Bind(P_str_CartID);
                }
            }
        }
コード例 #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            string     P_str_CartID = Session["UserName"].ToString();
            flowerShop db           = new flowerShop();
            int        n            = db.ExCmd("delete from Cart1 where CartId=" + Session["UserName"]);

            if (n < 0)
            {
                Response.Write("<soript>清空失败,请重试!</soript>");
            }
            else
            {
                Bind(P_str_CartID);
            }
        }
コード例 #3
0
        protected void DataList1_lnkbtnDelete(object source, DataListCommandEventArgs e)
        {
            string     P_str_CartID = Session["UserName"].ToString();
            flowerShop db           = new flowerShop();
            int        n            = db.ExCmd("delete from Cart1 where CartId='" + Session["UserID"] + "' and fid='" + e.CommandArgument.ToString() + "''");

            if (n < 0)
            {
                Response.Write("<script> 删除失败,请重试!</ script >");
            }
            else
            {
                Bind(P_str_CartID);
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label11.Text = "Whelcom:" + Session["UserName"] + Session["AdminName"];


            if (Session["UserName"] == null)
            {
                Response.Redirect("/login.aspx");
            }
            else
            {
                //Response.Redirect("/login.aspx");
            }
            if (!Page.IsPostBack)
            {
                string P_str_CartID = Session["UserName"].ToString();
                string P_str_fID    = Request.QueryString["id"];
                if (P_str_fID == null)
                {
                    Bind(P_str_CartID);
                    return;
                }

                DataSet    ds = flowerShop.ReDs("select count(*) from Cart1 where fid=" + P_str_fID + " and CartId=" + P_str_CartID);
                flowerShop db = new flowerShop();
                if (ds.Tables[0].Rows[0][0].ToString() == "0")
                {
                    DataSet ds1         = flowerShop.ReDs("select fname,price from flower where fid=" + P_str_fID);
                    DataSet ds2         = flowerShop.ReDs("select uid from UserInfo where uid=" + P_str_CartID);
                    string  P_str_fName = ds1.Tables[0].Rows[0][0].ToString();
                    string  P_str_Price = ds1.Tables[0].Rows[0][1].ToString();
                    string  UserName    = ds2.Tables[0].Rows[0][0].ToString();
                    string  p_str_Num   = Session["cot"].ToString();
                    string  n           = Session["UserName"].ToString();
                    string  da          = DateTime.Now.ToString("yyyy-mm-dd");
                    string  str         = "Insert into Cart1 (CartID,fid,fname,price,count,name,date) values('" + P_str_CartID + "','" + P_str_fID + "','" + P_str_fName + "','" + P_str_Price + "','" + p_str_Num + "','" + n + "','" + da + "')";
                    db.ExCmd(str);
                }
                else
                {
                    db.ExCmd("update flower set sort=" + P_str_CartID + " where  fid=" + P_str_fID);
                    db.ExCmd("update Cart1 set count=count+1 where  fid=" + P_str_fID);//uid=" + P_str_CartID + " and
                }

                Bind(P_str_CartID);
            }
        }