protected void btLogin_Click(object sender, EventArgs e) { Session.RemoveAll(); string name = txtName.Text.Replace("'", "").Replace(" ", ""); string pass = txtPass.Text.Replace("'", "").Replace(" ", ""); string strwhere = ""; string username = ""; pass = ljxpower.Common.DESEncrypt.Encrypt(pass); #region login .... ljxpower.BLL.com_user bll = new ljxpower.BLL.com_user(); strwhere = "(userid='" + name + "' or logincount='" + name + "' ) and password='******'"; Session["schoolnum"] = ""; DataSet ds = ljxpower.Common.DbHelperMySQL.Query("select * from com_user where " + strwhere); if (ds.Tables[0].Rows.Count <= 0) { lblName.Text = "用户名或密码错误"; } else { ljxpower.Model.com_user usermodel = new ljxpower.Model.com_user(); usermodel = bll.GetModel(int.Parse(ds.Tables[0].Rows[0]["Id"].ToString())); ljxpower.BLL.com_loginlog lbll = new ljxpower.BLL.com_loginlog(); ljxpower.Model.com_loginlog lmodel = new ljxpower.Model.com_loginlog(); lmodel.LoginDate = DateTime.Now; lmodel.LoginIP = Page.Request.UserHostAddress; lmodel.Status = "0"; lmodel.Userid = name; if (ds.Tables[0].Rows.Count > 0) { username = ds.Tables[0].Rows[0]["username"].ToString(); //登录用户姓名 } lmodel.username = username; lbll.Add1(lmodel); userinfo userobj = new userinfo(); userobj.logincount = ds.Tables[0].Rows[0]["logincount"].ToString(); //登录帐户编名 userobj.userid = ds.Tables[0].Rows[0]["userid"].ToString(); //登录帐户编名 userobj.username = ds.Tables[0].Rows[0]["username"].ToString(); //登录用户名 userobj.usertype = ds.Tables[0].Rows[0]["usertype"].ToString(); //用户类别 userobj.orgid = ds.Tables[0].Rows[0]["orgid"].ToString(); //部门编号 userobj.logintime = DateTime.Now; //登录时间 Session["userobj"] = userobj; Response.Redirect("index.html?username="******"username"].ToString() + "&time=" + DateTime.Now.ToUniversalTime()); } #endregion login.... }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; ljxpower.BLL.com_user bll = new ljxpower.BLL.com_user(); if (context.Request.QueryString["type"] == "pass")//修改密码 { userinfo userobj = (userinfo)context.Session["userobj"]; string Userid = userobj.userid; string pass = context.Request.QueryString["pass"]; ljxpower.Model.com_user model = new ljxpower.Model.com_user(); string myid = ljxpower.Common.DbHelperMySQL.getvalue("select id from com_user where userid='" + Userid + "'"); if (myid == "") { myid = "0"; } model = bll.GetModel(int.Parse(myid)); model.password = ljxpower.Common.DESEncrypt.Encrypt(pass); if (bll.Update1(model)) { context.Response.Write("true"); } else { context.Response.Write("false"); } } if (context.Request.QueryString["type"] == "login")//修改密码 { string Userid = context.Request.QueryString["userid"]; string pass = context.Request.QueryString["pass"]; context.Session.RemoveAll(); string name = Userid.Replace("'", "").Replace(" ", ""); pass = pass.Replace("'", "").Replace(" ", ""); //string strwhere = ""; //string username = ""; pass = ljxpower.Common.DESEncrypt.Encrypt(pass); #region login .... #endregion login.... } if (context.Request.QueryString["type"] == "edit")//获取要编辑的用户信息 { string Userid = context.Request.QueryString["Id"]; DataSet ds = ljxpower.Common.DbHelperMySQL.Query("select RolesId,UserId from tb_rolesadduser where UserId = '" + Userid + "'"); string IdList = ""; foreach (DataRow dr in ds.Tables[0].Rows) { if (IdList != "") { IdList += ","; } IdList += dr["RolesId"].ToString(); } context.Response.Write(IdList); } else if (context.Request.QueryString["type"] == "role")// { string Userid = context.Request.QueryString["Userid"]; string role = context.Request.QueryString["role"]; if (Userid != null && Userid != "null" && Userid != "undefined")// { saveRole(Userid, role); } } else if (Convert.ToString(context.Request.Form["action"]) == "query" || context.Request.Form["OrgId"] != null) { int row = int.Parse(context.Request["rows"].ToString()); int page = int.Parse(context.Request["page"].ToString()); string strorgid = ""; string strWhere = ""; if (context.Request["OrgId"] != null) { strorgid = zhangte.Common.DbHelperMySQL.getvalue("select OrgId from com_organization where id=" + context.Request["OrgId"].ToString()); strorgid = strorgid.Replace("0", " ").TrimEnd(); strorgid = strorgid.Replace(" ", "0"); strWhere = " orgid like '" + strorgid + "%'"; } string retstr = ""; retstr = bll.GetListByPageColumns_tojson("*", strWhere, "userid desc", row, page); context.Response.Write(retstr); } }