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

📄 doctemplate.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;
using OI.DatabaseOper ;

namespace OI.DocTemplate
{
	/// <summary>
	/// DocTemplate 的摘要说明。
	/// </summary>
	public class DocTemplate : OI.PageBase
	{
		protected System.Web.UI.WebControls.Button ButtonNew;
		protected System.Web.UI.WebControls.Button ButtonDel;
		protected System.Web.UI.WebControls.DataGrid DataGridDoc;
		DatabaseOper.DatabaseConnect dc;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面		
			if (Session["userid"]==null)
			{
				Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
				return ;
			}
			dc=new DatabaseConnect ();
			if(!this.IsPostBack )
				this.BindDoc ();
			else
				ButtonDel.Attributes["onclick"]= "return confirm('是否要删除?')";
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.ButtonNew.Click += new System.EventHandler(this.ButtonNew_Click);
			this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void ButtonNew_Click(object sender, System.EventArgs e)
		{
			Response.Redirect ("TemplateAddEdit.aspx?id=-1");
		}

		private void ButtonDel_Click(object sender, System.EventArgs e)
		{
			string sql="DELETE FROM DocumentCyclostyle ";
			bool isHave=false;
			foreach(DataGridItem  li in this.DataGridDoc.Items) 
			{				
				if(((CheckBox)li.FindControl("CheckBoxSelected")).Checked) 
				{
					if(!isHave)
					{
						sql+=" WHERE CyclostyleID='"+DataGridDoc.Items[li.ItemIndex ].Cells [0].Text .Trim ()+"'";
						isHave=true;
					}
					else
						sql+=" OR CyclostyleID='"+DataGridDoc.Items[li.ItemIndex ].Cells [0].Text .Trim ()+"'";
				}
			}			
			if(isHave)
			{								
				dc.deleteData (sql);
			}
			else
				Page.RegisterStartupScript ("","<script>alert('没有选择数据')</script>");
			this.BindDoc ();
		}
		private void BindDoc()
		{
			string sql="SELECT CyclostyleID,CyclostyleName FROM DocumentCyclostyle";
			DataGridDoc.DataSource =dc.getBinding (sql,"table1").Tables ["table1"].DefaultView ;
			DataGridDoc.DataBind ();
		}		
	}
}

⌨️ 快捷键说明

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