public ActionResult Admin_Edit(t_admin model) { string sql = string.Format("update t_admin t set t.level={0},t.xzqhcode='{1}',t.name='{2}',t.phone='{3}' where t.id={4}", model.level, model.xzqhcode, model.name, model.phone, model.id); int count = DbHelperMySQL.ExecuteSql(sql); return(Json(Result.AutoResult(count), JsonRequestBehavior.AllowGet)); }
public ActionResult Admin_GetListByPage(SearchModel model) { string sql1 = "select t.*,t1.name xzqhname from t_admin t left join t_xzqh t1 on t.xzqhcode=t1.code where t.del=0"; string sql2 = "select count(*) from t_admin t where t.del=0"; if (model.string1 != "-1") { string and = " and t.xzqhcode='" + model.string1 + "'"; sql1 += and; sql2 += and; } else { t_admin admin = Common.getAdmin(); if (admin.xzqhcode.Length != 1) { string and = " and instr(t.xzqhcode,'" + admin.xzqhcode + "')"; sql1 += and; sql2 += and; } } if (!string.IsNullOrWhiteSpace(model.string2)) { string and = " and t.name like '%" + model.string2 + "%'"; sql1 += and; sql2 += and; } sql1 += " order by t.id limit " + Util.getPage(model.page, model.limit); DataTable dt = DbHelperMySQL.Query(sql1).Tables[0]; var data = dt.ConvertToModel <t_admin>(); int count = Convert.ToInt32(DbHelperMySQL.GetSingle(sql2)); return(Json(Result.Success(count, data), JsonRequestBehavior.AllowGet)); }
public ActionResult NewsTalk_GetListByPage(SearchModel model) { string sql1 = "select t.*,t1.title newstitle,t2.name xzqhname,t3.name typename,t4.name adminname,t5.name username" + " from t_news_talk t" + " left join t_news t1 on t.newsid = t1.id" + " left join t_xzqh t2 on t1.xzqhcode = t2.code" + " left join t_news_type t3 on t1.typeid = t3.id" + " left join t_admin t4 on t.adminid = t4.id" + " left join t_user t5 on t.userid = t5.id" + " where t.del=0"; string sql2 = "select count(*) from t_news_talk t left join t_news t1 on t.newsid = t1.id where t.del=0"; if (model.string1 != "-1") { string and = " and t1.xzqhcode='" + model.string1 + "'"; sql1 += and; sql2 += and; } else { t_admin admin = Common.getAdmin(); if (admin.xzqhcode.Length != 1) { string and = " and instr(t1.xzqhcode,'" + admin.xzqhcode + "')"; sql1 += and; sql2 += and; } } if (model.number1 != -1) { string and = " and t1.typeid=" + model.number1; sql1 += and; sql2 += and; } if (model.number2 != -1) { string and = model.number2 == 0 ? (" and t.answer is null") : (" and t.answer is not null"); sql1 += and; sql2 += and; } if (!string.IsNullOrWhiteSpace(model.string2)) { string and = " and t1.title like '%" + model.string2 + "%'"; sql1 += and; sql2 += and; } sql1 += " order by t.id desc limit " + Util.getPage(model.page, model.limit); DataTable dt = DbHelperMySQL.Query(sql1).Tables[0]; var data = dt.ConvertToModel <t_news_talk>(); int count = Convert.ToInt32(DbHelperMySQL.GetSingle(sql2)); try { Common.Count_Admin_News_Answer(); } catch (Exception e) { } return(Json(Result.Success(count, data), JsonRequestBehavior.AllowGet)); }
public ActionResult Login(t_admin user) { BAEntities usersEntities = new BAEntities(); int? userId = usersEntities.ValidateUser(user.email, user.password).FirstOrDefault(); string message = string.Empty; switch (userId.Value) { case -1: message = "Username and/or password is incorrect."; break; case -2: message = "Account has not been activated."; break; default: FormsAuthentication.SetAuthCookie(user.email, user.RememberMe); return(RedirectToAction("Index", "Admin")); } ViewBag.Message = message; return(View(user)); }
public ActionResult Admin_Add(t_admin model) { string sql = string.Format("select count(*) from t_admin t where t.del=0 and t.account='{0}'", model.account); int count = Convert.ToInt32(DbHelperMySQL.GetSingle(sql)); if (count != 0) { return(Json(Result.Error("该账号已存在", -1), JsonRequestBehavior.AllowGet)); } sql = string.Format("insert into t_admin(level,xzqhcode,account,password,name,phone,count_publish,count_answer,del) values('{0}','{1}','{2}','{3}','{4}','{5}',0,0,0)", model.level, model.xzqhcode, model.account, model.password, model.name, model.phone); count = DbHelperMySQL.ExecuteSql(sql); return(Json(Result.AutoResult(count), JsonRequestBehavior.AllowGet)); }
public ActionResult GetXzqhByAdmin() { t_admin admin = Common.getAdmin(); string sql = "select code,name,pcode,substr(code,1,9) as short_code from t_xzqh t order by short_code,pcode"; DataTable dt = DbHelperMySQL.Query(sql).Tables[0]; List <t_xzqh> list = dt.ConvertToModel <t_xzqh>().ToList(); List <t_xzqh> result = new List <t_xzqh>(); if (admin.xzqhcode.Length != 1) { foreach (var x in list) { if (x.code.ToString().StartsWith(admin.xzqhcode)) { result.Add(x); } } } else { result = list; } return(Json(Result.Success(result.Count, result), JsonRequestBehavior.AllowGet)); }