?? login.aspx.cs
字號:
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
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -