为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

登陆页面

2017-09-25 10页 doc 28KB 32阅读

用户头像

is_358746

暂无简介

举报
登陆页面登陆页面 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using CXES.Model; using CXES.BLL; public partial class Main : System.Web.UI.MasterPage { pri...
登陆页面
登陆页面 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using CXES.Model; using CXES.BLL; public partial class Main : System.Web.UI.MasterPage { private string msg = ""; private List functions; private readonly string LoginURL = "LoginPage.aspx"; private readonly string SessionUserInfo = "SessionUserInfo"; private readonly string SessionUserType = "SessionUserType"; private DictionaryManager dicManager = new DictionaryManager(); private SystemUsersManager suManager = new SystemUsersManager(); private SystemParametersManager spManager = new SystemParametersManager(); private FunctionsManager funcManager = new FunctionsManager(); private AdminsManager adminsManager = new AdminsManager(); protected void Page_Load(object sender, EventArgs e) { bool haveSession = HaveSession(); if (haveSession) { if (!CheckSystemIsOpen()) { int type = Convert.ToInt32(Session[SessionUserType]); if (type != 92) { Page.ClientScript.RegisterStartupScript(this.GetType(), "it", ""); foreach (System.Web.UI.Control objControl in this.Controls) { if (objControl is System.Web.UI.HtmlControls.HtmlForm) { foreach (System.Web.UI.Control objHtmlControl in objControl.Controls) { System.Web.UI.WebControls.WebControl objWebCon; objWebCon = objHtmlControl as WebControl; if (objWebCon != null) { objWebCon.Enabled = false; } } } } return; } } } if (!IsPostBack) { UpdateDLL(); if (!haveSession) { this.txtLoginId.Enabled = true; this.txtLoginPWD.Enabled = true; this.btnLogin.Enabled = true; this.ddlUserType.Enabled = true; //this.btnReset.Enabled = false; this.btnReset.Visible = false; if (Request.Url.ToString().Substring(Request.Url.ToString().LastIndex Of('/') + 1) != LoginURL) { Response.Redirect(LoginURL); } return; } this.txtLoginId.Enabled = false; this.txtLoginPWD.Enabled = false; this.btnLogin.Enabled = false; this.ddlUserType.Enabled = false; //this.txtLoginId.Visible = false; //this.txtLoginPWD.Visible = false; //this.btnLogin.Visible = false; //this.btnReset.Enabled = true; int userType = Convert.ToInt32(Session[SessionUserType]); if (userType!=92) { SystemUsersInfo user = Session[SessionUserInfo] as SystemUsersInfo; this.ltUserInfo.Text = user == null ? "Î?µÇÂ?" : user.LoginId; this.ddlUserType.SelectedValue = userType.ToString(); } else { AdminsInfo admin = Session[SessionUserInfo] as AdminsInfo; this.ltUserInfo.Text = admin == null ? "Î?µÇÂ?" : admin.LoginId; this.ddlUserType.SelectedValue = userType.ToString(); } UpdateTree(); } } #region ??Öú???? private bool CheckSystemIsOpen() { return spManager.CheckSystemIsOpen(); } private bool HaveSession() { return Session[SessionUserInfo] == null || Session[SessionUserType] == null ? false : true; } private void UpdateDLL() { List dics = dicManager.GetDictionaryInfoByGroupName("UserType"); this.ddlUserType.DataSource = dics; this.ddlUserType.DataTextField = "Content"; this.ddlUserType.DataValueField = "DicId"; this.ddlUserType.DataBind(); } private bool CheckLogin(SystemUsersInfo user) { return suManager.CheckLogin(user, ref msg); } private void UpdateTree() { int userType = Convert.ToInt32(Session[SessionUserType]); if (userType == 92) { functions = funcManager.GetAllInfo(); UpdateNodes(); } else { SystemUsersInfo user = Session[SessionUserInfo] as SystemUsersInfo; if (user != null) { functions = funcManager.GetFunctionsByLoginId(user.LoginId); UpdateNodes(); } } } private void UpdateNodes() { foreach (FunctionsInfo item in functions.Where(p => p.FId == 0)) { TreeNode father = new TreeNode(); father.Value = item.FunctionId.ToString(); father.Text = item.Describe; father.NavigateUrl = item.URL; UpdateChildNodes(father); this.tvPower.Nodes.Add(father); } } private void UpdateChildNodes(TreeNode father) { foreach (FunctionsInfo item in functions.Where(p => p.FId == Convert.ToInt32(father.Value))) { TreeNode child = new TreeNode(); child.Value = item.FunctionId.ToString(); child.Text = item.Describe; child.NavigateUrl = item.URL; UpdateChildNodes(child); father.ChildNodes.Add(child); } } #endregion protected void btnLogin_Click(object sender, EventArgs e) { if (this.txtLoginId.Text.Trim() == "" || this.txtLoginPWD.Text == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "it", ""); return; } if (Convert.ToInt32(this.ddlUserType.SelectedValue)!=92) { SystemUsersInfo user = new SystemUsersInfo(); user.LoginId = this.txtLoginId.Text.Trim(); user.LoginPWD = this.txtLoginPWD.Text; user.UserType = Convert.ToInt32(this.ddlUserType.SelectedValue); if (!CheckLogin(user)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "it", string.Format("", msg)); return; } else { user.LastLoginTime = System.DateTime.Now; user.State = 91; suManager.Update_State_LastLoginTime(user); Session[SessionUserInfo] = user; Session[SessionUserType] = user.UserType; Response.Redirect("MainPage.aspx"); } } else { AdminsInfo admin=new AdminsInfo(); admin.LoginId=this.txtLoginId.Text.Trim(); admin.LoginPWD=this.txtLoginPWD.Text; if (!adminsManager.CheckLogin(admin,ref msg)) { Page.ClientScript.RegisterStartupScript(this.GetType(), "it", string.Format("", msg)); return; } else { Session[SessionUserInfo] = admin; Session[SessionUserType] = this.ddlUserType.SelectedValue; Response.Redirect("MainPage.aspx"); } } } protected void btnReset_Click(object sender, EventArgs e) { Session[SessionUserInfo] = null; Session[SessionUserType] = null; this.tvPower.Nodes.Clear(); Response.Redirect("LoginPage.aspx"); } }
/
本文档为【登陆页面】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索