⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changeform.aspx.cs

📁 C# + MYSQL 课程设计 ASP.NET 2.0数据库开发《餐饮消费管理系统》功能完整
💻 CS
字号:
//文件名:ChangeForm.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;
public partial class EatingManage_ChangeForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("B4") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        this.Button1.OnClientClick = "return confirm('是否确认更换选择的台位和客人信息?')";
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {//在GridView控件单元格中设置短日期显示格式
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime MyDate = DateTime.Parse(e.Row.Cells[4].Text);
            e.Row.Cells[4].Text = MyDate.ToShortDateString();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//确认换台
        int MyDiff = Convert.ToInt16(this.GridView1.SelectedRow.Cells[3].Text.ToString()) - Convert.ToInt16(this.GridView2.SelectedRow.Cells[2].Text.ToString());
        if (MyDiff>0)
        {
            return;
        }
        string My用餐单号 = this.GridView1.SelectedRow.Cells[1].Text.ToString();        
        string My原台位 = this.GridView1.SelectedRow.Cells[2].Text.ToString();
        string My新台位 = this.GridView2.SelectedRow.Cells[1].Text.ToString();
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        string MySQL = "Update 用餐信息 Set 入座台位='" + My新台位 + "' WHERE 用餐单号='" + My用餐单号 + "';";
        MySQL += "Update 台位信息 Set 当前状态='空置' WHERE 台位编号='" + My原台位 + "';";
        MySQL += "Update 台位信息 Set 当前状态='在用' WHERE 台位编号='" + My新台位 + "';";
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
        this.SqlDataSource1.DataBind();
        this.SqlDataSource2.DataBind();
        this.GridView1.DataBind();
        this.GridView2.DataBind();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -