taskadd.aspx.cs

来自「ASP.NET的一些开发实例,有论坛管理系统等」· CS 代码 · 共 121 行

CS
121
字号
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 WorkGroupManager.task
{
	/// <summary>
	/// Filter 的摘要说明。
	/// </summary>
	public class TaskAdd : WorkGroupManager.WebFormBase
	{
		protected System.Web.UI.WebControls.TextBox tbtime1;
		protected System.Web.UI.WebControls.TextBox tbtime2;
		protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
		protected System.Web.UI.WebControls.RangeValidator RangeValidator2;
		protected System.Web.UI.WebControls.TextBox tbAIRCRAFTNUM;
		protected System.Web.UI.WebControls.TextBox tbFLIGHTID;
		protected System.Web.UI.WebControls.TextBox tbName;
		protected System.Web.UI.WebControls.TextBox tbDate;
		protected System.Web.UI.WebControls.TextBox tbEndDate;
		protected System.Web.UI.WebControls.CheckBox cbShare;
		protected System.Web.UI.WebControls.TextBox tbContent;
		protected System.Web.UI.WebControls.TextBox tbRemark;
		protected System.Web.UI.WebControls.TextBox tbNO;
		protected System.Web.UI.WebControls.LinkButton datacheck;
		protected Task.TaskService ts=new Task.TaskService();
		protected System.Web.UI.WebControls.Label lbPromulgator;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.DropDownList ddlExecutor;
		protected Task.task task=new Task.task();
		protected User.UserService us=new User.UserService();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			this.VerifyPage();
			try
			{
				// 在此处放置用户代码以初始化页面
				if(!Page.IsPostBack)
				{
					//this.tbNO.Text=this.ts.CreateTaskNO("Acars");
					this.tbDate.Text=System.DateTime.Now.ToShortDateString();
					this.tbEndDate.Text=System.DateTime.Now.ToShortDateString();
					this.lbPromulgator.Text=Session["user"].ToString();
					string sqluser=this.us.selectSql(string.Format("身份='{0}'","0"));
					this.BindDropDownList(this.ddlExecutor,sqluser,"用户名","用户名");
				}
			}
			catch(Exception ex)
			{
				string str=ex.Message;
			}
		}

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

		}
		#endregion

		private void datacheck_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.task.tNo=this.tbNO.Text;
				this.task.tDate=DateTime.Parse(this.tbDate.Text);
				this.task.tContent=this.tbContent.Text;
				this.task.tExecutor=this.ddlExecutor.SelectedItem.Value;
				this.task.tPromulgator=this.lbPromulgator.Text;
				this.task.tName=this.tbName.Text;
				this.task.tEndDate=DateTime.Parse(this.tbEndDate.Text);
				this.task.tRemark=this.tbRemark.Text;
				this.task.tScan="0";
				if(this.cbShare.Checked==true)
					this.task.tShare="1";
				else
					this.task.tShare="0";
			
				if(this.ts.AddTask(this.task))
				{
					this.Return(this);	 
				}
				else	
				{
					//使用时将下面代码中的"MainModel_1.aspx"改到特定页面的打开页面的URL
					Response.Write("<script language=javascript>window.opener.location='../Error.aspx?errmsg=任务未能增加成功。';window.close();</script>");  
							
				}
			}
			catch(Exception ex)
			{
				this.BaseService.Write("任务添加。");
				this.BaseService.Write(ex.Message);
			}
		}
	}
}

⌨️ 快捷键说明

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