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

📄 customerorderslist.aspx.cs

📁 PetShop实现的是一个网上购物的系统功能
💻 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;
using System.Data.SqlClient;

namespace PetShop.Web
{
	/// <summary>
	/// CustomerOrdersList 的摘要说明。
	/// </summary>
	public partial class CustomerOrdersList : System.Web.UI.Page
	{
		string strDate="",strNum="",strSTo="";
		SqlConnection con=new SqlConnection(PetShop.Components.Database.strCon);

		public bool AllowPaging = true;
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
//			string strDate=Request.QueryString["strDT"];
//			string strNum=Request.QueryString["strNM"];
//			string strSTo=Request.QueryString["strTS"];
//			DateTime dt=Convert.ToDateTime(strDate);
//			int num=Convert.ToInt32(strNum);
//			PetShop.Components.Order order=new PetShop.Components.Order();
//			this.DataGrid1.DataSource=order.GetOrderList(dt,num,strSTo);
//			this.DataGrid1.DataBind();
			if(Page.IsPostBack==false)
			{
				if(AllowPaging)
				{
					this.DataGrid1.AllowPaging=true;
					this.DataGrid1.PageSize=4;
					this.DataGrid1.CurrentPageIndex=0;
				}
			}
			if(Request["strDt"]!=null)
			{
				string strDate=Request.QueryString["strDT"];
			}
			else
			{
				Response.Write("<scrip>alert('请从正常路径进入');Window.location='CustomerOrderQuery.aspx';</scrip>");
			}
			if(Request["strNM"]!=null)
			{
				strNum=Request.QueryString["strNM"];
			}
			else
			{
				Response.Write("<scrip>alert('请从正常路径进入');Window.location='CustomerOrderQuery.aspx';</scrip>");
			}
			if(Request["strTS"]!=null)
			{
				if(Request["strTS"]=="A")
				{
					strSTo="";

				}
				else
				{
					strSTo=Request["strTS"].ToString();
				}
			}
			if (!IsPostBack) 
			{
				bindData();
			}
		}
			private void bindData()
			{
				string strSqlAll="Select * From orderStatus where ";
				string str1,str2,str3;
				str1=" timestamp like'%"+strDate+"%' ";
				str2=" and orderid like'%"+strNum+"%' ";
				str3=" and status like'%"+strSTo+"%' ";
				strSqlAll=strSqlAll+str1+str2+str3;
			//	Response.Write(strSqlAll);
				DataSet DS=new DataSet();
				con.Open();
				SqlDataAdapter sda=new SqlDataAdapter(strSqlAll,con);
				sda.Fill(DS);
				sda.Dispose();
				this.DataGrid1.DataSource=DS;
				this.DataGrid1.DataBind();
				ShowNavButtons();
//
//				Hashtable ad=(Hashtable)Session["UserID"];
//                bool state=Convert.ToBoolean(ad["UserID"]);
//				if(state)
//				{
//					this.DataGrid1.Columns[4].Visible=false;
//				}
//				else
//				{
//					this.DataGrid1.Columns[4].Visible=true;
//				}
				con.Close();

			}
		private void ShowNavButtons() 
		{
			// hide or show navigation buttons
			// always hide if not supporting paging or there is only one page
			if(AllowPaging && (this.DataGrid1.PageCount>0))
			{
				this.ImageButton1.Visible=this.DataGrid1.CurrentPageIndex>0;
				this.ImageButton2.Visible=this.DataGrid1.CurrentPageIndex<(this.DataGrid1.PageCount-1);
			}
			else
			{
				this.ImageButton1.Visible=this.ImageButton2.Visible=false;
			}
//			if (AllowPaging && (dataGrid.PageCount > 0)) 
//			{
//				// hide and show buttons
//				btnPrev.Visible = dataGrid.CurrentPageIndex > 0;
//				btnMore.Visible = dataGrid.CurrentPageIndex < (dataGrid.PageCount-1);
//			}
//			else 
//			{
//				// both buttons should be hidden
//				btnPrev.Visible = btnMore.Visible = false;
//			}
		}
		

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
			this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
			this.ImageButton2.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton2_Click);

		}
		#endregion

		private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			string strdata="";
			string strnum="";
			string strstotus="";
			
			if(e.Item.Cells[0].Text.Trim()=="")
			{
				 strdata="";
			}
			else
			{
				 strdata=e.Item.Cells[0].Text.ToString();
//				strdatetime=this.txtordesdate.Text.ToString();
			}
			if(e.Item.Cells[1].Text.Trim()=="")
			{
				strnum="";
			}
			else
			{
			   strnum=e.Item.Cells[1].Text.ToString();
			}
			if(e.Item.Cells[2].Text=="")
			{
				strstotus="";

			}
			else
			{
				 strstotus=e.Item.Cells[2].Text.ToString();
				
			}


           if(e.CommandName=="view")
			{
				Response.Redirect("CustomerOrderDetails.aspx?strDT="+strdata+"&strNM="+strnum+"&strTS="+strstotus);
			}


			if(e.CommandName=="Edit")
			{
				Response.Redirect("CustomerOrderModify.aspx?strDT="+strdata+"&strNM="+strnum+"&strTS="+strstotus);
			}

			//Response.Redirect("CustomerOrdersList.aspx?strDT="+strdata+"&strNM="+strnum+"&strTS="+strstotus);

		}

		private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(this.ImageButton2.Visible)
			{
				this.DataGrid1.CurrentPageIndex++;
                bindData();
			}
		}

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(this.ImageButton1.Visible)
			{
				this.DataGrid1.CurrentPageIndex--;
				bindData();
			}
		}

		protected void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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