private string GetClientType(HttpContext context, string userid, string entid) { string Json = ""; string sqlStr = "select TypeID,ClientType from dt_CustomerType where status=1 order by TypeID asc"; SqlRun sql = new SqlRun(SqlRun.sqlstr); DataTable dt = sql.RtDataTable(sqlStr); if (dt.Rows.Count > 0) { Json = JsonMethod.GetDataTable(0, dt.Rows.Count, 1, dt); } else { Json = JsonMethod.GetError(1, "客户分类加载失败"); } return(Json); }
protected string GetWebSiteBase(string json, string proc, string UserId, string entId) { JObject obj = (JObject)JsonConvert.DeserializeObject(json); StringBuilder strSql = new StringBuilder(); //修改商品主表 strSql.Append("select entId,web_name,web_ip,company,complaints,xxjyz,xxfwz,icp,beizhu,img_app,img_logo,img_left,img_right,img_service,link_service from dt_system_base(nolock) where entid='" + entId + "'"); SqlRun sql = new SqlRun(SqlRun.sqlstr); DataTable dt = sql.RtDataTable(strSql.ToString()); if (dt.Rows.Count > 0) { return(JsonMethod.GetDataTable(0, 1, 1, dt)); } else { return(JsonMethod.GetError(1, "无数据")); } }
/// <summary> /// 返回模板绑定 /// </summary> /// <param name="templateName"></param> /// <param name="status"></param> /// <param name="page"></param> /// <param name="size"></param> /// <returns></returns> protected string GetTemplateRelationReturnJson(string templateName, string status, int type, int page = 1, int size = 30) { string r_json = ""; SqlRun sql = new SqlRun(SqlRun.sqlstr); DataSet ds = sql.RunProDataSet("Pc_TemplateRelation", new SqlParameter[] { new SqlParameter("@type", "PC_GetTemplateRelationList"), new SqlParameter("@TemplateRelationName", templateName), new SqlParameter("@TypeCode", type), new SqlParameter("@Status", status), new SqlParameter("@PageIndex", page), new SqlParameter("@PageSize", size) }); if (ds.Tables.Count >= 3) { if (ds.Tables[1].Rows.Count > 0) { int recordCount = Convert.ToInt32(ds.Tables[2].Rows[0]["recordCount"].ToString().Trim()); int pageCount = Convert.ToInt32(ds.Tables[2].Rows[0]["pageCount"].ToString().Trim()); r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds.Tables[1]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } else { if (ds.Tables[0].Rows.Count > 0) { int recordCount = 0; int pageCount = 0; r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds.Tables[0]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } return(r_json); }
/// <summary> /// 检测用户的角色权限 /// </summary> /// <param name="json"></param> /// <param name="proc"></param> /// <param name="userId"></param> /// <param name="entId"></param> /// <returns></returns> protected string GetRoleJson(string json, string proc, string userId, string entId) { SqlParameter[] param = (JsonMethod.ListParameter(json, userId, entId)).ToArray();//动态解析json参数 SqlRun sql = new SqlRun(SqlRun.sqlstr); DataTable ds = sql.RunProcedureDR(proc, param); string r_json; if (ds.Rows.Count > 0) { int recordCount = 0; int pageCount = 0; r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } return(r_json); }
/// <summary> /// 返回模板绑定 /// </summary> /// <param name="templateName"></param> /// <param name="isDel"></param> /// <param name="status"></param> /// <param name="page"></param> /// <param name="size"></param> /// <returns></returns> protected string GetTemplateRelationDetail(string TemplateCode) { string r_json = ""; SqlRun sql = new SqlRun(SqlRun.sqlstr); DataTable ds = sql.RunProcedureDR("Pc_TemplateRelation", new SqlParameter[] { new SqlParameter("@type", "PC_GetTemplateRelationDetail"), new SqlParameter("@TemplateRelationCode", TemplateCode) }); if (ds.Rows.Count > 0) { r_json = JsonMethod.GetDataTable(0, ds.Rows.Count, 1, ds); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } return(r_json); }
/// <summary> /// 返回DataTable(规则详情) /// </summary> /// <param name="json"></param> /// <param name="proc"></param> /// <param name="userId"></param> /// <param name="entid"></param> /// <returns></returns> protected string GeTypeDetailReturnJson(string userId, string entId, string id) { SqlRun sql = new SqlRun(SqlRun.sqlstr); DataTable ds = sql.RunProcedureDR("Pc_Coupon", new SqlParameter[] { new SqlParameter("@type", "PC_GetTypeDetail"), new SqlParameter("@strWhere", id), new SqlParameter("@entId", entId) }); string r_json; if (ds.Rows.Count > 0) { r_json = JsonMethod.GetDataTable(0, ds.Rows.Count, 1, ds); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } return(r_json); }
/// <summary> /// 获取数据返回数据列表 /// </summary> /// <param name="json"></param> /// <param name="proc"></param> /// <param name="userId"></param> /// <param name="entId"></param> /// <returns></returns> protected string GetReturnJson(string json, string proc, string userId, string entId) { string r_json; SqlParameter[] param = (JsonMethod.ListParameter(json, userId, entId)).ToArray();//动态解析json参数 SqlRun sql = new SqlRun(SqlRun.sqlstr); DataSet ds = sql.RunProDataSet(proc, param); if (ds.Tables.Count >= 3) { if (ds.Tables[1].Rows.Count > 0) { int recordCount = Convert.ToInt32(ds.Tables[2].Rows[0]["recordCount"].ToString().Trim()); int pageCount = Convert.ToInt32(ds.Tables[2].Rows[0]["pageCount"].ToString().Trim()); DataTable table = sql.GetChinaName(ds.Tables[1]); r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, table, ds.Tables[1]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } else { if (ds.Tables[0].Rows.Count > 0) { int recordCount = 0; int pageCount = 0; r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds.Tables[0]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } return(r_json); }
/// <summary> /// 获取数据返回数据列表 /// </summary> /// <param name="json"></param> /// <param name="proc"></param> /// <param name="userId"></param> /// <param name="entid"></param> /// <returns></returns> protected string GetReturnJson(string json, string proc, string userId, string entid) { List <SqlParameter> listPrmt = new List <SqlParameter>(); JObject o = JObject.Parse(json); IEnumerable <JProperty> properties = o.Properties(); bool flag = true; foreach (JProperty item in properties) { if (item.Name.Trim() != "") { if (item.Name.ToString() == "Entid") { flag = false; } if (item.Name.ToString() == "PassWord")//密码md5加密 { listPrmt.Add(new SqlParameter("@" + item.Name, Encryption.GetMD5_16(item.Value.ToString()))); } else if (item.Name.ToString() == "XPassWord")//密码md5加密 { listPrmt.Add(new SqlParameter("@" + item.Name, Encryption.GetMD5_16(item.Value.ToString()))); } else { listPrmt.Add(new SqlParameter("@" + item.Name, item.Value.ToString().Trim() ?? "")); } } } if (userId != "") { listPrmt.Add(new SqlParameter("@UserId", userId)); } if (entid != "" && flag == true) { listPrmt.Add(new SqlParameter("@entId", entid)); } SqlParameter[] param = listPrmt.ToArray();//动态解析json参数 JObject obj = (JObject)JsonConvert.DeserializeObject(json); string familyid = ""; if (obj["type"].ToString() == "GetAdminList") { familyid = Familylist(userId, entid); Log.Info("家族主键", familyid); } if (familyid != "" && flag == true) { listPrmt.Add(new SqlParameter("@familyid", familyid)); } //获取顶级以及最底层所有会员的状态 SqlRun sql = new SqlRun(SqlRun.sqlstr); DataSet ds = sql.RunProDataSet(proc, param); string r_json; if (ds.Tables.Count >= 3) { if (ds.Tables[1].Rows.Count > 0) { int recordCount = Convert.ToInt32(ds.Tables[2].Rows[0]["recordCount"].ToString().Trim()); int pageCount = Convert.ToInt32(ds.Tables[2].Rows[0]["pageCount"].ToString().Trim()); r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds.Tables[1]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } else { if (ds.Tables[0].Rows.Count > 0) { int recordCount = 0; int pageCount = 0; r_json = JsonMethod.GetDataTable(0, recordCount, pageCount, ds.Tables[0]); } else { string error = "无数据"; r_json = JsonMethod.GetError(1, error); } } return(r_json); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string returnJson = ""; try { Dt_User user = RoleFuns.IsLoginAdmin(context.Session["user"]); if (user != null) //登录检测,权限检测 context.Session["user"] { string json = context.Request.QueryString["json"].Trim(); //请求参数(json类型) var obj = JsonConvert.DeserializeObject <PromRuleListModel>(json); var type = obj.type; if (type != null) { List <string> rolestr = context.Session["role"] != null ? (List <string>)context.Session["role"] : null; RoleFuns.SetAdminLog(user.username, "促销管理", rolestr); switch (type) { case "QueryList": { var db = new SqlSugarDb(); var total = 0; var strWhere = obj.strWhere; var status = obj.status; var faType = obj.faType; System.Linq.Expressions.Expression <Func <SC_T_PromSales, SC_T_PromRule, dt_PromType, bool> > lab; if (string.IsNullOrEmpty(status)) { lab = (d, f, e) => (d.salesName.Contains(strWhere) || f.describe.Contains(strWhere)) && d.faType.Contains(faType); } else { lab = (d, f, e) => (d.salesName.Contains(strWhere) || f.describe.Contains(strWhere)) && d.faType.Contains(faType) && SqlFunc.IsNull(d.isShow, "1") == status; } var data = db.Db.Queryable <SC_T_PromSales, SC_T_PromRule, dt_PromType>((d, f, e) => new object[] { JoinType.Left, d.ruleCode == f.ruleCode && d.faType == f.faType, JoinType.Left, d.faType == e.faType }) .Where(lab) .Select((d, f, e) => new { d.entid, d.salesName, d.salesCode, d.isShow, e.faName, f.ruleTitle, d.faType }) .ToDataTablePage(obj.PageIndex, obj.PageSize, ref total); var totalPage = total % obj.PageSize == 0 ? total / obj.PageSize : total / obj.PageSize + 1; returnJson = JsonMethod.GetDataTable(0, total, totalPage, data); } break; case "UpdateSalesDown": { var updateStatus = 1; var db = new SqlSugarDb(); db.Db.Ado.UseTran(() => { db.Db.Updateable <SC_T_PromSales>().SetColumns(d => new SC_T_PromSales() { isShow = updateStatus.ToString() }).Where(d => d.salesCode == obj.ruleCode && d.entid == obj.entid).ExecuteCommand(); db.Db.Ado.UseStoredProcedure().ExecuteCommand("Proc_Admin_PromSales", new SugarParameter("@type", "UpdateSalesDown"), new SugarParameter("@entid", obj.entid), new SugarParameter("@salesCode", obj.ruleCode)); }); returnJson = JsonMethod.GetError(0, "操作成功"); } break; case "UpdateSalesShow": { var updateStatus = 2; var db = new SqlSugarDb(); db.Db.Ado.UseTran(() => { db.Db.Updateable <SC_T_PromSales>().SetColumns(d => new SC_T_PromSales() { isShow = updateStatus.ToString() }).Where(d => d.salesCode == obj.ruleCode && d.entid == obj.entid).ExecuteCommand(); db.Db.Ado.UseStoredProcedure().ExecuteCommand("Proc_Admin_PromSales", new SugarParameter("@type", "UpdateSalesShow"), new SugarParameter("@entid", obj.entid), new SugarParameter("@salesCode", obj.ruleCode)); }); returnJson = JsonMethod.GetError(0, "操作成功"); } break; case "DeleteSales": { var updateStatus = 0; var db = new SqlSugarDb(); db.Db.Updateable <SC_T_PromSales>().SetColumns(d => new SC_T_PromSales() { isShow = updateStatus.ToString() }).Where(d => d.salesCode == obj.ruleCode && d.entid == obj.entid).ExecuteCommand(); returnJson = JsonMethod.GetError(0, "操作成功"); } break; } } } else { returnJson = JsonMethod.GetError(2, "登陆超时,请重新登陆!"); } } catch (Exception e) { string msg = e.Message.ToString().Trim().Replace("\"", "\\\"").Replace("\r", "").Replace("\n", ""); returnJson = JsonMethod.GetError(4, msg);; } context.Response.Write(returnJson); }