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

📄 bookingeatform.aspx.cs

📁 C# + MYSQL 课程设计 ASP.NET 2.0数据库开发《餐饮消费管理系统》功能完整
💻 CS
字号:
//文件名:BookingEatForm.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 BookingManage_BookingEatForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("C2") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
        this.Button2.OnClientClick = "return confirm('请检查客人开台信息是否正确,一旦保存就无法修改,是否继续?')";
        this.Button4.OnClientClick = "return confirm('是否确认删除当前选择的用餐单号?')";
     
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {//获取选择的台位
        this.TextBox2.Text = this.GridView1.SelectedRow.Cells[1].Text.ToString();
        this.TextBox3.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString();
        this.TextBox1.Text = this.GridView3.SelectedRow.Cells[1].Text.ToString()+ this.TextBox2.Text;        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//保存开台信息
        if (this.TextBox1.Text.Length < 2)
            return;
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
        string MySQL = "INSERT INTO 用餐信息(用餐单号,入座台位,宾客人数,用餐日期,用餐类别,服务人员,当前状态,补充说明)VALUES('";
        MySQL += this.TextBox1.Text + "','";
        MySQL += this.TextBox2.Text + "','";
        MySQL += this.TextBox3.Text + "','";
        MySQL += this.TextBox4.Text + "','";
        MySQL += this.DropDownList1.SelectedValue.ToString() + "','";
        MySQL += this.DropDownList3.SelectedValue.ToString() + "','";
        MySQL += "正在用餐','";
        MySQL += this.TextBox7.Text + "');";
        MySQL += "Update 台位信息 SET 当前状态='在用' WHERE 台位编号='" + this.TextBox2.Text + "';";
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        if (MyConnection.State == ConnectionState.Open)
            MyConnection.Close();
        this.SqlDataSource1.DataBind();
        this.SqlDataSource4.DataBind();
        this.GridView1.DataBind();
        this.GridView2.DataBind();
    }

    protected void GridView2_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 Button4_Click(object sender, EventArgs e)
    {//删除选择的用餐单
        String My用餐单号 = this.TextBox1.Text;
        string My入座台位 = this.TextBox2.Text;
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
        string MySQL = "DELETE FROM 用餐信息 WHERE 用餐单号='" + My用餐单号 + "';";
        MySQL += "Update 台位信息 SET 当前状态='空置' WHERE 台位编号='" + My入座台位 + "';";
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        SqlCommand MyCommand = MyConnection.CreateCommand();
        MyCommand.CommandText = MySQL;
        MyCommand.ExecuteNonQuery();
        this.SqlDataSource1.DataBind();
        this.SqlDataSource4.DataBind();
        this.GridView1.DataBind();
        this.GridView2.DataBind();
    }
    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {//在控件中显示选择的记录
        this.TextBox1.Text = this.GridView2.SelectedRow.Cells[1].Text.ToString();
        this.TextBox2.Text = this.GridView2.SelectedRow.Cells[2].Text.ToString();
        this.TextBox3.Text = this.GridView2.SelectedRow.Cells[3].Text.ToString();
        this.TextBox4.Text = this.GridView2.SelectedRow.Cells[4].Text.ToString();
        this.DropDownList1.SelectedValue = this.GridView2.SelectedRow.Cells[5].Text.ToString();
        this.DropDownList3.SelectedValue = this.GridView2.SelectedRow.Cells[6].Text.ToString();
        this.TextBox7.Text = this.GridView2.SelectedRow.Cells[7].Text.ToString();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {//打印客人用餐服务单
        Server.Transfer("~/BookingManage/BookingEatPrint.aspx");
    }
    public String MyPrint用餐单号
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox1.Text;
        }
    }
    public String MyPrint入座台位
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox2.Text;
        }
    }
    public String MyPrint客人人数
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox3.Text;
        }
    }
    public String MyPrint用餐日期
    {//设置要传递到打印页的数据
        get
        {
            return this.TextBox4.Text;
        }
    }
    public String MyPrint用餐类别
    {//设置要传递到打印页的数据
        get
        {
            return this.DropDownList1.SelectedValue.ToString();
        }
    }
    public String MyPrint服务人员
    {//设置要传递到打印页的数据
        get
        {
            return this.DropDownList3.SelectedItem.Text.ToString();
        }
    }
    protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
    {//在GridView控件单元格中设置短日期显示格式
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime MyDate = DateTime.Parse(e.Row.Cells[2].Text);
            e.Row.Cells[2].Text = MyDate.ToShortDateString();
            MyDate = DateTime.Parse(e.Row.Cells[3].Text);
            e.Row.Cells[3].Text = MyDate.ToShortDateString();
        }
    }
    protected void GridView3_SelectedIndexChanged(object sender, EventArgs e)
    {//在输入控件中显示选择的内容
        this.TextBox4.Text = this.GridView3.SelectedRow.Cells[3].Text.ToString();
        this.DropDownList1.SelectedValue= this.GridView3.SelectedRow.Cells[5].Text.ToString();
        this.TextBox3.Text = this.GridView3.SelectedRow.Cells[4].Text.ToString();
        this.SqlDataSource4.SelectCommand = "SELECT [用餐单号], [入座台位], [宾客人数], [用餐日期], [用餐类别], [服务人员], [补充说明], [当前状态] FROM [用餐信息] WHERE (用餐单号 LIKE '%" + this.GridView3.SelectedRow.Cells[1].Text.ToString() + "%') AND ([当前状态] = '正在用餐')";
        this.SqlDataSource4.DataBind();
        this.GridView2.DataBind();
    }
}

⌨️ 快捷键说明

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