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

📄 querybookingform.aspx.cs

📁 C# + MYSQL 课程设计 ASP.NET 2.0数据库开发《餐饮消费管理系统》功能完整
💻 CS
字号:
//文件名:QueryBookingForm.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 QueryManage_QueryBookingForm : System.Web.UI.Page
{
    private static string MySQL = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("D1") > 1)
        {
            Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {//查询预订用餐信息
        string My当前状态 = this.DropDownList1.SelectedValue.ToString();
        if (My当前状态 == "所有情况")
            My当前状态 = "%%";
        string My餐次名称 = this.DropDownList2.SelectedValue.ToString();
        if (My餐次名称 == "所有")
            My餐次名称 = "%%";
        DataTable MyTable = new DataTable();
        MySQL = "SELECT * From 预订信息 WHERE (预订编号 LIKE '%" + this.TextBox1.Text + "%')";
        MySQL += "AND (用餐要求 LIKE '%" + this.TextBox2.Text + "%')";
        MySQL += "AND (联系人员 LIKE '%" + this.TextBox15.Text + "%')";
        MySQL += "AND (补充说明 LIKE '%" + this.TextBox14.Text + "%')";
        MySQL += "AND (当前状态 LIKE '%" + My当前状态 + "%')";
        MySQL += "AND (餐次名称 LIKE '%" + My餐次名称 + "%')";
        MySQL += "AND (预订日期 BETWEEN '" + this.TextBox12.Text + "' AND '" + this.TextBox13.Text + "') ";
        MySQL += "AND (预交订金 BETWEEN " + this.TextBox16.Text + " AND " + this.TextBox17.Text + ") ";
        String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyEateryDBConnectionString"].ConnectionString;
        SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
        MyConnection.Open();
        SqlDataAdapter MyAdatper = new SqlDataAdapter(MySQL, MyConnection);
        MyAdatper.Fill(MyTable);
        this.GridView1.DataSource = MyTable;
        this.GridView1.DataBind();
        if (MyConnection.State == ConnectionState.Open)
        {
            MyConnection.Close();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {//打印预订用餐信息
        Server.Transfer("~/QueryManage/QueryBookingPrint.aspx");
    }
    public string MyPrintSQL
    {//设置要传递到打印页的数据
        get
        {
            return MySQL;
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {//在GridView控件单元格中设置短日期显示格式
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime MyDate = DateTime.Parse(e.Row.Cells[1].Text);
            e.Row.Cells[1].Text = MyDate.ToShortDateString();
            MyDate = DateTime.Parse(e.Row.Cells[2].Text);
            e.Row.Cells[2].Text = MyDate.ToShortDateString();
        }
    }
}

⌨️ 快捷键说明

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