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

📄 login-moas0001.aspx.cs

📁 很具有学习参考价值的OA办公自动化系统,完整源码.OAde
💻 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 System.Data.SqlClient;

namespace MOAS
{
	/// <summary>
	/// login_MOAS0001 的摘要说明。
	/// </summary>
	public class login_MOAS0001 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Panel Panel1;
	
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面

			Page.RegisterStartupScript("focus", "<script language=javascript>document.getElementById('TextBox1').focus();</script>");    //定位TextBox1,或的焦点;
        
		}

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

		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			try
			{
			//作判断:社员番号不能为空,不能少于9位; 密码不能为空
				string[] strcmpn1={""+Label6.Text+"",""+TextBox1.Text+""};        //用字符串数组接受职员ID(Label6.Text="职员ID")的输入信息;
				string[] strcmpn2={""+Label5.Text+"",""+TextBox2.Text+""};        //用字符串数组接受职员密码(Label5.Text="职员密码")的输入信息;
				string[] strcmpn3={""+Label6.Text+"",""+TextBox1.Text+"",""+TextBox1.MaxLength+""};//用字符串数组接受职员ID(Label6.Text="职员ID")的输入信息,包括:label6.text,输入的值(作为要判断的条件),文本框的最大的输入值(maxlength)
			//调用Compare类,传入要判断的参数
				Compare cmp=new Compare();
				if(cmp.CompareNull(strcmpn1)==true&&cmp.CompareNull(strcmpn2)==true&&cmp.CompareNumber(strcmpn1)==true&&cmp.CompareLength(strcmpn3)==true)                    //判断表达式为true时,说明输入的不为空,社员id是9位数字;          
				{
						string strpw="'"+TextBox2.Text+"'";
						string strid="'"+TextBox1.Text+"'";
						string str1="select ID,NAME,PASSWORD from USERS WHERE PASSWORD="+strpw+" and id="+strid+" and status!='0'"; //根据输入的id和psw得到sql语句;    status!='0'说明没有辞职.
					//调用	CCoSearchFromDatabase类,得到二唯数组;
					   CCoSearchFromDatabase dsc=new CCoSearchFromDatabase();
						string[,] strArryInfo=dsc.getList(str1);
						if(strArryInfo!=null)         //string[,] strArryInfo 不为空时;说明数据中有该信息,且(status!='0')没有辞职
						{ 
							string strname=strArryInfo[0,1];  // 得到 检索得到的id(根据 select ID,NAME,PASSWORD from.....)
							string[] strArrayInfo={""+TextBox1.Text+"",""+strname+"",""+TextBox2.Text+""};  //把 ID,NAME,PASSWORD 存入字符串数组string[] strArrayInfo
							Session.Add("strArrayLoginInfo",strArrayInfo);     //把string[] strArrayInfo 值赋入session:strArrayLoginInfo中
//							CCoOptionFile m_FileRead=new CCoOptionFile ("/AppProConfig/connectionStr.txt",1);
//							if(strArryInfo[0,0]==""+m_FileRead.strLineText+"")
                         //判断是否输入是管理员进入;
							if(strArryInfo[0,0]=="000000101")
							{
								Response.Redirect("adminFram.htm",false);  //调用Admin主菜单;
							}
							else
							{
								Response.Redirect("userFram.htm",false);  // 调用user主菜单
							}
						}
						else
						{
							Page.RegisterStartupScript("startup","<script language='javascript'>alert('输入的社员密码不正确!请重新输入!');</script>");
						}
				}
			}
			catch(Exception ex) //  抛出异常处理画面
			{
				HttpContext.Current.Response.Redirect("ErrorMessage.aspx?message="+ex.Message+"");
			}
			
	}


		private void Button2_Click(object sender, System.EventArgs e)
		{
	      //清空输入.
			Label3.Text="";
			TextBox1.Text="";
			TextBox2.Text="";
		}

	}
}

⌨️ 快捷键说明

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