?? default.aspx.cs
字號:
using System;
using WebBase;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
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.Web.Security;
namespace TextileManager
{
public partial class Default : WebBase.GsDataPage
{
protected void Page_Load(object sender, System.EventArgs e){
if (!IsPostBack) {
TextBoxUserName.Text="Emily"; TextBoxPassword.Text="emily";
ButtonConfirm_Click(null,null);
}
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
}
#endregion
protected void ButtonConfirm_Click(object sender, System.EventArgs e) {
Db.DataSource="GS1"; string password=TextBoxPassword.Text;
Gbl.MainPage=this; Db.InitialCatalog="Textile";
#if DEBUG
if (password=="" && TextBoxUserName.Text=="Emily") password="emily";
#endif
Db.CreateConnection(TextBoxUserName.Text.Trim(),password);
if (Db.OpenCnn()) {
FormsAuthentication.RedirectFromLoginPage(TextBoxUserName.Text.Trim(),false);//告訴應用程序該用戶已經通過證書檢驗
string sql="SELECT 姓名,部門 FROM 員工表 WHERE 代碼='"+TextBoxUserName.Text+"'";
SqlDataReader dr=WebBase.Sql.RunReader(sql);
if (!dr.Read()) {
Gbl.ShowErrorMsg("非本單位員工,登陸失敗!");
dr.Close(); Db.CloseCnn(); return;
}
Session["UserName"]=Db.CaoZuoYuan=dr["姓名"].ToString();
Session["Department"]=dr["部門"].ToString();
//Session["Purview"]=dr["權限"].ToString();
dr.Close(); Db.CaoZuoYuanGroup=0; Db.CaoZuoYuanCode=TextBoxUserName.Text;
dr=Sql.RunReader("EXEC sp_helpuser '"+Session["UserName"]+"'");
while (dr.Read()) {
switch ((string)dr["GroupName"]) {
case "db_owner": Db.CaoZuoYuanGroup|=Qx.管理員組; Db.CaoZuoYuanQuanXianFix|=Qx.管理權限; break;
case "完全權限組": Db.CaoZuoYuanGroup|=Qx.完全權限組; Db.CaoZuoYuanQuanXianFix|=Qx.完全權限; break;
case "財務組": Db.CaoZuoYuanGroup|=Qx.財務組; Db.CaoZuoYuanQuanXianFix|=Qx.財務權限; break;
case "業務組": Db.CaoZuoYuanGroup|=Qx.業務組; Db.CaoZuoYuanQuanXianFix|=Qx.業務權限; break;
case "操作員組": Db.CaoZuoYuanGroup|=Qx.操作員組; Db.CaoZuoYuanQuanXianFix|=Qx.操作權限; break;
case "查詢組": Db.CaoZuoYuanGroup|=Qx.查詢組; Db.CaoZuoYuanQuanXianFix|=Qx.查詢權限; break;
}
} dr.Close();
Response.Redirect("SystemPage.aspx");
}
else
Gbl.ShowErrorMsg("密碼或用戶名錯誤!");
//Response.Redirect("ErrorPage.aspx?ErrorText='密碼或用戶名錯誤'");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -