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

📄 config.cs

📁 ThreeLayer有关详细信息
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Web;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Web.Security;
using System.Security.Cryptography;
using WFNetCtrl;
using System.Drawing.Imaging;
using System.Drawing;
using System.Net;

namespace ThreeLayer.Web
{
	/// <summary>
	//========高处不胜寒Asp.Net三层结构表示层公共类V1.1===========
	//==========================================
	//    
	//                   '''
	//                  (0 0)
	//      +-----oOO----(_)-------------------+
	//      |                                  | 
	//      |     作者:高处不胜寒              |
	//      |     QQ:28767360                  |
	//      |     AspXCn QQ群:14094415        |  
	//      |     类型:Web版                  |
	//      |     适用数据库:Sql Sever        |
	//      |     更新时间:2005-08-13        |
	//      |     技术支持网站:www.AspxCn.Org  |
	//      |                                  |
	//      +------------------oOO-------------+
	//                 |__|__|
	//                  || ||
	//                 ooO Ooo  
	//
	//===========================================
	/// </summary>
	public class Config :Page
	{

		/// <summary>
		/// Set control's mode
		/// </summary>
		/// <param name="ctrls">name of control</param>
		/// <param name="Type">type of control</param>
		public void SetCtrlMode(Control [] ctrls,string Type)
		{
			for (int i=0;i<ctrls.Length;i++)
			{
				if (ctrls[i] is Button)
				{
					((Button)ctrls[i]).Attributes.Add("class",Type);
				}
				if (ctrls[i] is TextBox)
				{
					((TextBox)ctrls[i]).Attributes.Add("class",Type);
				}
			}
		}
		/// <summary>
		/// 服务器端弹出alert对话框
		/// </summary>
		/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
		/// <param name="page">Page类</param>
		public void Alert(string str_Message,Page page)
		{
			page.RegisterStartupScript("","<script>alert('"+str_Message+"');</script>");
		}
		/// <summary>
		/// 服务器端弹出alert对话框
		/// </summary>
		/// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param>
		/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
		/// <param name="page">Page类</param>
		public void Alert(string str_Ctl_Name,string str_Message,Page page)
		{
			page.RegisterStartupScript("","<script>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
		}
		/// <summary>
		/// 服务器端弹出confirm对话框,该函数有个弊端,必须放到响应事件的最后,目前没有妥善解决方案
		/// </summary>
		/// <param name="str_Message">提示信息,例子:"您是否确认删除!"</param>
		/// <param name="btn">隐藏Botton按钮Id值,比如:btn_Flow</param>
		/// <param name="page">Page类</param>
		public void Confirm(string str_Message,string btn,Page page)
		{
			page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();}</script>");
		}
		/// <summary>
		///  服务器端弹出confirm对话框,询问用户准备转向相应操作,包括“确定”和“取消”时的操作
		/// </summary>
		/// <param name="str_Message">提示信息,比如:"成功增加数据,单击\"确定\"按钮填写流程,单击\"取消\"修改数据"</param>
		/// <param name="btn_Redirect_Flow">"确定"按钮id值</param>
		/// <param name="btn_Redirect_Self">"取消"按钮id值</param>
		/// <param name="page">Page类</param>
		public void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self,Page page)
		{
			page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>");
		}
		/// <summary>
		/// 刷新某个桢
		/// </summary>
		/// <param name="Frame">桢名称</param>
		/// <param name="url">连接</param>
		/// <param name="page">page对象</param>
		public void ReloadFrame(string Frame,string url,Page page)
		{
			page.RegisterStartupScript("","<script language=\"javascript\">parent.frames('"+Frame+"').document.location.href='"+url+"';</script>");
		}

		/// <summary>
		/// Bind the data to the control,Include control:Repeater,DataGrid,DataList
		/// </summary>
		/// <param name="PageCount">Record count</param>
		/// <param name="lst">Data source</param>
		/// <param name="ctl_Listctl">control</param>
		/// <param name="AspNetPager1">Alot page control</param>
		public void BindCtrl(int PageCount,IList lst,Control ctl_Listctl,Wuqi.Webdiyer.AspNetPager AspNetPager1)
		{
			AspNetPager1.RecordCount=PageCount; 

			if (ctl_Listctl is Repeater)
			{
				((Repeater)ctl_Listctl).DataSource=lst;
				((Repeater)ctl_Listctl).DataBind();
			}
			if (ctl_Listctl is DataList)
			{
				((DataList)ctl_Listctl).DataSource=lst;
				((DataList)ctl_Listctl).DataBind();
			}
			if (ctl_Listctl is DataGrid)
			{
				((DataGrid)ctl_Listctl).DataSource=lst;
				((DataGrid)ctl_Listctl).DataBind();
			}
			AspNetPager1.CustomInfoText="当前页/总页数:"+AspNetPager1.CurrentPageIndex+"/"+AspNetPager1.PageCount+",每页记录:"+AspNetPager1.PageSize;

		}
		public void BindCtrl(IList lst,Control ctl_Listctl)
		{
			if (ctl_Listctl is Repeater)
			{
				((Repeater)ctl_Listctl).DataSource=lst;
				((Repeater)ctl_Listctl).DataBind();
			}
			if (ctl_Listctl is DataList)
			{
				((DataList)ctl_Listctl).DataSource=lst;
				((DataList)ctl_Listctl).DataBind();
			}
			if (ctl_Listctl is DataGrid)
			{
				((DataGrid)ctl_Listctl).DataSource=lst;
				((DataGrid)ctl_Listctl).DataBind();
			}
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="strValueField"></param>
		/// <param name="id"></param>
		/// <param name="name"></param>
		/// <param name="lst"></param>
		/// <param name="listctrl"></param>
		public void SetCtrl(string strValueField,string id,string name,IList lst,Control listctrl)
		{
			BindCtrl(id,name,lst,listctrl);
			
			//===DropDownList===
			if (listctrl is DropDownList)
			{
				((DropDownList)listctrl).Items[0].Selected=false;
				for (int i=0;i<((DropDownList)listctrl).Items.Count;i++) 
				{
					if (","+strValueField+","==","+((DropDownList)listctrl).Items[i].Value+",")
					{
						((DropDownList)listctrl).Items[i].Selected=true;
						break;
					}
				}
			}
			//===CheckBoxList===
			if (listctrl is CheckBoxList)
			{
				for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++) 
				{
					if ((","+strValueField+",").IndexOf(","+((CheckBoxList)listctrl).Items[i].Value+",")!=-1)
					{
						((CheckBoxList)listctrl).Items[i].Selected=true;
					}
				}
			}
			//===RadioButtonList===
			if (listctrl is RadioButtonList)
			{
				((RadioButtonList)listctrl).Items[0].Selected=false;
				for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++) 
				{
					if (","+strValueField+","==","+((RadioButtonList)listctrl).Items[i].Value+",")
					{
						((RadioButtonList)listctrl).Items[i].Selected=true;
						break;
					}
				}
			}
			//===c===
			if (listctrl is ListBox)
			{
				for (int i=0;i<((ListBox)listctrl).Items.Count;i++) 
				{
					if ((","+strValueField+",").IndexOf(","+((ListBox)listctrl).Items[i].Value+",")!=-1)
					{
						((ListBox)listctrl).Items[i].Selected=true;
					}
				}
			}
		}
		public void SetCtrl(string strValueField,string val,string txt,Control listctrl)
		{
			string[] arr_Val=val.Split(',');
			string[] arr_Txt=txt.Split(',');
			
			//===DropDownList===
			if (listctrl is DropDownList)
			{
				for (int i=0;i<arr_Val.Length;i++)
				{
					if (strValueField==arr_Val[i].ToString())
					{
						ListItem it=new ListItem(arr_Txt[i],arr_Val[i]);
						((DropDownList)listctrl).Items.Insert(0,it);
					}
					else
					{
						ListItem it=new ListItem(arr_Txt[i],arr_Val[i]);
						((DropDownList)listctrl).Items.Add(it);
					}
				}
			}
			//===CheckBoxList===
			if (listctrl is CheckBoxList)
			{
				for (int i=0;i<arr_Val.Length;i++)
				{
					if (strValueField==arr_Val.ToString())
					{
						ListItem it=new ListItem(arr_Txt[i],arr_Val[i]);
						it.Selected=true;
						((CheckBoxList)listctrl).Items.Add(it);
					}
				}
			}

			//===RadioButtonList===
			if (listctrl is RadioButtonList)
			{
				for (int i=0;i<arr_Val.Length;i++)
				{
					if (strValueField==arr_Val.ToString())
					{
						ListItem it=new ListItem(arr_Txt[i],arr_Val[i]);
						it.Selected=true;
						((RadioButtonList)listctrl).Items.Add(it);
					}
				}
			}
			//===ListBox===
			if (listctrl is ListBox)
			{
				for (int i=0;i<arr_Val.Length;i++)
				{
					if (strValueField==arr_Val.ToString())
					{
						ListItem it=new ListItem(arr_Txt[i],arr_Val[i]);
						it.Selected=true;
						((ListBox)listctrl).Items.Add(it);
					}
				}
			}


		}

		/// <summary>
		/// 获得CheckBoxLis,RadioButtonList,ListBox控件所有选中值并以逗号格开,形式:"2,3,4"
		/// </summary>
		/// <param name="listctrl">CheckBoxLis,RadioButtonList,ListBox控件</param>
		/// <param name="type">类型,是想获得Value还是Text值</param>
		/// <returns></returns>
		public string GetCtrlSelValue(Control listctrl)
		{
			string str_Value="";

			//===CheckBoxList===
			if (listctrl is CheckBoxList)
			{
				for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++) 
				{
					if (((CheckBoxList)listctrl).Items[i].Selected==true)
					{
						str_Value=str_Value+((CheckBoxList)listctrl).Items[i].Value+",";
					}
				}
				if (str_Value!="")
				{
					str_Value=str_Value.Substring(0,str_Value.Length-1);
				}
			}
			//===RadioButtonList===
			if (listctrl is RadioButtonList)
			{
				for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++) 
				{
					if (((RadioButtonList)listctrl).Items[i].Selected==true)
					{
						str_Value=((RadioButtonList)listctrl).Items[i].Value;
					}
				}

			}
			//===ListBox===
			if (listctrl is ListBox)
			{

				for (int i=0;i<((ListBox)listctrl).Items.Count;i++) 
				{
					if (((ListBox)listctrl).Items[i].Selected==true)
					{
						str_Value=str_Value+((ListBox)listctrl).Items[i].Value+",";
					}
				}
				if (str_Value!="")
				{
					str_Value=str_Value.Substring(0,str_Value.Length-1);
				}
			}
			return str_Value;
		}

		/// <summary>
		/// 绑定DropDownList等控件
		/// </summary>
		/// <param name="id">控件Value值字段</param>
		/// <param name="name">控件Text值字段</param>
		/// <param name="lst">IList数据源</param>
		/// <param name="listctrl">控件Id</param>
		public void BindCtrl(string id,string name,IList lst,Control listctrl)
		{
			//===DropDownList===
			if (listctrl is DropDownList)
			{
				((DropDownList)listctrl).DataValueField=id;
				((DropDownList)listctrl).DataTextField=name;
				((DropDownList)listctrl).DataSource=lst;
				((DropDownList)listctrl).DataBind();
			}
			if (listctrl is CheckBoxList)
			{
				((CheckBoxList)listctrl).DataValueField=id;
				((CheckBoxList)listctrl).DataTextField=name;
				((CheckBoxList)listctrl).DataSource=lst;
				((CheckBoxList)listctrl).DataBind();
			}
		}
		public void BindCtrl(string DefaultValue,string DefaultText,string id,string name,IList lst,Control listctrl)
		{
			//===DropDownList===
			if (listctrl is DropDownList)
			{
				((DropDownList)listctrl).DataValueField=id;
				((DropDownList)listctrl).DataTextField=name;
				((DropDownList)listctrl).DataSource=lst;
				((DropDownList)listctrl).DataBind();
				ListItem it=new ListItem(DefaultText,DefaultValue);
				it.Selected=true;
				((DropDownList)listctrl).Items.Insert(0,it);
			}

		}
		public void SetCtrl(string strValueField,string DefaultValue,string DefaultText,string id,string name,IList lst,Control listctrl)
		{
			//===DropDownList===
			if (listctrl is DropDownList)
			{
				((DropDownList)listctrl).DataValueField=id;
				((DropDownList)listctrl).DataTextField=name;
				((DropDownList)listctrl).DataSource=lst;
				((DropDownList)listctrl).DataBind();
				ListItem it=new ListItem(DefaultText,DefaultValue);
				((DropDownList)listctrl).Items.Insert(0,it);
			}

			//===DropDownList===
			if (listctrl is DropDownList)
			{
				for (int i=0;i<((DropDownList)listctrl).Items.Count;i++)
				{
					if (strValueField==((DropDownList)listctrl).Items[i].Value.ToString())
					{
						((DropDownList)listctrl).Items[i].Selected=true;
					}
				}
			}

		}
		public void BindCtrl(string val,string txt,Control listctrl)
		{
			string[] arr_Val=val.Split(',');

⌨️ 快捷键说明

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