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

📄 orderfrm.aspx.cs

📁 某大型国企试用的网上订餐管理系统完整源代码
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace WebApplication1
{
	/// <summary>
	/// OrderFrm 的摘要说明。
	/// </summary>
	public class OrderFrm : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.DropDownList RptDList;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.DropDownList DinnerTypeDList;
		protected System.Web.UI.WebControls.RangeValidator VldDate;
		protected System.Web.UI.WebControls.Label VldDateMsg;
		protected System.Web.UI.WebControls.Calendar Calendar1;
		protected System.Web.UI.WebControls.Button Button1;


		protected System.Data.Odbc.OdbcConnection odbcConnection1;
		protected System.Data.DataSet dataSet1;
		protected System.Data.Odbc.OdbcCommand odbcSelectCommand1;
		protected System.Data.Odbc.OdbcCommand odbcInsertCommand1;
		protected System.Data.Odbc.OdbcCommand odbcUpdateCommand1;
		protected System.Data.Odbc.OdbcCommand odbcDeleteCommand1;
		protected System.Data.Odbc.OdbcDataAdapter odbcDataAdapter1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.TextBox RptDateBox;

		private string strUser ;     
		private string strUserName;  
		private string strDept;
		private string strDeptName;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.Button Button3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.DropDownList PageSizeDList; 
		private string		strDate;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			Calendar1.SelectedDate = DateTime.Today;

			strUser = (string)Session["strUser"];          
			strUserName = (string)Session["strUserName"];  
			strDept = (string)Session["strDept"];          
			strDeptName = (string)Session["strDeptName"];  

			if (!Page.IsPostBack)
			{
				if (!Global.CheckUserValidation((string)Session["strRole"], Global.MENU_PRINT))
				{
					Response.Redirect("err_session.htm", true);
				}
				RptDList.Items.Clear();
			//	RptDList.Items.Add("全部订餐单");
				RptDList.Items.Add("部门订餐单");
				RptDList.Items.Add("个人订餐单");
			
				DinnerTypeDList.Items.Clear();
				DinnerTypeDList.Items.Add("早餐");
				DinnerTypeDList.Items.Add("午餐");
				DinnerTypeDList.Items.Add("晚餐");
				DinnerTypeDList.Items.Add("零点餐");

				//2006-05-07
				PageSizeDList.Items.Clear();
				PageSizeDList.Items.Add("打印机设置的默认大小");
				PageSizeDList.Items.Add("A4 纸,210 x 297 毫米");
				PageSizeDList.Items.Add("A5 纸,148 x 210 毫米");
				PageSizeDList.Items.Add("B4 纸,250 x 354 毫米");
				PageSizeDList.Items.Add("B5 纸,182 x 257 毫米");
				PageSizeDList.Items.Add("A3 纸,297 x 420 毫米");
				PageSizeDList.Items.Add("Letter,215.9x279.4 毫米");
				PageSizeDList.Items.Add("纸张为 254 x 355.6 毫米");
				PageSizeDList.Items.Add("纸张为 279.4x431.8 毫米");

				RptDateBox.Text=DateTime.Today.ToString("yyyy'-'MM'-'dd");
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.odbcConnection1 = new System.Data.Odbc.OdbcConnection();
			this.odbcSelectCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcInsertCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcUpdateCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcDeleteCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcDataAdapter1 = new System.Data.Odbc.OdbcDataAdapter();
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Calendar1.DayRender += new System.Web.UI.WebControls.DayRenderEventHandler(this.Calendar1_DayRender);
			this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
			this.Button3.Click += new System.EventHandler(this.Button3_Click);
			// 
			// odbcDataAdapter1
			// 
			this.odbcDataAdapter1.DeleteCommand = this.odbcDeleteCommand1;
			this.odbcDataAdapter1.InsertCommand = this.odbcInsertCommand1;
			this.odbcDataAdapter1.SelectCommand = this.odbcSelectCommand1;
			this.odbcDataAdapter1.UpdateCommand = this.odbcUpdateCommand1;
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			string strCommand;
			string strReport;
			string strKind,DinnerKind ;
			int DListIndex; 
			string StartDate="",EndDate="";

			RptDateBox.DataBind();
			strDate=RptDateBox.Text;
			if(!VldDate.IsValid||RptDateBox.Text.Trim().CompareTo("")==0)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:订餐日期输入有误,请重新输入!"")</script>");
				//VldDateMsg.Visible=true;
				//VldDateMsg.Text="开始日期输入有误,请重新输入!";
				return;
			}
			else
				strDate=RptDateBox.Text;
			
			//VldDateMsg.Visible=false;		

			DListIndex =DinnerTypeDList.SelectedIndex;
			strKind="早餐";
			DinnerKind="A";
			switch(DListIndex)
			{
				case 0:
					strKind="早餐";
					DinnerKind="A";
					break;
				case 1:
					strKind="午餐";
					DinnerKind="B";
					break;
				case 2:
					strKind="晚餐";
					DinnerKind="C";
					break;
				case 3:
					strKind="零点餐";
					DinnerKind="D";
					break;
			}

			bool bEndDinner;
			string strSysDinner, strSysDate;
			bEndDinner = Global.FindBookTime(out strSysDinner, out strSysDate);
			if ((strDate.CompareTo(strSysDate) > 0) ||
				 (strDate.CompareTo(strSysDate) == 0 && DinnerKind.CompareTo(strSysDinner) > 0) ||
				 (bEndDinner && strDate.CompareTo(strSysDate) == 0 && DinnerKind.CompareTo(strSysDinner) == 0))
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:所要打印的订餐尚未结束!"")</script>");
				return;
			}


			DListIndex = RptDList.SelectedIndex;
			if (DListIndex==0)
			{
				strReport="t_batch_order";
				strCommand = "select BATCH_ORDER_id,date,elt(conv(kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,"+
					"Department_ID,department,Num,send_dest,reason,Manager_id,Manager_name,Effect,Checker_id,"+
				   "Checker_name from t_batch_order where Effect='1' and date='"+strDate+"' and Kind='"+DinnerKind+"' order by BATCH_ORDER_id";
			}
			else
			{
				strReport="t_order";
				strCommand = "select distinct a.ORDER_ID ORDER_ID,a.Date Date,a.Kind Kind,a.Send_dest Send_dest,"+
					"a.User_id User_id,a.Name name,a.Department_id Department_id,a.Department Department,"+
					"a.Totel_price/100 Totel_price,a.Free Free,a.memo Memo,c.Name Menu_Name,"+
					"b.Quantity Quantity,b.Quantity*c.Price/100 Balance "+
					"from t_order a,t_order_detail b,t_current_menu c where a.ORDER_ID=b.ORDER_ID and "+
					"b.food_id=c.food_id and a.date='"+strDate+"' and a.Kind='"+ DinnerKind+"' order by a.ORDER_ID";
			}

			//Session["strConnect"]=strConnect;
			Session["strCommand"]=strCommand;
			Session["strReport"]=strReport;
			Session["StartDate"]=StartDate;
			Session["EndDate"]=EndDate;
			Session["strKind"]=strKind;
			//2006-05-07
			Session["PageSize"]=PageSizeDList.SelectedIndex;

			String sUrl = "./RptFrm.aspx";
			String sFeatures ="''";
			String sScript ="";
			sScript += "<script language=javascript>";
			sScript += "window.open('" + sUrl + "',''," + sFeatures + ");";
			sScript += "</script>";
			Response.Write(sScript);

			Global.OpenConnection(ref odbcConnection1);
			Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_PRINT,Global.ACTION_OTHER,"打印"+strDate+"日,"+DinnerKind+"餐,"+RptDList.SelectedItem.Text);
         odbcConnection1.Close();	

		}

		private void Calendar1_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
		{
			/*if (Calendar1.SelectedDate==Calendar1.TodaysDate)
			{
				RptDateBox.Text =Calendar1.SelectedDate.ToString("yyyy'-'MM'-'dd");
				strDate= RptDateBox.Text;
			}*/
		}

		private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
		{
			RptDateBox.Text =Calendar1.SelectedDate.ToString("yyyy'-'MM'-'dd");
			strDate= RptDateBox.Text;
		}

		private void Button3_Click(object sender, System.EventArgs e)
		{
			string strCommand;
			string strReport;
			string strKind,DinnerKind ;
			int DListIndex; 
			string StartDate="",EndDate="";

			RptDateBox.DataBind();
			strDate=RptDateBox.Text;
			if(!VldDate.IsValid||RptDateBox.Text.Trim().CompareTo("")==0)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:订餐日期输入有误,请重新输入!"")</script>");
				//VldDateMsg.Visible=true;
				//VldDateMsg.Text="开始日期输入有误,请重新输入!";
				return;
			}
			else
				strDate=RptDateBox.Text;
			
			//VldDateMsg.Visible=false;		

			DListIndex =DinnerTypeDList.SelectedIndex;
			strKind="早餐";
			DinnerKind="A";
			switch(DListIndex)
			{
				case 0:
					strKind="早餐";
					DinnerKind="A";
					break;
				case 1:
					strKind="午餐";
					DinnerKind="B";
					break;
				case 2:
					strKind="晚餐";
					DinnerKind="C";
					break;
				case 3:
					strKind="零点餐";
					DinnerKind="D";
					break;
			}

			bool bEndDinner;
			string strSysDinner, strSysDate;
			bEndDinner = Global.FindBookTime(out strSysDinner, out strSysDate);
			if ((strDate.CompareTo(strSysDate) > 0) ||
				(strDate.CompareTo(strSysDate) == 0 && DinnerKind.CompareTo(strSysDinner) > 0) ||
				(bEndDinner && strDate.CompareTo(strSysDate) == 0 && DinnerKind.CompareTo(strSysDinner) == 0))
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:所要打印的订餐尚未结束!"")</script>");
				return;
			}


			DListIndex = RptDList.SelectedIndex;
			if (DListIndex==0)
			{
				strReport="t_batch_order";
				strCommand = "select BATCH_ORDER_id,date,elt(conv(kind,16,10)-9,'早餐','中餐','午餐','零点餐') kind,"+
					"Department_ID,department,Num,send_dest,reason,Manager_id,Manager_name,Effect,Checker_id,"+
					"Checker_name from t_batch_order where Effect='1' and date='"+strDate+"' and Kind='"+DinnerKind+"' order by BATCH_ORDER_id";
			}
			else
			{
				strReport="t_order";
				strCommand = "select distinct a.ORDER_ID ORDER_ID,a.Date Date,a.Kind Kind,a.Send_dest Send_dest,"+
					"a.User_id User_id,a.Name name,a.Department_id Department_id,a.Department Department,"+
					"a.Totel_price/100 Totel_price,a.Free Free,a.memo Memo,c.Name Menu_Name,"+
					"b.Quantity Quantity,b.Quantity*c.Price/100 Balance "+
					"from t_order a,t_order_detail b,t_current_menu c where a.ORDER_ID=b.ORDER_ID and "+
					"b.food_id=c.food_id and a.date='"+strDate+"' and a.Kind='"+ DinnerKind+"' order by a.ORDER_ID";
			}

			//Session["strConnect"]=strConnect;
			Session["strCommand"]=strCommand;
			Session["strReport"]=strReport;
			Session["StartDate"]=StartDate;
			Session["EndDate"]=EndDate;
			Session["strKind"]=strKind;
			//2006-05-07
			Session["PageSize"]=PageSizeDList.SelectedIndex;

			String sUrl = "./PdfFrm.aspx";
			String sFeatures ="''";
			String sScript ="";
			sScript += "<script language=javascript>";
			sScript += "window.open('" + sUrl + "',''," + sFeatures + ");";
			sScript += "</script>";
			Response.Write(sScript);

			Global.OpenConnection(ref odbcConnection1);
			Global.WriteLog(ref odbcConnection1, strUser,Global.MENU_PRINT,Global.ACTION_OTHER,"打印"+strDate+"日,"+DinnerKind+"餐,"+RptDList.SelectedItem.Text);
			odbcConnection1.Close();			
		}
	}
}

⌨️ 快捷键说明

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