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 = "(企业标识代码='" + name + "' ) and 登录密码='" + pass + "'"; DataSet ds = ljxpower.Common.DbHelperMySQL.Query("select * from zt_qiyebiao 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]["企业名称"].ToString(); //登录用户姓名 // lmodel.username = username; // lbll.Add1(lmodel); userinfo userobj = new userinfo(); userobj.logincount = "admin"; userobj.userid = "1"; userobj.username = "******"; userobj.usertype = "1"; userobj.orgid = "1100000000"; userobj.logintime = DateTime.Now;//登录时间 Session["userobj"] = userobj; Session["lb"] = ds.Tables[0].Rows[0]["企业类别"].ToString(); Session["xy"] = ds.Tables[0].Rows[0]["信用等级"].ToString(); Session["account"] = ds.Tables[0].Rows[0]["企业名称"].ToString(); Session["gongsibianhao"] = ds.Tables[0].Rows[0]["企业标识代码"].ToString(); Response.Redirect("index.html?username="******"企业名称"].ToString() + "&time=" + DateTime.Now.ToUniversalTime()); } #endregion login.... }
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); } }
public override void ProcessRequest(HttpContext context) { ljxpower.BLL.com_user bll = new ljxpower.BLL.com_user(context); base.ProcessRequest(context); context.Response.ContentType = "text/plain"; mycommonClass mycommonClassobj = new mycommonClass(); context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); if (context.Request.QueryString["type"] == "edit")//获取编辑信息 { if (context.Request.QueryString["Id"] != null) { string strret = bll.Geteditdata(context.Request.QueryString["Id"].ToString());//aa1 context.Response.Write(strret); } } else if (context.Request.QueryString["type"] == "del")//删除信息 { if (context.Request.QueryString["Id"] == null) { return; } string Id = context.Request.QueryString["Id"].ToString(); bll.Delete(int.Parse(Id)); kyfly.Common.DbHelperMySQL.ExecuteSql("delete from Com_OrgAddUser where UserId=" + Id); } else if (context.Request.QueryString["type"] == "combox")//保存修改或添加 信息 aa2 { if (context.Request.QueryString["comboxname"] == "status") { ljxpower.BLL.com_zidian bllzd = new ljxpower.BLL.com_zidian(); string strret = bllzd.GetListByColumn_tojson("Id,xianshizhi", "leibie='人员状态'", ""); context.Response.Write(strret); //context.Response.Write(""); } if (context.Request.QueryString["comboxname"] == "orgid") { ljxpower.BLL.com_organization bllzd = new ljxpower.BLL.com_organization(); string strret = bllzd.GetListByColumn_tojson("Id,Agency,orgid,Person", "1=1", ""); context.Response.Write(strret); } } else if (context.Request.QueryString["type"] == "comboxtree") { //string str = ""; //str = ljxpower.Common.DbHelperMySQL.getvalue("select mycontent from temp1"); //context.Response.Write(str); //return; StringBuilder sb = new StringBuilder(); ljxpower.BLL.com_organization orgbll = new ljxpower.BLL.com_organization(); DataSet ds = new DataSet(); ds = orgbll.GetAllList(); if (ds.Tables.Count > 0) { sb.Append("["); DataView dv = new DataView(ds.Tables[0]); dv.RowFilter = "ParentId=0"; dv.Sort = " Sort "; for (int i = 0; i < dv.Count; i++) { sb.Append("{"); sb.Append("\"id\":" + dv[i]["orgid"] + ","); sb.Append("\"text\":\"" + dv[i]["Agency"] + "\""); DataView dv2 = new DataView(ds.Tables[0]); dv2.RowFilter = "ParentId=" + dv[i]["Id"]; dv2.Sort = " Sort "; if (dv2.Count > 0) { sb.Append(GetChlid(dv2, ds)); } sb.Append("},"); } sb.Remove(sb.Length - 1, 1); sb.Append("]"); } context.Response.Write(sb.ToString()); } else if (context.Request.QueryString["type"] == "powersave")//保存修改或添加 { string userstr = context.Request.QueryString["idlist"].ToString(); string roleid = context.Request.QueryString["roleid"].ToString(); string[] userid; if (userstr != "" && roleid != "") { userid = userstr.Split(':'); for (int i = 0; i < userid.Length; i++) { if (userid[i] == "") { continue; } saveRole(userid[i], roleid); } } } else if (context.Request.QueryString["type"] == "save")//保存修改或添加 { string userid = context.Request.QueryString["userid"]; string logincount = context.Request.QueryString["logincount"]; string username = context.Request.QueryString["username"]; string orgid = context.Request.QueryString["orgid"]; string password = context.Request.QueryString["password"]; string usertype = context.Request.QueryString["usertype"]; string status = context.Request.QueryString["status"]; string gongsibianhao = context.Request.QueryString["gongsibianhao"]; string orgname = context.Request.QueryString["orgname"]; if (password.Trim() != "") { password = ljxpower.Common.DESEncrypt.Encrypt(password); } else { password = kyfly.Common.DbHelperMySQL.getvalue("select password from com_user where UserId=" + userid); } if (context.Request.QueryString["Id"] != null && context.Request.QueryString["Id"] != "") { if (kyfly.Common.DbHelperMySQL.getvalue("select id from Com_OrgAddUser where UserId=" + userid) == "") { kyfly.Common.DbHelperMySQL.ExecuteSql("insert into Com_OrgAddUser(orgid,UserId) values('" + orgid + "','" + userid + "')"); } else { bll.Update(context.Request.QueryString["Id"].ToString(), userid, logincount, username, orgid, password, usertype, status, gongsibianhao, orgname); kyfly.Common.DbHelperMySQL.ExecuteSql("update Com_OrgAddUser set orgid='" + orgid + "' where UserId=" + userid); } }//(string Id, string userid, string logincount, string username, string orgid, string password, string usertype, string status, string gongsibianhao) else { bll.Add(userid, logincount, username, orgid, password, usertype, status, gongsibianhao, username); } context.Response.Write("true"); } else if (Convert.ToString(context.Request.Form["action"]) == "query") { //string strret = bll.GetListByPageColumns_tojson("id,产品名称,产品数量,产品规格,备注", "1=1", "产品数量"); 加权限, 1=1 改为:部门编号 like '1010%' string strret = bll.GetListByPageColumns_tojson("Id,userid,logincount,username,orgid,password,usertype,status,gongsibianhao,orgname", pagestrif, "Id"); context.Response.Write(strret); return; } else { } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string RoleId = "0"; if (context.Request.QueryString["type"] == "edit")//获取角色信息 { int Id = int.Parse(context.Request.QueryString["Id"]); ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles(); ljxpower.Model.tb_roles model = bll.GetModel(Id); StringBuilder sb = new StringBuilder(); sb.Append(model.RolesName + ","); sb.Append(model.Remark + ","); ljxpower.BLL.com_user ubll = new ljxpower.BLL.com_user(); List <ljxpower.Model.com_user> list = ubll.GetModelList(" Userid in(select UserId from tb_rolesadduser where RolesId=" + Id + ")"); foreach (ljxpower.Model.com_user item in list) { sb.Append("<div onclick='ss(" + item.userid + ")' height='23px'><input type='hidden' value='" + item.userid + "' />" + item.password + "|" + item.username + "</div>"); } context.Response.Write(sb.ToString()); } else if (context.Request.QueryString["type"] == "getUser")//获取未绑定到当前角色的用户 { StringBuilder sb = new StringBuilder(); ljxpower.BLL.com_user ubll = new ljxpower.BLL.com_user(); List <ljxpower.Model.com_user> list = new List <ljxpower.Model.com_user>(); //if (context.Request.QueryString["Id"] != null && context.Request.QueryString["Id"] != "") //{ // int Id = int.Parse(context.Request.QueryString["Id"]); // list = ubll.GetModelList(" Userid not in(select UserId from tb_rolesadduser where RolesId=" + Id + ")"); //} //else //{ list = ubll.GetModelList(""); // } foreach (ljxpower.Model.com_user item in list) { sb.Append("<div><input name=\"chkItem\" value=\"<div onclick='ss(" + item.userid + ")' height='23px'><input type='hidden' value='" + item.userid + "' />" + item.password + "|" + item.username + "</div>\" type=\"checkbox\" /> "); sb.Append(item.password + "|" + item.username + "</div>"); } context.Response.Write(sb.ToString()); } else if (context.Request.QueryString["type"] == "save")//保存角色信息 { string name = context.Request.QueryString["name"]; string remark = context.Request.QueryString["remark"]; int Id = int.Parse(context.Request.QueryString["Id"]); ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles(); ljxpower.Model.tb_roles model = bll.GetModel(Id); model.Remark = remark; model.RolesName = name; context.Response.Write(bll.Update1(model)); } else if (context.Request.QueryString["type"] == "add")//添加 { string name = context.Request.QueryString["name"]; string remark = context.Request.QueryString["remark"]; ljxpower.Model.tb_roles model = new ljxpower.Model.tb_roles(); ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles(); model.Remark = remark; model.RolesName = name; if (bll.Add1(model) > 0) { context.Response.Write("true"); } else { context.Response.Write("false"); } } else if (context.Request.QueryString["type"] == "delRole")//删除角色 { int Id = int.Parse(context.Request.QueryString["Id"]); ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles(); ljxpower.BLL.tb_rolesadduser rbll = new ljxpower.BLL.tb_rolesadduser(); rbll.Delete(Id); context.Response.Write(bll.Delete(Id)); } else if (context.Request.QueryString["type"] == "Distri")//获取已分配的权限 { int Id = int.Parse(context.Request.QueryString["Id"]); ljxpower.BLL.tb_rolesandnavigation bll = new ljxpower.BLL.tb_rolesandnavigation(); List <ljxpower.Model.tb_rolesandnavigation> list = new List <ljxpower.Model.tb_rolesandnavigation>(); list = bll.GetModelList(" RolesId=" + Id); StringBuilder sb = new StringBuilder(); foreach (ljxpower.Model.tb_rolesandnavigation model in list) { sb.Append(model.NavigationId + ","); } if (sb.Length > 0) { sb.Remove(sb.Length - 1, 1); } context.Response.Write(sb.ToString()); } else if (context.Request.QueryString["type"] == "saveDistri") { int Id = int.Parse(context.Request.QueryString["Id"]); string nav = context.Request.QueryString["nav"]; string[] str = nav.Split(','); List <string> list = new List <string>(); string sql = "delete tb_rolesandnavigation where RolesId=" + Id; foreach (string ss in str) { ljxpower.BLL.tb_navigation bll = new ljxpower.BLL.tb_navigation(); ljxpower.Model.tb_navigation model = bll.GetModel(int.Parse(ss)); if (model.ParentId != 0) { string sql3 = "delete tb_rolesandnavigation where RolesId=" + Id + " and NavigationId=" + model.ParentId; string sql1 = "insert into tb_rolesandnavigation (RolesId,NavigationId) values(" + Id + "," + model.ParentId + ")"; list.Add(sql3); list.Add(sql1); } string sql2 = "insert into tb_rolesandnavigation (RolesId,NavigationId) values(" + Id + "," + ss + ")"; list.Add(sql2); } ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list); } else if (context.Request.QueryString["type"] == "savenav") { RoleId = context.Request["RoleId"].ToString(); string NavId = context.Request["NavId"].ToString(); List <string> list = new List <string>(); list.Add("delete from tb_rolesandnavigation where RolesId=" + RoleId); string[] str = NavId.Split('|'); for (int i = 0; i < str.Length - 1; i++) { string[] str2 = str[i].Split(','); if (str2.Length == 2) { list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + ",0)"); } else { for (int j = 1; j < str2.Length - 1; j++) { list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + "," + str2[j] + ")"); } } } ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list); context.Response.Write("Hello World"); } else if (context.Request.QueryString["type"] == "query") { ljxpower.BLL.tb_roles bll = new ljxpower.BLL.tb_roles(); List <ljxpower.Model.tb_roles> list = bll.GetModelList(""); StringBuilder sb = new StringBuilder(); sb.Append("["); foreach (ljxpower.Model.tb_roles item in list) { sb.Append("{\"Id\":" + item.Id + ","); sb.Append("\"Name\":\"" + item.RolesName + "\","); sb.Append("\"Remark\":\"" + item.Remark + "\"},"); } if (sb.Length > 1) { sb.Remove(sb.Length - 1, 1); } sb.Append("]"); context.Response.Write(sb.ToString()); } ///////////////////////////////////// else if (context.Request["type"].ToString() == "ljxquery") { RoleId = context.Request["RoleId"].ToString(); getdata(RoleId, context); } else if (context.Request["type"] == "pageload") { //设置内容权限,读取内容权限,保留在本页中。 string str1 = context.Request.UrlReferrer.LocalPath; if (str1.Length > 3) { str1 = str1.Substring(1); } string pageljxfun = getstrif(str1, context); context.Response.Write(pageljxfun); //context.Response.Write("OK"); //return; } else if (context.Request["type"] == "ljxsave") { //设置内容权限,读取内容权限,保留在本页中。 RoleId = context.Request["RoleId"].ToString(); string NavId = context.Request["NavId"].ToString(); List <string> list = new List <string>(); list.Add("delete from tb_rolesandnavigation where RolesId=" + RoleId); string[] str = NavId.Split('|'); for (int i = 0; i < str.Length - 1; i++) { string[] str2 = str[i].Split(','); if (str2.Length == 2) { list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + ",0)"); } else { for (int j = 1; j < str2.Length - 1; j++) { list.Add(" insert into tb_rolesandnavigation(RolesId,NavigationId,ButtonId) values(" + RoleId + "," + str2[0] + "," + str2[j] + ")"); } } } ljxpower.Common.DbHelperMySQL.ExecuteSqlTran(list); context.Response.Write("OK"); //return; } }