예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         int    i, j;
         string sn = "";
         mysql = "SELECT * FROM selcourse WHERE sno='" + Session["uno"] + "'";
         i     = mydb.Rownum(mysql, "selcourse", ref sn);
         mysql = "SELECT * FROM score WHERE sno='" + Session["uno"] + "'";
         j     = mydb.Rownum(mysql, "score", ref sn);
         if (i == 0 && j == 0)  //第一次选课:score和selcourse表中都没有该学号的记录
         {
             mysql = "INSERT INTO selcourse(sno,cno,cname,ctime,cplace,tno,tname,sel) SELECT '" +
                     Session["uno"] + "',cno,cname,ctime,cplace,tno,tname,'×' FROM course";
             mydb.ExecuteNonQuery(mysql);
             bind();
         }
         else if (i > 0)  //selcourse表中有该学号的记录
         {
             bind();
         }
         else
         {
             Response.Redirect("~/dispinfo.aspx?info=" + "你选课已提交,不能再重新选课");
         }
     }
 }
예제 #2
0
    public void delusertable(string tname)
    {
        CommDB mydb = new CommDB();
        string mysql;

        mysql = "DELETE " + tname;
        mydb.ExecuteNonQuery(mysql);
        mysql = "INSERT INTO Users(用户名,密码,类型,有效否) VALUES('system','manager','管理员','1')";
        mydb.ExecuteNonQuery(mysql);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mysql;
        CommDB mydb = new CommDB();

        mysql = "INSERT INTO score(sno,sname,cno,cname,degree,tno) " +
                "SELECT sno,'" + Session["uname"] + "',cno,cname,0,tno FROM selcourse" +
                " WHERE sno = '" + Session["uno"] + "' AND sel = '√'";
        mydb.ExecuteNonQuery(mysql);
        mysql = "DELETE FROM selcourse WHERE sno = '" + Session["uno"] + "'";
        mydb.ExecuteNonQuery(mysql);
        Server.Transfer("~/dispinfo.aspx?info=" + "你的选课已成功提交!");
    }
예제 #4
0
 protected void Update(string no, string fs)
 //自定义过程,用UPDATE语句修改分数
 {
     mysql = "UPDATE score SET degree=" + fs + " WHERE sno = '" +
             no + "' AND cno='" + DropDownList1.SelectedValue + "'";
     mydb.ExecuteNonQuery(mysql);
 }
예제 #5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            int i;
            mysql = "SELECT * FROM Customers WHERE 用户名 = '"
                    + usernameTextBox.Text.Trim() + "'";
            i = mydb.Rownum(mysql);
            if (i > 0)
            {
                Response.Write("<script>alert('对不起,你输入的用户名" + "已经注册了!')</script>");
            }
            else
            {
                string sf = "管理员";
                if (RadioButton2.Checked)
                {
                    sf = "操作员";
                }

                mysql = "INSERT INTO Users (用户名,密码,类型,有效否) "
                        + "VALUES('" + usernameTextBox.Text.Trim() + "','"
                        + passTextBox1.Text.Trim() + "','"
                        + sf + "','1')";
                mydb.ExecuteNonQuery(mysql);
                Response.Redirect("~/dispinfo.aspx?info=欢迎您,管理员!");
            }
        }
    }
예제 #6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    i;
        CommDB mydb = new CommDB();
        string mysql, sn = "";

        mysql = "SELECT * FROM teacher WHERE tno='" + TextBox1.Text + "'";
        i     = mydb.Rownum(mysql, "teacher", ref sn);
        if (i > 0)
        {
            Response.Redirect("~/dispinfo.aspx?info=编号重复,不能添加该教师记录!");
        }
        else
        {
            string xb;
            if (RadioButton1.Checked)
            {
                xb = "男";
            }
            else if (RadioButton2.Checked)
            {
                xb = "女";
            }
            else
            {
                xb = "";
            }
            mysql = "INSERT INTO teacher(tno,tname,tsex,tdepart,tpass) VALUES('" +
                    TextBox1.Text + "','" + TextBox2.Text + "','" + xb + "','" +
                    TextBox3.Text + "','" + TextBox1.Text + "')";
            //刚添加时密码同编号
            mydb.ExecuteNonQuery(mysql);
            Response.Redirect("~/dispinfo.aspx?info=教师记录已成功添加!");
        }
    }
예제 #7
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     mysql = "UPDATE manager SET mname = '" + TextBox2.Text +
             "' WHERE mno='" + TextBox1.Text + "'";
     mydb.ExecuteNonQuery(mysql);
     Response.Redirect("editmanager.aspx");
 }
예제 #8
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    i;
        CommDB mydb = new CommDB();
        string mysql, sn = "";

        mysql = "SELECT * FROM student WHERE sno='" + TextBox1.Text + "'";
        i     = mydb.Rownum(mysql, "student", ref sn);
        if (i > 0)
        {
            Response.Redirect("~/dispinfo.aspx?info=学号重复,不能添加该学生记录!");
        }
        else
        {
            string xb;
            if (RadioButton1.Checked)
            {
                xb = "男";
            }
            else if (RadioButton2.Checked)
            {
                xb = "女";
            }
            else
            {
                xb = "";
            }
            mysql = "INSERT INTO student(sno,sname,ssex,snation,sclass,spass) VALUES('" +
                    TextBox1.Text + "','" + TextBox2.Text + "','" + xb + "','" +
                    DropDownList1.SelectedValue + "','" + TextBox3.Text + "','" +
                    TextBox1.Text + "')";
            mydb.ExecuteNonQuery(mysql);;
            Response.Redirect("~/dispinfo.aspx?info=学生记录已成功添加!");
        }
    }
예제 #9
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         int i;
         mysql = "SELECT * FROM Customers WHERE 用户名 = '"
                 + usernameTextBox.Text.Trim() + "'";
         i = mydb.Rownum(mysql);
         if (i > 0)
         {
             Response.Write("<script>alert('对不起,你输入的用户名" + "已经注册了!')</script>");
         }
         else
         {
             mysql = "INSERT INTO Customers(用户名,密码,姓名,年龄,学历," + "地区,省份,市,县,住址,邮箱,电话,有效否)"
                     + "VALUES('" + usernameTextBox.Text.Trim() + "','"
                     + passTextBox1.Text.Trim() + "','"
                     + xmTextBox.Text.Trim() + "',"
                     + ageTextBox.Text + ",'"
                     + DropDownList1.SelectedValue.ToString().Trim() + "','"
                     + DropDownList2.SelectedValue.ToString().Trim() + "','"
                     + DropDownList3.SelectedValue.ToString().Trim() + "','"
                     + DropDownList4.SelectedValue.ToString().Trim() + "','"
                     + DropDownList5.SelectedValue.ToString().Trim() + "','"
                     + placeTextBox.Text.Trim() + "','"
                     + EmailTextBox.Text.Trim() + "','"
                     + TelTextBox.Text.Trim() + "','1'";
             mydb.ExecuteNonQuery(mysql);
             Response.Redirect("~/dispinofo.aspx?info=你可以退出再以顾客身份" + "登录后购物,或者继续以游客身份游览!");
         }
     }
 }
예제 #10
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     mysql = "UPDATE course SET cname = '" + TextBox2.Text +
             "',ctime ='" + TextBox3.Text + "',cplace='" + TextBox4.Text +
             "' WHERE cno='" + TextBox1.Text + "'";
     mydb.ExecuteNonQuery(mysql);
     Response.Redirect("editcourse.aspx");
 }
예제 #11
0
    public void deltable(string tname)
    {
        CommDB mydb = new CommDB();
        string mysql;

        mysql = "DELETE " + tname;
        mydb.ExecuteNonQuery(mysql);
    }
예제 #12
0
    protected void savedata()
    {
        string   spno;
        CheckBox xzBox;
        TextBox  slBox;
        Image    imgBox;

        int i;

        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            xzBox = GridView1.Rows[i].FindControl("CheckBox1") as CheckBox; //寻找CheckBox1控件
            slBox = GridView1.Rows[i].FindControl("TextBox1") as TextBox;   //寻找TextBox1控件
            if (xzBox.Checked)
            {
                spno   = GridView1.Rows[i].Cells[0].Text.Trim();        //获取商品编号
                imgBox = GridView1.Rows[i].FindControl("Image") as Image;
                if (inCart(spno))
                {
                    mysql = "UPDATE ShoppingCart SET 数量 = 数量 + "
                            + slBox.Text.Trim()
                            + "WHERE 用户名 = '" + Session["uname"]
                            + "'AND 商品编号 = '" + spno + "'";
                }
                else
                {
                    string f1 = GridView1.Rows[i].Cells[1].Text.Trim();
                    string f2 = GridView1.Rows[i].Cells[2].Text.Trim();
                    string f3 = GridView1.Rows[i].Cells[3].Text.Trim();
                    string f4 = GridView1.Rows[i].Cells[4].Text.Trim();
                    string f5 = GridView1.Rows[i].Cells[5].Text.Trim();
                    string f6 = imgBox.ImageUrl;
                    string f7 = slBox.Text.Trim();
                    mysql = "INSERT INTO ShoppingCart(用户名,商品编号,分类,子类,品牌,型号,单价,图片,数量) VALUES('" + Session["uname"] + "','"
                            + spno + "','" + f1 + "','" + f2 + "','"
                            + f3 + "','" + f4 + "','" + f5 + "','"
                            + f6 + "'," + f7 + ")";
                }
                mydb.ExecuteNonQuery(mysql);
                mysql = "UPDATE ShoppingCart SET 金额 = 数量 * 单价 "
                        + "WHERE 用户名 = '" + Session["uname"]
                        + "' AND 商品编号 = '" + spno + "'";
                mydb.ExecuteNonQuery(mysql);
            }
        }
    }
예제 #13
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string tno = GridView1.DataKeys[e.RowIndex].Value.ToString();
        string mysql;

        mysql = "DELETE FROM teacher WHERE tno='" + tno + "'";
        mydb.ExecuteNonQuery(mysql);
        bind();
    }
예제 #14
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        e.Cancel = true;
        string uname;

        uname = GridView1.DataKeys[e.RowIndex].Value.ToString();
        mysql = "DELETE FROM Users WHERE 用户名 = '" + uname + "'";
        mydb.ExecuteNonQuery(mysql);
        bind();
    }
예제 #15
0
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        string tno   = GridView1.DataKeys[e.NewEditIndex][0].ToString();
        string tname = GridView1.DataKeys[e.NewEditIndex][1].ToString();
        string cno   = Request.QueryString["cno"];

        mysql = "UPDATE course SET tno='" + tno + "',tname='" +
                tname + "' WHERE cno='" + cno + "'";
        mydb.ExecuteNonQuery(mysql);
        Response.Redirect("plancourse.aspx");
    }
예제 #16
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            String today = DateTime.Today.Year.ToString() + "/"
                           + DateTime.Today.Month.ToString() + "/"
                           + DateTime.Today.Day.ToString();

            id   = GridView1.SelectedDataKey.Values["ID"].ToString();
            date = Calendar1.SelectedDate.Year.ToString() + "/"
                   + Calendar1.SelectedDate.Month.ToString() + "/"
                   + Calendar1.SelectedDate.Day.ToString();
            String mysql = "INSERT INTO [airDB].[dbo].[book]([uid],[fid],[btime],[fdate]) VALUES("
                           + "'" + Session["uid"]
                           + "','" + id
                           + "','" + today
                           + "','" + date
                           + "')";

            if (mycmd.ExecuteNonQuery(mysql))
            {
                String mysql1 = "Select [umoney] FROM [airDB].[dbo].[user_] where uid = " + Session["uid"];
                string money  = "";
                if (mycmd.Rownum(mysql1, "umoney", ref money) > 0)
                {
                    int    price  = int.Parse(GridView1.SelectedDataKey.Values["价格"].ToString());
                    String mysql2 = "UPDATE user_ SET umoney = '" + (decimal.Parse(money) - price) + "' where uid = " + Session["uid"];
                    if (mycmd.ExecuteNonQuery(mysql2))
                    {
                        Response.Write("<script>alert('预定成功!');</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('预定失败!" + mysql + "');</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('预定失败!" + mysql + "');</script>");
            }
        }
예제 #17
0
    protected void savedata()
    {
        string  spno;
        TextBox slBox;
        Image   imgBox;
        int     sl;

        mysql = "DELETE FROM ShoppingCart WHERE 用户名 = '" + Session["uname"] + "'";
        mydb.ExecuteNonQuery(mysql);

        int i;

        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            slBox = GridView1.Rows[i].FindControl("TextBox1") as TextBox;  //寻找TextBox1控件
            sl    = int.Parse(slBox.Text.Trim());
            if (sl > 0)
            {
                spno   = GridView1.Rows[i].Cells[0].Text.Trim();        //获取商品编号
                imgBox = GridView1.Rows[i].FindControl("Image1") as Image;
                string f1 = GridView1.Rows[i].Cells[1].Text.Trim();
                string f2 = GridView1.Rows[i].Cells[2].Text.Trim();
                string f3 = GridView1.Rows[i].Cells[3].Text.Trim();
                string f4 = GridView1.Rows[i].Cells[4].Text.Trim();
                string f5 = GridView1.Rows[i].Cells[5].Text.Trim();
                string f6 = imgBox.ImageUrl;
                string f7 = slBox.Text.Trim();
                mysql = "INSERT INTO ShoppingCart(用户名,商品编号,分类,子类,品牌,型号,单价,图片,数量) VALUES('" + Session["uname"] + "','"
                        + spno + "','" + f1 + "','" + f2 + "','"
                        + f3 + "','" + f4 + "','" + f5 + "','"
                        + f6 + "'," + f7 + ")";
                mydb.ExecuteNonQuery(mysql);
                mysql = "UPDATE ShoppingCart SET 金额 = 数量 * 单价 "
                        + "WHERE 用户名 = '" + Session["uname"]
                        + "'AND 商品编号 = '" + spno + "'";
                mydb.ExecuteNonQuery(mysql);
            }
        }
    }
예제 #18
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         int i;
         mysql = "SELECT * FROM Products WHERE 商品编号 = '" + bhTextBox.Text + "'";
         i     = mydb.Rownum(mysql);
         if (i > 0)
         {
             Label1.Text = "商品编号重复,不能添加该商品记录!";
         }
         else
         {
             string filestr;
             if (FileUpload1.HasFile)
             {
                 filestr = Server.MapPath("/") + "Picture\\" + FileUpload1.FileName;
                 try
                 {
                     FileUpload1.SaveAs(filestr);
                     Label1.Text = "提示:文件成功上传";
                 }
                 catch (Exception ex)
                 {
                     Label1.Text = "提示:文件上传失败," + ex.Message;
                 }
             }
             else
             {
                 Label1.Text = "提示:没有指定要上传的任何文件";
             }
             mysql = "INSERT INTO Products(商品编号,分类,子类,品牌,型号,单价,库存数量,图片,有效否,星数,评论数) VALUES('"
                     + bhTextBox.Text.Trim() + "','"
                     + DropDownList1.SelectedValue.ToString().Trim() + "','"
                     + DropDownList2.SelectedValue.ToString().Trim() + "','"
                     + DropDownList3.SelectedValue.ToString().Trim() + "','"
                     + xhTextBox.Text.Trim() + "',"
                     + priceTextBox.Text.Trim() + ","
                     + numTextBox.Text.Trim() + ",'"
                     + "~//Pictrue//" + FileUpload1.FileName.Trim() + "','"
                     + "1',0,0)";
             mydb.ExecuteNonQuery(mysql);
             Response.Redirect("~/dispinfo.aspx?info=新型号的商品已添加");
         }
     }
     else
     {
         Label1.Text = "提示:商品信息错误,不能添加";
     }
 }
예제 #19
0
    protected void savedata()
    {
        CheckBox chBox;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            string f1 = GridView1.Rows[i].Cells[0].Text.Trim();
            chBox = GridView1.Rows[i].FindControl("CheckBox1") as CheckBox;
            bool b1 = chBox.Checked;

            mysql = "UPDATE OrderForm SET 结算否 =  '" + b1 + "'"
                    + "WHERE 用户名 = '" + f1 + "'";
            mydb.ExecuteNonQuery(mysql);
        }
    }
예제 #20
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (check())
     {
         Label1.Text = "原密码有误请重新输入";
     }
     else if (check2())
     {
         Label1.Text = "两次密码不一致请重新输入";
     }
     else
     {
         mysql = "UPDATE Users SET 密码 = '" + passTextBox2.Text.ToString()
                 + "' WHERE 用户名 = '" + Session["uname"] + "'";
         mydb.ExecuteNonQuery(mysql);
         Response.Redirect("~/dispinfo.aspx?info=更改密码成功!");
     }
 }
예제 #21
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         mysql = "UPDATE Customers SET 姓名 = '" + xmTextBox.Text.Trim() + "',"
                 + "年龄 = " + ageTextBox.Text + "," + "学历 = '" + DropDownList1.SelectedValue.ToString().Trim() + "',"
                 + "地区 = '" + DropDownList2.SelectedValue.ToString().Trim() + "',"
                 + "省份 = '" + DropDownList3.SelectedValue.ToString().Trim() + "',"
                 + "市 = '" + DropDownList4.SelectedValue.ToString().Trim() + "',"
                 + "县 = '" + DropDownList5.SelectedValue.ToString().Trim() + "',"
                 + "住址 = '" + placeTextBox.Text.Trim() + "',"
                 + "邮箱 = '" + EmailTextBox.Text.Trim() + "',"
                 + "电话 = '" + TelTextBox.Text.Trim() + "', 有效否 =  '1'"
                 + " WHERE 用户名 = '" + Session["uname"] + "'";
         mydb.ExecuteNonQuery(mysql);
         Response.Redirect("~/dispinfo.aspx?info=更改信息成功!");
     }
 }
예제 #22
0
        protected void submit_Click(object sender, EventArgs e)
        {
            String mysql = "UPDATE [airDB].[dbo].[user_] SET [uname] = '" + name.Text
                           + "',[uloginname] = '" + username.Text
                           + "',[utel] = '" + tel.Text
                           + "', [umoney] = '" + money.Text
                           + "', [upass] = '" + password.Text
                           + "' WHERE [uid] = '" + uid.Value + "'";

            if (mycom.ExecuteNonQuery(mysql))
            {
                Response.Write("<script>alert('保存成功!" + mysql + "');</script>");
            }
            else
            {
                Response.Write("<script>alert('保存失败!" + mysql + "');</script>");
            }
        }
예제 #23
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        CommDB mydb = new CommDB();
        string mysql, sn = "";
        int    i;

        mysql = "SELECT * FROM student WHERE sno='" + Session["uno"] + "' AND spass='******'";
        i     = mydb.Rownum(mysql, "student", ref sn);
        if (i == 0)
        {
            Server.Transfer("~/dispinfo.aspx?info=原密码输入错误!");
        }
        else
        {
            mysql = "UPDATE student SET spass='******' WHERE sno='" + Session["uno"] + "'";
            mydb.ExecuteNonQuery(mysql);
            Server.Transfer("~/dispinfo.aspx?info=密码修改成功!");
        }
    }
예제 #24
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    i;
        CommDB mydb = new CommDB();
        string mysql, sn = "";

        mysql = "SELECT * FROM manager WHERE mno='" + TextBox1.Text + "'";
        i     = mydb.Rownum(mysql, "manager", ref sn);
        if (i > 0)
        {
            Response.Redirect("~/dispinfo.aspx?info=管理员编程号重复,不能添加该课程记录!");
        }
        else
        {
            mysql = "INSERT INTO manager(mno,mname,mpass) VALUES('" +
                    TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox1.Text + "')";
            mydb.ExecuteNonQuery(mysql);
            Response.Redirect("~/dispinfo.aspx?info=管理员记录已成功添加!");
        }
    }
예제 #25
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int    i;
        CommDB mydb = new CommDB();
        string mysql, sn = "";

        mysql = "SELECT * FROM course WHERE cno='" + TextBox1.Text + "'";
        i     = mydb.Rownum(mysql, "course", ref sn);
        if (i > 0)
        {
            Response.Redirect("~/dispinfo.aspx?info=课程号重复,不能添加该课程记录!");
        }
        else
        {
            mysql = "INSERT INTO course(cno,cname,ctime,cplace,tno,tname) VALUES('" +
                    TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" +
                    TextBox4.Text + "','','')";
            mydb.ExecuteNonQuery(mysql);;
            Response.Redirect("~/dispinfo.aspx?info=课程记录已成功添加!");
        }
    }
예제 #26
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string xb;

        if (RadioButton1.Checked)
        {
            xb = "男";
        }
        else if (RadioButton2.Checked)
        {
            xb = "女";
        }
        else
        {
            xb = "";
        }
        mysql = "UPDATE teacher SET tname = '" + TextBox2.Text +
                "',tsex ='" + xb + "',tdepart='" + TextBox3.Text +
                "' WHERE tno='" + TextBox1.Text + "'";
        mydb.ExecuteNonQuery(mysql);
        Response.Redirect("editteacher.aspx");
    }
예제 #27
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string xb;

        if (RadioButton1.Checked)
        {
            xb = "男";
        }
        else if (RadioButton2.Checked)
        {
            xb = "女";
        }
        else
        {
            xb = "";
        }
        mysql = "UPDATE student SET sname = '" + TextBox2.Text + "',ssex ='" + xb +
                "',snation='" + DropDownList1.SelectedValue + "',sclass = '" +
                TextBox3.Text + "' WHERE sno='" + TextBox1.Text + "'";
        mydb.ExecuteNonQuery(mysql);
        Response.Redirect("editstudent1.aspx");
    }
예제 #28
0
 protected void Unnamed1_Click(object sender, EventArgs e)
 {
     if (GridView1.SelectedDataKey == null)
     {
         Response.Write("<script>alert('请选择退票航班');</script>");
     }
     else
     {
         String today = DateTime.Today.Year.ToString() + "/"
                        + DateTime.Today.Month.ToString() + "/"
                        + DateTime.Today.Day.ToString();
         //String mysql = "DELETE * FROM book where bid = '"+GridView1.SelectedDataKey.Values["ID"].ToString()+"'";
         String mysql = "INSERT INTO [airDB].[dbo].[rebook](bid,rtime) VALUES('" + GridView1.SelectedDataKey.Values["ID"].ToString() + "','" + today + "')";
         if (mycmd.ExecuteNonQuery(mysql))
         {
             Response.Write("<script>alert('退票成功!');</script>");
             Response.Redirect("~/User/returnTicket.aspx", false);
         }
         else
         {
             Response.Write("<script>alert('退票失败!" + mysql + "');</script>");
         }
     }
 }
예제 #29
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        int i;
        int zsl = 0;
        int zjr = 0;

        //更新Products表的数量
        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            string spno  = GridView1.Rows[i].Cells[0].Text.Trim();           //商品编号
            string gwsl  = GridView1.Rows[i].Cells[7].Text.Trim();           //购物数量
            string money = GridView1.Rows[i].Cells[8].Text.Trim();
            Label1.Text = "数量" + gwsl;
            mysql       = "UPDATE Products SET 库存数量 = 库存数量 - " + gwsl
                          + "WHERE 商品编号 = '" + spno + "'";
            mydb.ExecuteNonQuery(mysql);

            zsl += int.Parse(gwsl);
            zjr += int.Parse(money);
        }
        Session["zsl"] = zsl;
        Session["zjr"] = zjr;
        //求订单编号
        mysql = "SELECT COUNT( * ) FROM (SELECT distinct 订单号 FROM Sales) tmp";
        string dds  = mydb.ExecuteAggregateQuery(mysql);                    //求订单数
        string ndds = (int.Parse(dds) + 1).ToString();                      //新订单编号

        Session["ndds"] = ndds;
        //将订单的顾客信息插入OrderForm(顾客信息)表
        string name, dq, sf, cs, xm, dz, yx, th;

        mysql = "SELECT 姓名,地区,省份,市,县,住址,邮箱,电话 FROM Customers " +
                "WHERE 用户名 = '" + Session["uname"] + "'";
        myds = mydb.ExecuteQuery(mysql, "Customers");
        DataRow mydr = myds.Tables["Customers"].Rows[0];//获取查询结果第一行

        name             = mydr["姓名"].ToString().Trim();
        dq               = mydr["地区"].ToString().Trim();
        sf               = mydr["省份"].ToString().Trim();
        cs               = mydr["市"].ToString().Trim();
        xm               = mydr["县"].ToString().Trim();
        dz               = mydr["住址"].ToString().Trim();
        yx               = mydr["邮箱"].ToString().Trim();
        th               = mydr["电话"].ToString().Trim();
        Session["name"]  = name;                       //收件人姓名
        Session["sjrdz"] = sf + cs + xm + dz;          //收件人地址
        Session["th"]    = th;
        mysql            = "INSERT INTO OrderForm(订单号,日期,用户名,姓名,地区,省份,市,县,住址,邮箱,电话,总数量,总金额,处理否,结算否) VALUES("
                           + ndds + ",'" + DateTime.Now + "','" + Session["uname"] + "','"
                           + name + "','" + dq + "','" + sf + "','" + cs + "','"
                           + xm + "','" + dz + "','" + yx + "','" + th + "',"
                           + Session["zsl"] + "," + Session["zjr"] + ",0,0)";
        Label1.Text = mysql;
        mydb.ExecuteNonQuery(mysql);
        //将购物车全部信息移动到Sales中
        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            mysql = "INSERT INTO Sales(订单号,日期,用户名,商品编号,分类,子类,品牌,型号,单价,数量,金额) "
                    + "VALUES ( " + ndds + ",'"
                    + DateTime.Now + "','"
                    + Session["uname"] + "','"
                    + GridView1.Rows[i].Cells[0].Text.Trim() + "','"
                    + GridView1.Rows[i].Cells[1].Text.Trim() + "','"
                    + GridView1.Rows[i].Cells[2].Text.Trim() + "','"
                    + GridView1.Rows[i].Cells[3].Text.Trim() + "','"
                    + GridView1.Rows[i].Cells[4].Text.Trim() + "',"
                    + GridView1.Rows[i].Cells[5].Text.Trim() + ","
                    + GridView1.Rows[i].Cells[7].Text.Trim() + ","
                    + GridView1.Rows[i].Cells[8].Text.Trim() + ")";
            mydb.ExecuteNonQuery(mysql);
        }
        mysql = "DELETE ShoppingCart  WHERE 用户名 = '" + Session["uname"] + "'";
        mydb.ExecuteNonQuery(mysql);
        Response.Redirect("Orderform.aspx");
    }
예제 #30
0
 public void Update(string spno, string dj, string addkc)
 {
     mysql = "UPDATE Products SET 单价= " + dj + ",库存数量 = 库存数量 + " + addkc + " WHERE 商品编号 = '" + spno + "'";
     mydb.ExecuteNonQuery(mysql);
 }