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

📄 gwmanage.aspx.cs

📁 很不错的公文流转系统
💻 CS
字号:
using System; 
using System.Collections;
using System.ComponentModel;
using System.Data;
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 OI.Manage
{
	/// <summary>
	/// SignatureList 的摘要说明。
	/// </summary>
	public class gwmanage : OI.PageBase
	{
		protected System.Web.UI.WebControls.DataGrid DataGridList;
		protected DatabaseOper.DatabaseConnect conn=new OI.DatabaseOper.DatabaseConnect();
		protected System.Web.UI.WebControls.DropDownList dstwhere;
		protected System.Web.UI.WebControls.TextBox txtsearch;
		protected System.Web.UI.WebControls.ImageButton imgbtnsearch;
		protected ZHENGYI.DataGridNavigation DataGridNavigation1;
		
		//OI.Modules.iDBManage2000 DBAobj;

		private void Page_Load(object sender, System.EventArgs e)
		{
			if (Session["userid"]==null)
			{
				Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
				return ;
			}
			

			ZHENGYI.BindDataDelegate f =new ZHENGYI.BindDataDelegate (GetSignatureList);//修改这个dataBind,让f 指向你的方法。 
			DataGridNavigation1.SetTarget(DataGridList,f,15);
			if(!Page.IsPostBack)
			{
				GetSignatureList();
			}

		}
		private void GetSignatureList()
		{ 
			string sql="select * from Document order by DocumentID desc";
			DataGridList.DataSource=conn.getBinding(sql,"data"); 
			DataGridList.DataBind();		
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.imgbtnsearch.Click += new System.Web.UI.ImageClickEventHandler(this.imgbtnsearch_Click);
			this.DataGridList.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGridList_ItemCreated);
			this.DataGridList.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridList_DeleteCommand);
			this.DataGridList.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGridList_ItemDataBound);
			this.DataGridList.SelectedIndexChanged += new System.EventHandler(this.DataGridList_SelectedIndexChanged);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

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

		private void DataGridList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			if (e.Item .ItemType ==ListItemType.Item || e.Item .ItemType ==ListItemType.AlternatingItem )
			{
				string link="<a href=gwselecturl.aspx?documentid="+e.Item .Cells[1].Text+ " title=\""+e.Item .Cells[7].Text+"\">" ;
				if (e.Item .Cells[7].Text .Length >10 )
				{
					e.Item .Cells [0].Text =link+ e.Item .Cells[7].Text.Substring (0,10)+"...</a>"; 
				}
				else
				{
					e.Item .Cells [0].Text =link+ e.Item .Cells[7].Text +"</a>"; 
				}
			}
		}

		private void DataGridList_ItemDataBound_1(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
		
		}

		private void DataGridList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			if(e.CommandName=="Delete")
			{
				string PkId=e.Item.Cells[1].Text;
				if(PkId=="")
					return;
				else
				{
					string sql1="select * from receivewait where sendclass=0 and DocumentID="+PkId;
					int countt=Convert.ToInt32(conn.GetValueBySql(sql1));
					if (countt==0)
					{
						string sql11="select * from DocumentTransact where  DocumentID="+PkId;
						countt=Convert.ToInt32(conn.GetValueBySql(sql11));
						if (countt!=0)
						{
							string sql2="delete  from  DocumentTransact where DocumentID="+PkId;
							conn.ExecuteSQL(sql2);
						}
						string sql31="select * from receivewait where  DocumentID="+PkId;
						countt=Convert.ToInt32(conn.GetValueBySql(sql31));
						if (countt!=0)
						{
							string sql4="delete from receivewait   where DocumentID="+PkId;
							conn.ExecuteSQL(sql4);
						}
							string sql21="select * from documentsendr where DocumentID="+PkId;
						countt=Convert.ToInt32(conn.GetValueBySql(sql21));
						if (countt!=0)
						{
							string sql3="delete  from  documentsendr where DocumentID="+PkId;
							conn.ExecuteSQL(sql3);
						}


						string sql="delete from  Document where DocumentID="+PkId;
						conn.ExecuteSQL(sql);

						sql="delete from message  where modename in('回退公文','公文校核','签发管理','发文办理','收文办理') and id="+PkId;
					    conn.ExecuteSQL(sql);
						GetSignatureList();
					}
					else
					{
						Page.RegisterStartupScript("","<script>alert('你不能删除另存发送的公文!');</script>");
						return;
					}
				}
			}
		}

		private void DataGridList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void DataGridList_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
		{
			LinkButton lb=(LinkButton)e.Item.FindControl("Linkbutton1");
			if(lb!=null)
			{
				lb.Attributes["onclick"]="return confirm('你确认删除吗?');";
			}

			
		}

		private void imgbtnsearch_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			BindData();
		}
		private void BindData()
		{
			OI.DatabaseOper.DatabaseConnect oConn = new OI.DatabaseOper.DatabaseConnect();
			string szSql;
            
			szSql = "select * from Document  ";
			
			if (txtsearch.Text!="")
			{
				if(dstwhere.SelectedValue!="FileDate")
				{
					szSql+="  where  "+dstwhere.SelectedValue +" like '%"+ txtsearch.Text .Trim().Replace ("'","''")+"%'";
				}
				else
				{
					//string search_date="";
					int rmin;
					string delimstr="/-";
					char[] delimiter=delimstr.ToCharArray();
					string txt=txtsearch.Text.Trim();
                    string[] split=null;
						split=txt.Split(delimiter,3);
								rmin=split.Length;
									if(rmin==1)
									{
										szSql+="  where   DATEDIFF(year, filedate,'"+txtsearch.Text .Trim()+"')=0";
									}
									if(rmin==2)
									{
										szSql+="  where   DATEDIFF(month, filedate,'"+txtsearch.Text .Trim()+"/01')=0";
									}
									if(rmin==3)
									{
										szSql+="  where   DATEDIFF(day, filedate,'"+txtsearch.Text .Trim()+"')=0";
									}
				
				}
			
			} 
		 
			szSql+=" order by DocumentID desc";

			
			try
			{
				DataSet ds = oConn.getBinding(szSql,"Temp");
				DataGridList.DataSource = ds.Tables["Temp"].DefaultView;
				DataGridList.DataBind();
			}
			catch(Exception)
			{
				Response.Write ("<script>alert('输入的日期不正确!');window.location.href=window.location.href;</script>");
				return;
			}
				 
		}
	}
}

⌨️ 快捷键说明

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