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

📄 streamclassoprate.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 OI.Manage
{
	/// <summary>
	/// streamclassoprate 的摘要说明。
	/// </summary>
	public class streamclassoprate : OI.PageBase
	{
		protected System.Web.UI.WebControls.TextBox TextBoxTitle;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.TextBox TextBoxContent;
		protected System.Web.UI.WebControls.Label optitle;
		protected System.Web.UI.WebControls.ImageButton ImageButton1;
		protected System.Web.UI.WebControls.ImageButton imgBack;
	    protected OI.DatabaseOper.DatabaseConnect Dbc=new OI.DatabaseOper.DatabaseConnect (); 
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			if (Session["userid"]==null)
			{
				Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
				return ;
			}
			if (!Page.IsPostBack )
			{
				string op=Request.Params["op"];
				if (op=="new")
				{
					optitle.Text ="新增流程类别";
				}
				else
				{
					optitle.Text ="修改流程类别";
					ViewState["id"]=Request.Params ["id"].ToString ().Trim().Replace ("'","''");
					setvalue(ViewState["id"].ToString ());
				}
   	
			}


		}
		private void setvalue (string ID)
		{
			string sql="select * from streamclass where id="+ID;
			DataSet ds=new DataSet ();
			ds=Dbc.getBinding (sql,"t");
			TextBoxTitle.Text =Server.HtmlEncode( ds.Tables[0].Rows[0]["classtitle"].ToString ());
			TextBoxContent.Text =Server.HtmlEncode(ds.Tables[0].Rows[0]["classdetail"].ToString ()); 
			
		}

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

		}
		#endregion

		private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string sql="";
			string title=TextBoxTitle.Text.Trim ().Replace ("'","''");
			string content=TextBoxContent.Text .Trim ().Replace ("'","''");
			if (Session["userid"]==null)
			{
				Page.RegisterStartupScript ("","<script>alert('超时,请重新登录')</script>");
				return;
			}
			
			string author=Session["userid"].ToString ();
			if (optitle.Text =="新增流程类别")
			{
				sql="select count(*) from streamclass where classtitle='"+title+"'";
				if (int.Parse (Dbc.GetValueBySql (sql))>0)
				{
					Page.RegisterStartupScript ("","<script>alert('此类别已经存在')</script>");
				}
				else
				{
					sql="insert into streamclass (classtitle,classdetail,author) values('"+title+"','"+content+"','"+author+"')";
					try
					{
						Dbc.ExecuteSQL (sql);
						Response.Redirect ("streamclass.aspx");
					}
					catch
					{
					}
				}
			}
			else
			{
				sql="select count(*) from streamclass where classtitle='"+title+"' and id !=" + ViewState["id"]  ;
				if (int.Parse (Dbc.GetValueBySql (sql))>0)
				{
					Page.RegisterStartupScript ("","<script>alert('此类别已经存在')</script>");
				}
				else
				{
					sql="update streamclass set classtitle='"+title +"',classdetail='"+content+"',author='"+author+"',createdate=getdate() where id="+  ViewState["id"]  ;
				    try
					{
					    Dbc.ExecuteSQL (sql);
						Response.Redirect ("streamclass.aspx");
					}
					catch
					{
					}
				}
			}
			

		}

		private void imgBack_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect ("streamclass.aspx");
		}
	}
}

⌨️ 快捷键说明

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