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

📄 save.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.PersonSend
{
	/// <summary>
	/// save 的摘要说明。
	/// </summary>
	public class save : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox TextBoxContent;
		protected System.Web.UI.WebControls.TextBox TextBoxTitle;
		protected System.Web.UI.WebControls.ImageButton ImageButtonsure;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.Label Message;
		protected System.Web.UI.HtmlControls.HtmlInputFile UpFile;
	
		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 )
			{
			}
		}

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

		}
		#endregion

		private void ImageButtonsure_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			string strTitle=TextBoxTitle.Text .Trim ().Replace ("'","’");
			string strContent=TextBoxContent.Text.Replace ("'","’");
			PersonSend.personDatum persondatum =new personDatum ();
			string upfilepath=persondatum.GetUpFilePath (UpFile.Value,UpFile.PostedFile );
			
			

			if(upfilepath=="false")
				upfilepath="";
			if(upfilepath=="TooBig,,,,,,,,,,,,,,,,,,")
			{
				//Page.RegisterStartupScript ("","<script>alert(\"文件太大,上传文件不能超过 8M !\")</script>");
			     Message.Text ="文件太大,上传文件不能超过 8M !";
				return;
			}
			try
			{
				persondatum.AddSaveDatum (strTitle,strContent,upfilepath,int.Parse (Session["userid"].ToString ()));
			Page.RegisterStartupScript  ("","<script>alert('保存成功!');window.location.href=window.location.href;</script>");

			}
			catch(Exception er)
			{
				Message.Text =er.Message ;
			}

		}
		
		private string UPFile()
		{
			string strFileNameT=UpFile.Value ;
			if(strFileNameT.Trim ()=="")
			{
				return "";
			}
			HttpPostedFile upfiles=UpFile.PostedFile ;	
			if(upfiles.ContentLength >8388608)//上传文件8M限制
				return "TooBig,,,,,,,,,,,,,,,,,,";
			if (upfiles.ContentLength >0)
			{
				string fileName;
				string path =Server.MapPath(OI.Modules.Config.GetSetting("documents")); //reportAccessories
				try
				{
					
					fileName=OI.Modules.FileName.NewFileName(upfiles.FileName);
					upfiles.SaveAs (path+"\\"+fileName) ;
				}
				catch
				{
					fileName="false";
				
					
				}
				return fileName;
			}
			else
			{
				return "";
			}
		}
	}
}

⌨️ 快捷键说明

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