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

📄 queryusedform.aspx.cs

📁 C# + MYSQL 课程设计 ASP.NET 2.0数据库开发《餐饮消费管理系统》功能完整
💻 CS
字号:
//文件名:QueryUsedForm.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_QueryUsedForm : System.Web.UI.Page
{
    private static string MySQL = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        string MyForbidString = Session["MyForbid"].ToString();
        if (MyForbidString.IndexOf("D3") > 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菜品小类 = "%%";
        string My菜品风味 = this.DropDownList3.SelectedValue.ToString();
        if (My菜品风味 == "所有")
            My菜品风味 = "%%";
        string My当前状态 = this.DropDownList4.SelectedValue.ToString();
        if (My当前状态 == "所有")
            My当前状态 = "%%";
        DataTable MyTable = new DataTable();
        MySQL = "SELECT dbo.用餐信息.用餐单号, dbo.用餐信息.用餐日期, dbo.用餐明细.菜品名称,dbo.用餐明细.计量单位, dbo.用餐明细.计费单价, dbo.用餐明细.计费数量, dbo.用餐明细.计费金额 FROM dbo.菜品信息 INNER JOIN  dbo.用餐明细 ON dbo.菜品信息.菜品名称 = dbo.用餐明细.菜品名称 INNER JOIN dbo.用餐信息 ON dbo.用餐明细.用餐单号 = dbo.用餐信息.用餐单号 WHERE (dbo.菜品信息.菜品大类 LIKE '%" + My菜品大类 + "%')";
        MySQL += "AND (dbo.菜品信息.菜品小类 LIKE '%" + My菜品小类 + "%')";
        MySQL += "AND (dbo.菜品信息.菜品风味 LIKE '%" + My菜品风味 + "%')";
        MySQL += "AND (dbo.菜品信息.当前状态 LIKE '%" + My当前状态 + "%')";
        MySQL += "AND (dbo.菜品信息.菜品名称 LIKE '%" + this.TextBox5.Text + "%')";
        MySQL += "AND (用餐信息.用餐日期 BETWEEN '" + this.TextBox6.Text + "' AND '" + this.TextBox7.Text + "')";
        MySQL += "AND (dbo.用餐信息.用餐单号 LIKE '%" + this.TextBox1.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)
    {//打印菜品消费信息
        Session["MySQL"] =MySQL;
        Server.Transfer("~/QueryManage/QueryUsedPrint.aspx");
    }  
    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();
        }
    }
}

⌨️ 快捷键说明

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