login.aspx.cs
上传用户:autodoor
上传日期:2022-08-04
资源大小:9973k
文件大小:4k
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.Security;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using qminoa.DA;
- namespace qminoa.Webs
- {
- public class login : System.Web.UI.Page
- {
- private string invalidLogin = string.Empty;
- protected System.Web.UI.WebControls.RequiredFieldValidator LoginIDRequiredFieldValidator;
- protected System.Web.UI.WebControls.TextBox password;
- protected System.Web.UI.WebControls.RequiredFieldValidator LoginPasswordRequiredFieldValidator;
- protected System.Web.UI.WebControls.ValidationSummary LogonValidationSummary;
- protected System.Web.UI.WebControls.TextBox username;
- protected System.Web.UI.WebControls.Button btnlogin;
- private void Page_Load(object sender, System.EventArgs e)
- {
- }
- private void btnlogin_Click(object sender, System.EventArgs e)
- {
- EmpDB AloginUsr=new EmpDB();
- String strLoginID= username.Text .Trim ();
- String strPassword =password.Text .Trim ();
- string strReason;
- string strUserID;
- string strValid;
- string[] NewLogin;
- String[] strLoginflag =AloginUsr.Login (strLoginID,strPassword);
- if(strLoginflag[0]=="usererror"||strLoginflag[0]=="pwderror"||strLoginflag[0]=="noacount")
- {
- strUserID = username.Text .Trim ();
- strValid= "否";
- strReason=strLoginflag[1];
- NewLogin=new string []
- {
- strUserID,
- DateTime.Now .ToString (),
- strValid,
- "",
- Request.UserHostAddress .ToString (),
- strReason
- };
- DbManagerLogininfo myclassfologin=new DbManagerLogininfo ();
- myclassfologin.insertLoginUser (NewLogin);
- Response.Write("<script language=javascript>");
- Response.Write("window.alert('");
- Response.Write(strReason);
- Response.Write("');");
- Response.Write("</script>");
- }
- else
- {
- Response.Cookies["empint"].Value=username.Text;
- Response.Cookies["empint"].Expires=DateTime.Now.AddDays(1);
- strUserID=username.Text .Trim ();
- strValid="是";
- strReason="";
- strReason=strLoginflag[1];
- NewLogin=new string []
- {
- strUserID,
- DateTime.Now .ToString (),
- strValid,
- "",
- Request.UserHostAddress .ToString (),
- strReason
- };
- DbManagerLogininfo myclassfologin=new DbManagerLogininfo ();
- myclassfologin.insertLoginUser (NewLogin);
- Session["EmpID"]=Int32.Parse(strLoginflag[0]);
- Session["username"]=username.Text;
- string tt="qminoa = window.open('"+Request.ApplicationPath+"/index.aspx"+"'"
- +",'','toolbar=no,menubar=no,titlebar=yes,directories=no,resizable=yes,status=yes,fullscreen=no,top=0;left=0,width=900,height=700');";
- Response.Write("<script language=javascript>");
- Response.Write(tt);
- Response.Write("qminoa.moveTo(0,0);");
- Response.Write("qminoa.resizeTo(screen.availWidth,screen.availHeight);");
- Response.Write("window.opener=null;");
- Response.Write("window.close();");
- Response.Write("</script>");
- }
- }
- #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.btnlogin.Click += new System.EventHandler(this.btnlogin_Click);
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }