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

📄 ccutility.cs

📁 基于web的图书管理系统 (SQL Server 2000)
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
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
{
	public class CCUtility
	{
		protected HttpSessionState Session;
		protected HttpServerUtility Server;
		protected HttpRequest Request;
		protected HttpResponse Response;
		public CCUtility(object parent)
		{
			Session=HttpContext.Current.Session;
			Server=HttpContext.Current.Server;
			Request=HttpContext.Current.Request;
			Response=HttpContext.Current.Response;
		} 
		public string GetParam(string ParamName) 
		{
			string Param = Request.QueryString[ParamName];
			if (Param == null)
				Param = Request.Form[ParamName];
			if (Param == null)
				return "";
			else 
				return Param;
		}

    	public OleDbConnection Connection;
		public void buildListBox(ListItemCollection Items,string sSQL, string sId, string sTitle, string CustomInitialDisplayValue,string CustomInitialSubmitValue)
		{	
			Items.Clear();
			OleDbCommand command = new OleDbCommand(sSQL, Connection);
			OleDbDataReader reader = command.ExecuteReader();
	
			if(CustomInitialDisplayValue!=null) Items.Add(new ListItem(CustomInitialDisplayValue,CustomInitialSubmitValue));

			while(reader.Read()) 
			{	
				if(sId==""&&sTitle=="")	
				{
					Items.Add(new ListItem(reader[1].ToString(),reader[0].ToString()));
				}
				else
				{
					Items.Add(new ListItem(reader[sTitle].ToString(),reader[sId].ToString()));
				}
			}
			reader.Close();
		}
	
		public void buildListBox(ListItemCollection Items,string[] values, string CustomInitialDisplayValue,string CustomInitialSubmitValue)
		{	
			Items.Clear();
			if(CustomInitialDisplayValue!=null) Items.Add(new ListItem(CustomInitialDisplayValue,CustomInitialSubmitValue));
			for(int i=0;i<values.Length;i+=2)Items.Add(new ListItem(values[i+1],values[i]));
		}
	
		public int Compare(System.DateTime dt1,System.DateTime dt2)
		{
		    int i;
			if(DateTime.Compare(dt1,dt2)>0)
			{
				for(i=0;i<1000;i++)
				{
					if(DateTime.Compare(dt1,dt2.AddDays(i))<=0)
						return i -1;	
				}
			}
			return 0;
		}
	
		public void CheckSecurity() 
		{
			if (Session["UserID"] == null || Session["UserID"].ToString().Length == 0) 
			{
				Response.Redirect("Web_login.aspx?QueryString=" + Server.UrlEncode(Request.ServerVariables["QUERY_STRING"]) + "&ret_page=" + Server.UrlEncode(Request.ServerVariables["SCRIPT_NAME"]));
			} 
			else 
			{
				//if (Int16.Parse(Session["UserRights"].ToString()) < iLevel)
				//	Response.Redirect("Web_login.aspx");
			}
		}
		public void Logout()
		{
		Session["UserID"]=null;
		
		}
	}
}

⌨️ 快捷键说明

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