private void AddUserInfo(HttpContext context)
        {
            BLL.UserInfo bll      = new BLL.UserInfo();
            string       UserName = context.Request["U_username"];
            int          ExistRes = bll.Exist(string.Format("U_username='******'", UserName));

            if (ExistRes > 0)
            {
                context.Response.Write("exist");
                return;
            }
            Model.UserInfo model = new Model.UserInfo();
            model.U_username   = UserName;
            model.U_password   = model.U_username;
            model.U_power      = context.Request["U_power"];
            model.U_nickname   = context.Request["U_nickname"];
            model.U_mailbox    = context.Request["U_mailbox"];
            model.U_Role       = context.Request["U_Role"];
            model.U_Comments   = context.Request["U_Comments"];
            model.U_CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.U_IsDelete   = 0;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("success");
            }
            else
            {
                context.Response.Write("fail");
            }
        }
 public static Com.DataPack.DataRsp <string> page(string PageIndex, string PageSize, string uname, string ustat)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     try
     {
         BLL.UserInfo user_bll            = new BLL.UserInfo();
         Com.DataPack.PageModelResp pages = new Com.DataPack.PageModelResp();
         pages.PageIndex = int.Parse(PageIndex);
         pages.PageSize  = int.Parse(PageSize);
         int rowc = 0; int pc = 0;
         // ,DepartId,Address,HeadImg,inssj,udsj
         string    cols   = "UserId,UserName,Name,Status,Email,inssj";
         DataTable userdt = user_bll.GetListCols(cols, "1=1", "UserId", "", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0];
         pages.PageCount = pc;
         pages.RowCount  = rowc;
         if (userdt.Rows.Count > 0)
         {
             pages.list = userdt;
         }
         rsp.data = Newtonsoft.Json.JsonConvert.SerializeObject(pages).Replace("\n\r", "");
     }
     catch (Exception ex)
     {
         throw;
     }
     return(rsp);
 }
        private void UpdateUserInfo(HttpContext context)
        {
            BLL.UserInfo bll      = new BLL.UserInfo();
            string       UserName = context.Request["U_username"];
            string       ID       = context.Request["U_ID"];
            int          ExistRes = bll.Exist(string.Format("U_username='******' and U_ID not in ({1})", UserName, ID));

            if (ExistRes > 0)
            {
                context.Response.Write("exist");
                return;
            }
            Model.UserInfo model = new Model.UserInfo();
            model.U_ID       = Convert.ToInt32(ID);
            model.U_username = UserName;
            model.U_power    = context.Request["U_power"];
            model.U_nickname = context.Request["U_nickname"];
            model.U_mailbox  = context.Request["U_mailbox"];
            model.U_Role     = context.Request["U_Role"];
            model.U_Comments = context.Request["U_Comments"];
            if (bll.Update(model))
            {
                context.Response.Write("success");
            }
            else
            {
                context.Response.Write("fail");
            }
        }
Beispiel #4
0
        protected void btn_Login_Click(object sender, EventArgs e)
        {
            string strUserName = this.txt_username.Value.Trim();
            string strPassword = this.txt_password.Value.Trim();

            if (string.IsNullOrEmpty(strUserName) || string.IsNullOrEmpty(strPassword))
            {
                Response.Write("<script>alert('Please Input Username or Password !');location.href='Login.aspx'</script>");
            }
            else
            {
                BLL.UserInfo bll = new BLL.UserInfo();
                DataSet      ds  = bll.Login(strUserName, strPassword);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    Session["User_ID"]       = dr["U_ID"];
                    Session["User_UserName"] = dr["U_nickname"];
                    Session["User_Power"]    = dr["U_power"];

                    Response.Redirect("DashBoard.aspx");
                }
                else
                {
                    Response.Write("<script>alert('Username or Password Incorrect !');location.href='Login.aspx'</script>");
                }
            }
        }
        //[ValidateAntiForgeryToken]
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (Request.Params["username"] != null && Request.Params["username"].Trim() != "")
            {
                int Id = Convert.ToInt32(Request.Params["username"]);
                string pwd = Request.Params["password"];
                BLL.UserInfo bll = new BLL.UserInfo();
                if (bll.GetRecordCount("Uid=" + Id.ToString() + " and Pwd='" + pwd + "'") == 1)
                {
                    return Redirect("/MyCenter/Index");
                }
            }
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string userName = context.Request["userName"];
            string pwd      = context.Request["password"];

            //从数据库读取用户密码验证
            BLL.UserInfo UserInfoObject = new BLL.UserInfo();


            if (UserInfoObject.Exists(userName, pwd) == true)
            {
                //将账号密码写入coockie
                context.Response.Cookies["UserName"].Value   = userName;
                context.Response.Cookies["pwd"].Value        = pwd;
                context.Response.Cookies["IsLogin"].Value    = "OK";
                context.Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(1);
                context.Response.Cookies["pwd"].Expires      = DateTime.Now.AddDays(1);
                context.Response.Cookies["IsLogin"].Expires  = DateTime.Now.AddDays(1);

                context.Response.Write("ok");
                context.Response.End();
            }
            else
            {
                context.Response.Write("登陆失败,请检查用户名或密码");
                context.Response.End();
            }
        }
Beispiel #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     string userName = textBox1.Text.Trim();
     string password = textBox2.Text.Trim();
     if (userName == "" || password == "")
     {
         MessageBox.Show("用户名或密码不能为空!");
         textBox1.Focus();
         return;
     }
     else
     {
         BLL.UserInfo user = new BLL.UserInfo();
         if (user.Login(userName, password))
         {   
             UserHelper.userName = textBox1.Text.Trim();
             UserHelper.password = textBox2.Text.Trim();
             this.Hide();
             scheduleUI f;
             f = new scheduleUI();
             f.Show();
         }
         else
         {
             MessageBox.Show("用户名或密码错误,请重新输入!", "错误");
             textBox1.Text = "";
             textBox2.Text = "";
             textBox1.Focus();
         }
     }
 }
 public ActionResult Info()
 {
     int Tid = Convert.ToInt32(HttpContext.Session["userid"]);
     Danyl.SnnuURP.Model.Teacher teacher = new BLL.Teacher().GetModel(Tid);
     try
     {
         Danyl.SnnuURP.Model.Depart depart = new BLL.Depart().GetModel(teacher.DeptId);
         Danyl.SnnuURP.Model.TeacherType TType = new BLL.TeacherType().GetModel(teacher.TeacherTypeId);
         Danyl.SnnuURP.Model.UserInfo userInfo = new BLL.UserInfo().GetModel(Tid);
         ViewBag.Tid = teacher.Tid;
         ViewBag.Tname = teacher.Tname;
         ViewBag.Sex = teacher.Sex ? '男' : '女';
         ViewBag.IdNumber = teacher.IdNumber;
         ViewBag.Depart = depart.DeptName;
         ViewBag.Degree = teacher.Degree;
         ViewBag.TeacherType = TType.TeacherTypes;
         ViewBag.Phone = userInfo.UserPhone;
         ViewBag.Email = userInfo.UserEmail;
         return View(ViewBag);
     }
     catch (Exception ex)
     {
         return Redirect("~/Teacher/Account/Login");
     }
 }
        private void UpdateDynamicJSUserInfo(HttpContext context)
        {
            BLL.UserInfo             bll  = new BLL.UserInfo();
            DataSet                  ds   = bll.GetList("");
            List <Model.UserForJson> list = new List <Model.UserForJson>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Model.UserForJson()
                {
                    U_ID       = Convert.ToInt32(dr["U_ID"]),
                    U_nickname = dr["U_nickname"].ToString()
                });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            //string strJson = string.Format("{{\"rows\":{0}}}", jss.Serialize(list));
            string strJson = jss.Serialize(list);

            try
            {
                //File.WriteAllText(WMSys.Common.PathHelper.ServerPath+"\\jsonData\\UserInfo.json", strJson);
                string   DynamicJSPath    = WMSys.Common.PathHelper.ServerPath + "\\DynamicJS\\TagsInputUserData.js";
                string[] DynamicJSContent = File.ReadAllLines(DynamicJSPath);
                DynamicJSContent[0] = string.Format("var JsonData = '{0}'", strJson);
                File.WriteAllLines(DynamicJSPath, DynamicJSContent);
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                context.Response.Write("fail");
            }
        }
Beispiel #10
0
        void DataBind()//定义一个函数用于绑定数据到DataGridView
        {
            BLL.UserInfo bll = new BLL.UserInfo();
            DataSet      ds  = new DataSet();

            ds = bll.GetList();
            dataGridView2.DataSource = ds.Tables[0];
        }
        private void ChangePassword(HttpContext context)
        {
            int    U_ID        = Convert.ToInt32(context.Request["U_ID"]);
            string oldPassword = context.Request["oldPassword"];
            string NewPassword = context.Request["NewPassword"];

            BLL.UserInfo bll = new BLL.UserInfo();
            context.Response.Write(bll.ChangePassword(U_ID, oldPassword, NewPassword));
        }
Beispiel #12
0
        public string GetNameByUserInfoID(int UserInfoID)
        {
            string Name = "";

            BLL.UserInfo   BUserInfo = new BLL.UserInfo();
            Model.UserInfo MUserInfo = new Model.UserInfo();
            MUserInfo = BUserInfo.GetModel(UserInfoID);
            if (MUserInfo != null)
            {
                Name = MUserInfo.TrueName;
            }
            return(Name);
        }
        /// <summary>
        /// 执行策略
        /// </summary>
        public override void DoWork <T>(T context)
        {
            var userInfoContext = context as XCLCMS.Data.BLL.Strategy.UserInfo.UserInfoContext;

            if (null == userInfoContext.UserInfo)
            {
                return;
            }

            bool flag = false;

            XCLCMS.Data.BLL.UserInfo bll = new BLL.UserInfo();

            try
            {
                switch (userInfoContext.HandleType)
                {
                case StrategyLib.HandleType.ADD:
                    userInfoContext.UserInfo.CreaterID   = userInfoContext.ContextInfo.UserInfoID;
                    userInfoContext.UserInfo.CreaterName = userInfoContext.ContextInfo.UserName;
                    userInfoContext.UserInfo.CreateTime  = DateTime.Now;
                    userInfoContext.UserInfo.UpdaterID   = userInfoContext.UserInfo.CreaterID;
                    userInfoContext.UserInfo.UpdaterName = userInfoContext.UserInfo.CreaterName;
                    userInfoContext.UserInfo.UpdateTime  = userInfoContext.UserInfo.CreateTime;
                    flag = bll.Add(userInfoContext.UserInfo);
                    break;

                case StrategyLib.HandleType.UPDATE:
                    userInfoContext.UserInfo.UpdaterID   = userInfoContext.ContextInfo.UserInfoID;
                    userInfoContext.UserInfo.UpdaterName = userInfoContext.ContextInfo.UserName;
                    userInfoContext.UserInfo.UpdateTime  = DateTime.Now;
                    flag = bll.Update(userInfoContext.UserInfo);
                    break;
                }
            }
            catch (Exception ex)
            {
                flag = false;
                this.ResultMessage += string.Format("异常信息:{0}", ex.Message);
            }

            if (flag)
            {
                this.Result = StrategyLib.ResultEnum.SUCCESS;
            }
            else
            {
                this.Result        = StrategyLib.ResultEnum.FAIL;
                this.ResultMessage = string.Format("保存用户基础信息失败!{0}", this.ResultMessage);
            }
        }
        private void DeleteUserInfo(HttpContext context)
        {
            BLL.UserInfo bll  = new BLL.UserInfo();
            int          U_ID = Convert.ToInt32(context.Request["U_ID"]);

            if (bll.Delete(U_ID))
            {
                context.Response.Write("success");
            }
            else
            {
                context.Response.Write("fail");
            }
        }
Beispiel #15
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == "" || txtUserPassword.Text == "" || cboUserType.Text == "")
            {
                MessageBox.Show("请将信息添加完整!");
                return;
            }
            Model.UserInfo model = new Model.UserInfo();//实例化model层
            model.UserName     = txtUserName.Text.Trim();
            model.UserPassword = txtUserPassword.Text.Trim();
            model.UserType     = cboUserType.Text.Trim();
            BLL.UserInfo bll = new BLL.UserInfo();//实例化BLL层
            model = bll.ToMD5(model);
            switch (flag)
            {
            case 0:
            {
            } break;

            case 1:
            {
                if (bll.Add(model))    //将员工信息添加到数据库中,根据返回值判断是否添加成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
            } break;

            case 2:
            {
                if (bll.Update(model)) //根据返回布尔值判断是否修改数据成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    txtUserName.ReadOnly = false;
                    ControlStatus();
                }
            } break;

            case 3:
            {
                if (bll.Delete(model)) //根据返回布尔值判断是否删除数据成功
                {
                    DataBind();        //窗体登录时绑定数据到DataGridView
                    ControlStatus();
                }
            } break;
            }
        }
Beispiel #16
0
        public void ProcessRequest(HttpContext context)
        {
            BLL.UserInfo UserInfoService = new BLL.UserInfo();

            context.Response.ContentType = "text/plain";
            string userName   = context.Request["userName"];
            string pwd        = context.Request["password"];
            string confirmPwd = context.Request["password_confirmation"];
            string Guid_Code  = context.Request["Guid_Code"];

            if (UserInfoService.Exists(Guid_Code) == false)
            {
                context.Response.Write("邀请码不正确,请QQ联系 1443742816 , 2101300125 获取邀请码!");
                context.Response.End();
            }
            else if (pwd != confirmPwd)
            {
                context.Response.Write("输入的两次密码不一致!");
                context.Response.End();
            }
            else if (pwd == "" || userName == "")
            {
                context.Response.Write("账号或密码不能为空!");
                context.Response.End();
            }
            else
            {
                Model.UserInfo UserinfoModal = new Model.UserInfo();
                UserinfoModal.UserId       = userName;
                UserinfoModal.UserPassword = pwd;
                if (UserInfoService.Add(UserinfoModal) == 0 || UserInfoService.Delete(Guid_Code))
                {
                    context.Response.Write("ok");
                }

                else
                {
                    context.Response.Write("注册失败!");
                }
                context.Response.End();
            }
        }
Beispiel #17
0
        public ActionResult Login(Osiris.CloudWeb.Models.UserInfo user)
        {
            string uName     = user.UserName.Trim();
            string uPassword = Commons.Get_MD5(user.Password.Trim());

            Osiris.BLL.UserInfo bll = new BLL.UserInfo();
            string r = bll.CheckUserInfo(uName, uPassword);

            if (r.Equals("success"))
            {
                Session["UserName"] = uName;
                Session["Eare"]     = "上海市";
                return(Redirect("/home/index"));
            }
            else
            {
                // var scripts = string.Format("alert('{0}');", r);
                // return Content(string.Format("<script>alert('{0}');</script>", r));
                Response.Write(string.Format("<script>alert('{0}');</script>", r));
                return(View("login"));
            }
        }
        //private void LoginReturnUserInfo(HttpContext context)
        //{

        //}

        private void GetUserInfoSingle(HttpContext context)
        {
            BLL.UserInfo          bll  = new BLL.UserInfo();
            DataSet               ds   = bll.GetList(" U_ID=" + context.Request["U_ID"]);
            DataRow               dr   = ds.Tables[0].Rows[0];
            List <Model.UserInfo> list = new List <Model.UserInfo>();

            list.Add(new Model.UserInfo()
            {
                U_username     = dr["U_username"].ToString(),
                U_PowerDisplay = ChangePowerToDisplay(dr["U_power"].ToString()),
                U_power        = dr["U_power"].ToString(),
                U_nickname     = dr["U_nickname"].ToString(),
                U_mailbox      = dr["U_mailbox"].ToString(),
                U_Role         = dr["U_Role"].ToString(),
                U_Comments     = dr["U_Comments"].ToString()
            });
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string strJson           = jss.Serialize(list).TrimStart('[').TrimEnd(']');

            context.Response.Write(strJson);
        }
Beispiel #19
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            Model.UserInfo model = new Model.UserInfo();//实例化Model层
            model.UserName     = txtUserName.Text.Trim();
            model.UserPassword = txtPassword.Text.Trim();
            BLL.UserInfo bll = new BLL.UserInfo(); //实例化BLL层
            model = bll.ToMD5(model);
            DataSet ds = new DataSet();            //定义DataSet对象

            ds = bll.GetList(model);               //调用BLL层中的GetList方法,返还DataSet对象
            if (ds.Tables[0].Rows.Count > 0)
            {
                Main main = new Main();
                main.Type = ds.Tables[0].Rows[0]["用户类别"].ToString();
                main.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("用户名或者密码输入错误!");
            }
        }
Beispiel #20
0
        private void txtOK_Click(object sender, EventArgs e)
        {
            string strSelect = this.cbxCondition.Text.Trim();

            if (strSelect == "")
            {
                MessageBox.Show("请选择查询条件!");
                return;
            }
            if (this.txtKeyWord.Text == "")
            {
                MessageBox.Show("输入查询条件!");
                return;
            }
            string strWhere = "1=1";
            string userName = txtKeyWord.Text;
            string userType = txtKeyWord.Text;

            switch (strSelect)
            {
            case "用户账号":
            {
                strWhere = strWhere + " and UserName like '%" + userName + "%' ";
            }
            break;

            case "用户类型":
            {
                strWhere = strWhere + " and UserType =  '" + userType + "'";
            }
            break;
            }
            BLL.UserInfo bll = new BLL.UserInfo(); //实例化BLL层
            DataSet      ds  = new DataSet();

            ds = bll.GetList(strWhere);              //执行带参数SQL语句,将结果存在ds中
            dataGridView2.DataSource = ds.Tables[0]; //将ds中的表作为DataGridView的数据源
        }
        //[ValidateAntiForgeryToken]
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (Request.Params["username"] != null && Request.Params["username"].Trim() != "")
            {
                string Uid = Request.Params["username"];
                string pwd = Request.Params["password"];
                List<Danyl.SnnuURP.Model.UserInfo> userInfolist = new BLL.UserInfo().GetModelList("Uid=" + Uid + " and Pwd='" + pwd + "'");
                if (userInfolist.Count==1)
                {
                    Danyl.SnnuURP.Model.UserInfo userInfo = userInfolist.FirstOrDefault<Danyl.SnnuURP.Model.UserInfo>();
                    this.HttpContext.Session["userid"] = userInfo.Uid;
                    this.HttpContext.Session["username"] = userInfo.Uname;
                    return Redirect("../MyInfo/Index");
                }
            }
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            switch (result)
            {
                case SignInStatus.Success:
                    return RedirectToLocal(returnUrl);
                case SignInStatus.LockedOut:
                    return View("Lockout");
                case SignInStatus.RequiresVerification:
                    return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                case SignInStatus.Failure:
                default:
                    ModelState.AddModelError("", "Invalid login attempt.");
                    return View(model);
            }
        }
Beispiel #22
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空!", "Error");
                return;
            }
            if (textBox2.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空!", "Error");
                return;
            }
            string user = textBox1.Text.Trim();
            string pass = textBox2.Text.Trim();
            Model.UserInfo adduser = new Model.UserInfo();
            adduser.UserName = user;
            adduser.Password = pass;
            BLL.UserInfo insectuser = new BLL.UserInfo();

            if (insectuser.AddUserInfoList(adduser))
            {
                MessageBox.Show("注册成功!");
                this.Hide();
                LoginUI f;
                f = new LoginUI();
                f.Show();
            }
            else
            {
                MessageBox.Show("很抱歉,注册失败!","Error");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }

        }
        private void QueryUserList(HttpContext context)
        {
            string strKeyWord = context.Request["KeyWord"];

            BLL.UserInfo          bll  = new BLL.UserInfo();
            List <Model.UserInfo> list = new List <Model.UserInfo>();
            DataSet ds = new DataSet();

            if (!string.IsNullOrEmpty(strKeyWord))
            {
                ds = bll.GetList(string.Format("U_nickname like '%{0}%'", strKeyWord));
            }
            else
            {
                ds = bll.GetList("");
            }
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                list.Add(new Model.UserInfo()
                {
                    U_ID       = Convert.ToInt32(dr["U_ID"]),
                    U_username = dr["U_username"].ToString(),
                    //U_power = dr["U_power"].ToString(),
                    U_PowerDisplay = ChangePowerToDisplay(dr["U_power"].ToString()),
                    //U_power = dr["U_Power"].ToString(),
                    U_nickname = dr["U_nickname"].ToString(),
                    U_mailbox  = dr["U_mailbox"].ToString(),
                    U_Role     = dr["U_Role"].ToString(),
                });
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            //string strJson = string.Format("{{\"rows\":{0}}}", jss.Serialize(list));
            string strJson = jss.Serialize(list);

            context.Response.Write(strJson);
        }