Пример #1
0
        protected void Btn_save_Click(object sender, EventArgs e)
        {
            sr_User users = new sr_User();
            string UserID = Session["UserID"].ToString();
            string UserName = TB_UserName.Text.ToString().Trim();
            string Sex = DropDL_Sex.SelectedValue;
            string Unit = TB_Unit.SelectedValue;
            string Education = DropDL_Degree.SelectedValue;
            string ZhiCheng = TB_ZhiCheng.SelectedValue;

            string Telephone = TB_Telephone.Text.ToString().Trim();
            string InOffice = DropDL_Job.SelectedIndex.ToString();//...
            string Email = TB_Email.Text.ToString().Trim();

            if (users.UpdateGeRenXinXi(UserName, Sex, Unit, Education, ZhiCheng, Telephone, InOffice, Email, UserID))
            {
                Response.Write("<script>alert('信息更新成功')</script>");
                users.UpdateLogins(UserID);             //更新登录次数
            }
            else
            {
                Response.Write("<script>alert('信息更新失败')</script>");
                return;
            }

            Session["UserName"] = users.GetUserName(Session["UserID"].ToString()); //完善完信息后再将UserName保存到session
            string Role = Session["Role"].ToString();      //完善完信息后再根据角色跳到不通的页面。
            Session["Unit"] = users.GetUserUnit(Session["UserID"].ToString());
            switch (Role)
            {
                case "教师":
                    Response.Redirect("../Teacher.aspx");
                    break;
                case "管理员":
                    Response.Redirect("../Secretary.aspx");
                    break;
                case "系统管理员":
                    Response.Redirect("../KeYuan.aspx");
                    break;
                case "超级管理员":
                    Response.Redirect("../Chief.aspx");
                    break;
                default:
                    break;
            }
        }
Пример #2
0
        protected void login1_Click(object sender, ImageClickEventArgs e)
        {
            string UserID = "", temppwd = "", Role = "";
            UserID = user.Text.Trim().ToString();
            temppwd = password.Text.Trim().ToString();
            string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(temppwd, "MD5");
            Role = chknumber.SelectedValue;

            sr_User users = new sr_User();

            //if (UserID == "")
            //{
            //    //Response.Write("<script>alert('用户名不能为空')</script>");
            //    user.Focus();
            //    return;
            //}
            //else if (temppwd == "")
            //{
            //    Response.Write("<script>alert('密码不能为空')</script>");
            //    password.Focus();
            //    return;
            //}
            if (!users.Exists(UserID))
            {
                Response.Write("<script>alert('不存在此用户')</script>");
                return;
            }
            if (!users.isExistUser(UserID, pwd, Role) )
            {
                Response.Write("<script>alert('密码或角色错误')</script>");
                return;
            }
            if (!users.StatusIsTrue(UserID))
            {
                Response.Write("<script>alert('此用户已被屏蔽')</script>");
                return;
            }
            else//如果可以登录进去
            {
                Session["UserID"] = UserID;
                Session["UserName"] = users.GetUserName(UserID);
                Session["Role"] = Role;
                Session["Unit"] = users.GetUserUnit(UserID);
                int LoginTimes;
                LoginTimes = users.GetLogins(UserID);   //得到登录次数

                if (LoginTimes == 0)                    //如果是第一次登录
                {
                    Response.Write(" <script> alert( '你首次登陆,请先完善信息');location.href= 'YongHuGuanLi/WanShanXinXi.aspx'; </script> ");

                }
                else
                {

                    switch (Role)
                    {
                        case "教师":
                            Response.Redirect("Teacher.aspx");
                            break;
                        case "管理员":
                            Response.Redirect("Secretary.aspx");
                            break;
                        case "系统管理员":
                            Response.Redirect("KeYuan.aspx");
                            break;
                        case "超级管理员":
                            Response.Redirect("Chief.aspx");
                            break;
                        default:
                            break;
                    }
                }
            }
            //else
            //{
            //    Response.Write("<script>alert('不存在此用户或此用户不合法')</script>");
            //    user.Text = "";
            //    password.Text = "";
            //    user.Focus();
            //    return;
            //}
        }