Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string returnJson = "";

            try
            {
                string type = context.Request.QueryString["type"].Trim();//请求类型
                if (type == "UploadImage")
                {
                    returnJson = UploadImage(context);
                }
            }
            catch (Exception e)
            {
                string msg = e.Message.ToString().Trim().Replace("\"", "\\\"").Replace("\r", "").Replace("\n", "");
                returnJson = JsonMethod.GetError(4, msg);;
            }
            context.Response.Write(returnJson);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新数据目录
        /// </summary>
        /// <param name="json"></param>
        /// <param name="proc"></param>
        /// <returns></returns>
        protected string GetReturnJsonInt(string json, string proc, string userId, string entid)
        {
            SqlParameter[] param = (JsonMethod.ListParameter(json, userId, entid)).ToArray();//动态解析json参数
            SqlRun         sql   = new SqlRun(SqlRun.sqlstr);
            int            n     = sql.ExecuteNonQuery(proc, param);
            string         r_json;
            string         msg;

            if (n > 0)
            {
                msg    = "更新成功";
                r_json = JsonMethod.GetError(0, msg);
            }
            else
            {
                msg    = "更新失败!";
                r_json = JsonMethod.GetError(1, msg);
            }
            return(r_json);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新数据库的数据,返回一个表
        /// </summary>
        /// <param name="json"></param>
        /// <param name="proc"></param>
        /// <returns></returns>
        protected string GetReturnDs(string json, string proc, string UserId, string entid)
        {
            SqlParameter[] param = (JsonMethod.ListParameter(json, UserId, entid)).ToArray();//动态解析json参数
            SqlRun         sql   = new SqlRun(SqlRun.sqlstr);
            DataTable      dt    = sql.RunProcedureDR(proc, param);
            string         r_json;

            if (dt.Rows.Count > 0)
            {
                int    flag = int.Parse(dt.Rows[0]["flag"].ToString() ?? "1");
                string msg  = dt.Rows[0]["msg"].ToString();
                r_json = JsonMethod.GetError(flag, msg);
            }
            else
            {
                string msg = dt.Rows[0]["msg"].ToString();
                r_json = JsonMethod.GetError(1, msg);
            }
            return(r_json);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 活动绑定上架
        /// </summary>
        /// <param name="templateCode"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        protected string SetTemplateRelationStatu(string templateRelationCode, string status)
        {
            string r_json = "";
            SqlRun sql    = new SqlRun(SqlRun.sqlstr);
            int    num    = sql.ExecuteNonQuery("Pc_TemplateRelation", new SqlParameter[] {
                new SqlParameter("@type", "PC_UpTemplateRelationStatus"),
                new SqlParameter("@TemplateRelationCode", templateRelationCode),
                new SqlParameter("@Status", status)
            });

            if (num > 0)
            {
                r_json = JsonMethod.GetError(0, "成功");
            }
            else
            {
                string error = "无数据";
                r_json = JsonMethod.GetError(1, error);
            }
            return(r_json);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <summary>
        ///  返回DataTable(权限访问)
        /// </summary>
        /// <param name="userId">用户主键</param>
        /// <param name="entId"></param>
        /// <param name="ConfigType">权限等级</param>
        /// <returns></returns>
        protected string GettIndexUrlJson(string entid, string username)
        {
            SqlRun           sql  = new SqlRun(SqlRun.sqlstr);
            List <Dt_Method> list = new List <Dt_Method>();

            if (entid == "superintendent")
            {
                list = DateTableTool.DataTableToList <Dt_Method>(sql.RtDataTable($"select * from Dt_Method m join [Dt_RoleMethod] rm on rm.MethodId=m.Id join dt_users us on rm.RoleId=us.role_id and us.entid='superintendent'"));
            }
            else
            {
                list = DateTableTool.DataTableToList <Dt_Method>(sql.RtDataTable($"select m.* from Dt_Method m join [Dt_RoleMethod] rm on rm.MethodId=m.Id join dt_users us on rm.RoleId=us.role_id where m.status=1  and us.entid='" + entid + "' and us.username='******' and m.Source in('B2B','ALL')"));
            }

            if (list.Count() > 0)
            {
                ///加载Html
                string urlList = "";
                foreach (Dt_Method meth in list.Where(a => a.FatherId == null))
                {
                    urlList += "<dl id='menu-" + meth.Id + "'>";
                    urlList += "     <dt ><i class='Hui-iconfont ztbj' style='font-size: 20px'>" + meth.IcoAddress + "</i> " + meth.Title + "<i class='Hui-iconfont menu_dropdown-arrow'>&#xe6d5;</i></dt>";
                    urlList += "    <dd>";
                    urlList += "        <ul>";
                    foreach (Dt_Method son in list.Where(a => a.FatherId == meth.Id).ToList())
                    {
                        urlList += "<li><a data-href='" + son.Power + "' data-title='" + son.Title + "' href='javascript:void(0)'><i class='Hui-iconfont'>" + son.IcoAddress + "</i> " + son.Title + "</a></li>";
                    }
                    urlList += "        </ul>";
                    urlList += "    </dd>";
                    urlList += "</dl>";
                }
                return("{\"flag\":\"0\",\"urlList\":\"" + urlList + "\"}");
            }
            else
            {
                string error = "无数据";
                return(JsonMethod.GetError(1, error));
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 用户审核
        /// </summary>
        public string AuditUser(string json)
        {
            JObject       obj    = (JObject)JsonConvert.DeserializeObject(json);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_users set status=@status where userId=@userId");
            SqlParameter[] pram = new SqlParameter[] {
                new SqlParameter("@status", obj["status"].ToString()),
                new SqlParameter("@userId", obj["userId"].ToString()),
            };
            SqlRun sql = new SqlRun(SqlRun.sqlstr);
            int    n   = sql.ExecuteSql(strSql.ToString(), pram);

            if (n > 0)
            {
                return(JsonMethod.GetError(0, "操作成功"));
            }
            else
            {
                return(JsonMethod.GetError(1, "操作失败"));
            }
        }
Ejemplo n.º 9
0
        /// <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);
        }
Ejemplo n.º 10
0
        protected string UpdateDelMethodJson(string status, string strWhere)
        {
            SqlRun    sql = new SqlRun(SqlRun.sqlstr);
            DataTable ds  = sql.RunProcedureDR("Proc_Admin_MembersQuery", new SqlParameter[] {
                new SqlParameter("@type", "PC_DelMethodUrl"),
                new SqlParameter("@strWhere", strWhere)
            });

            string r_json;

            if (ds.Rows.Count > 0 && ds.Rows[0]["flag"].ToString() == "1")
            {
                r_json = JsonMethod.GetError(0, "删除成功");
            }
            else
            {
                string error = "无数据";
                r_json = JsonMethod.GetError(1, error);
            }

            return(r_json);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        protected string UpdateUserInfo(string json, string password)
        {
            JObject obj = (JObject)JsonConvert.DeserializeObject(json);
            string  pwd = "";

            if (obj["pwd"].ToString().Trim() == password)
            {
                pwd = obj["pwd"].ToString().Trim();
            }
            else
            {
                pwd = Encryption.GetMD5_16(obj["pwd"].ToString().Trim());
            }
            string name     = obj["name"].ToString();
            string sex      = obj["sex"].ToString();
            string telphone = obj["telphone"].ToString();
            string birthday = obj["birthday"].ToString();
            string point    = obj["point"].ToString();
            string status   = obj["status"].ToString();
            string userIds  = obj["userId"].ToString();

            StringBuilder strSql = new StringBuilder();

            strSql.Append($"update dt_users set name='{name}',sex='{sex}',telphone='{telphone}',birthday='{birthday}',point='{point}',status='{obj["status"].ToString()}',");
            strSql.Append($"password='******' where userId='{userIds}'"); //entId = @entId,
            SqlRun sql = new SqlRun(SqlRun.sqlstr);

            bool flag = sql.ExecuteSql(strSql.ToString());

            if (flag)
            {
                return(JsonMethod.GetError(0, "存盘成功"));
            }
            else
            {
                return(JsonMethod.GetError(1, "操作失败"));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 保存模板绑定
        /// </summary>
        /// <param name="title"></param>
        /// <param name="newsType"></param>
        /// <param name="sortId"></param>
        /// <param name="dates"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        protected string SaveTemplateRelation(string promotioncode, string templatecode, string categorycode, int txtType, string templateimg, int sort_id, string id)
        {
            SqlRun sql = new SqlRun(SqlRun.sqlstr);
            int    num = sql.ExecuteNonQuery("Pc_TemplateRelation", new SqlParameter[] {
                new SqlParameter("@type", "PC_AddTemplateRelation"),
                new SqlParameter("@PromotionCode", promotioncode),
                new SqlParameter("@TemplateCode", templatecode),
                new SqlParameter("@CategoryCode", categorycode),
                new SqlParameter("@TypeCode", txtType),
                new SqlParameter("@TemplateImg", templateimg),
                new SqlParameter("@Sort_id", sort_id),
                new SqlParameter("@strWhere", id),
            });

            if (num > 0)
            {
                return(JsonMethod.GetError(0, "操作成功"));
            }
            else
            {
                return(JsonMethod.GetError(1, "操作失败"));
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 客户审核
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public string AuditCustomer(string json)
        {
            JObject       obj    = (JObject)JsonConvert.DeserializeObject(json);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_businessdoc set beactive=@status where businessid=@businessId and entid=@entId");
            SqlParameter[] pram = new SqlParameter[] {
                new SqlParameter("@status", obj["status"].ToString()),
                new SqlParameter("@businessId", obj["businessId"].ToString()),
                new SqlParameter("@entId", obj["entId"].ToString()),
            };
            SqlRun sql = new SqlRun(SqlRun.sqlstr);
            int    n   = sql.ExecuteSql(strSql.ToString(), pram);

            if (n > 0)
            {
                return(JsonMethod.GetError(0, "操作成功"));
            }
            else
            {
                return(JsonMethod.GetError(1, "操作失败"));
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 修改推荐商品
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        private string UpdateGoodsRecommend(string json)
        {
            dynamic obj           = JsonConvert.DeserializeObject <dynamic>(json);
            int     articleid     = Convert.ToInt32(obj.articleid);
            int     old_articleid = Convert.ToInt32(obj.old_articleid);
            int     type          = Convert.ToInt32(obj.code);
            int     old_type      = Convert.ToInt32(obj.old_type);
            int     status        = Convert.ToInt32(obj.status);
            int     sort          = Convert.ToInt32(obj.sort);

            DAL.GoodsInfoDal goodsInfoDal = new DAL.GoodsInfoDal();
            if (articleid != old_articleid)
            {
                bool isExist = goodsInfoDal.ExistGoodsRecommend(articleid, type);
                if (isExist)
                {
                    return(JsonMethod.GetError(3, "此推荐商品已存在"));
                }
            }
            bool result = goodsInfoDal.UpdateGoodsRecommend(articleid, old_articleid, type, old_type, status, sort);

            return(result ? JsonMethod.GetError(1, "修改成功") : JsonMethod.GetError(0, "修改失败,请稍后重试"));
        }
Ejemplo n.º 15
0
        public string SaveCustomer(string json)
        {
            JObject       obj    = (JObject)JsonConvert.DeserializeObject(json);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_businessdoc set businesscode=@businesscode,businessname=@businessname,entid=@entid,clienttype=@clienttype,");
            strSql.Append("beactive=@beactive,shortname=@shortname,businesscont=@businesscont,address=@address,wtr=@wtr,wtsyxq=@wtsyxq,");
            strSql.Append("xkzyxq=@xkzyxq,yyzzyxq=@yyzzyxq,gspzsyxq=@gspzsyxq where entid=@oldentid and businessid=@businessid ");
            SqlParameter[] pram = new SqlParameter[] {
                new SqlParameter("@businesscode", obj["businesscode"].ToString()),
                new SqlParameter("@businessname", obj["businessname"].ToString()),
                new SqlParameter("@entid", obj["entid"].ToString()),
                new SqlParameter("@clienttype", obj["clienttype"].ToString()),
                new SqlParameter("@beactive", obj["beactive"].ToString()),
                new SqlParameter("@shortname", obj["shortname"].ToString()),
                new SqlParameter("@businesscont", obj["businesscont"].ToString()),
                new SqlParameter("@address", obj["address"].ToString()),
                new SqlParameter("@wtr", obj["wtr"].ToString()),
                new SqlParameter("@wtsyxq", obj["wtsyxq"].ToString()),
                new SqlParameter("@xkzyxq", obj["xkzyxq"].ToString()),
                new SqlParameter("@yyzzyxq", obj["yyzzyxq"].ToString()),
                new SqlParameter("@gspzsyxq", obj["gspzsyxq"].ToString()),
                new SqlParameter("@oldentid", obj["oldentid"].ToString()),
                new SqlParameter("@businessid", obj["businessid"].ToString())
            };
            SqlRun sql = new SqlRun(SqlRun.sqlstr);
            int    n   = sql.ExecuteSql(strSql.ToString(), pram);

            if (n > 0)
            {
                return(JsonMethod.GetError(0, "存盘成功"));
            }
            else
            {
                return(JsonMethod.GetError(1, "存盘失败"));
            }
        }
Ejemplo n.º 16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string type       = context.Request.QueryString["type"].Trim(); //请求类型
            string json       = context.Request.QueryString["json"].Trim(); //请求参数(json类型)
            string proc       = context.Request.QueryString["proc"].Trim(); //存储过程名称
            string returnJson = "";

            switch (type)
            {
            case "login":
                returnJson = UserLogin(json, proc, context);
                break;

            case "loginOut":
                returnJson = loginOut(context);
                break;

            case "UrlAddress":
                Dt_User user = RoleFuns.IsLoginAdmin(context.Session["user"]);
                if (user == null)
                {
                    returnJson = JsonMethod.GetError(2, "登陆超时,请重新登陆!");
                }
                else
                {
                    returnJson = GettIndexUrlJson(user.entId, user.username);
                }
                break;

            default:
                returnJson = JsonMethod.GetError(4, "参数错误!");
                break;
            }
            context.Response.Write(returnJson);
        }
Ejemplo n.º 17
0
        /// <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);
        }
Ejemplo n.º 18
0
        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.Params["json"].Trim(); //请求参数(json类型)
                    string  type = context.Request.Params["type"].Trim(); //请求类型
                    string  proc = context.Request.Params["proc"].Trim(); //存储过程名称
                    JObject obj  = (JObject)JsonConvert.DeserializeObject(json);
                    if (obj["type"] != null)
                    {
                        List <string> rolestr = context.Session["role"] != null? (List <string>)context.Session["role"]:null;
                        RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr);
                        //if (/*rolestr == null || RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr) == 0*/false)
                        //{
                        //    returnJson = JsonMethod.GetError(4, "抱歉您没有权限进入!");
                        //}
                        //else {
                        //执行查询返回列表
                        switch (type)
                        {
                        case "ReturnList":
                            returnJson = GetReturnJson(json, proc, user.userId, user.entId);
                            break;

                        case "ReturnNumber":
                            returnJson = GetReturnJsonInt(json, proc, user.userId, user.entId);
                            break;

                        case "LoadCheckBox":
                            returnJson = LoadCheckBox(json, proc, user.userId, user.entId, context);
                            break;

                        case "ReturnDataSet":
                            returnJson = ReturnDataSetJson(json, proc, user.userId, user.entId);
                            break;

                        //case "UpdateGoodsInfo":
                        //    returnJson = UpdateGoodsInfo(json, proc, user.userId, user.entId);
                        //    break;
                        case "GoodsCategory":
                            returnJson = GetGoodsCategory(json, proc, user.userId, user.entId);
                            break;

                        case "GoodsRecommendList":
                            returnJson = GetGoodRecommendList(json);
                            break;

                        case "GoodsRecommendType":
                            returnJson = GetGoodsRecommendType();
                            break;

                        case "AddGoodsRecommend":
                            returnJson = AddGoodsRecommend(json);
                            break;

                        case "SingleGoodsRecommend":
                            returnJson = SingleGoodsRecommend(json);
                            break;

                        case "StatusGoodsRecommend":
                            returnJson = StatusGoodsRecommend(json);
                            break;

                        case "DeleteGoodsRecommend":
                            returnJson = DeleteGoodsRecommend(json);
                            break;

                        case "UpdateGoodsRecommend":
                            returnJson = UpdateGoodsRecommend(json);
                            break;

                        default:
                            returnJson = JsonMethod.GetError(4, "参数错误!");
                            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);
        }
Ejemplo n.º 19
0
        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 type = context.Request.QueryString["type"].Trim();//请求类型
                    string json = context.Request.QueryString["json"].Trim();//请求参数(json类型)
                    //string proc = context.Request.QueryString["proc"].Trim();//存储过程名称
                    var obj  = JsonConvert.DeserializeObject <PromData>(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);
                        //if (/*rolestr == null || RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr) == 0*/false)
                        //{
                        //    returnJson = JsonMethod.GetError(4, "抱歉您没有权限进入!");
                        //}
                        //else {
                        //执行查询返回列表
                        if (type == "SaveProm")
                        {
                            var db   = new SqlSugarDb();
                            var fabh = "";
                            if (string.IsNullOrWhiteSpace(obj.salesCode))
                            {
                                db.Db.Ado.UseTran(() =>
                                {
                                    var maxbh = db.Db.Queryable <dt_Maxbh>().First(d => d.BiaoShi == "FAH")?.maxbh ?? "0";
                                    var nowBh = (int.Parse(maxbh) + 1).ToString();
                                    db.Db.Updateable <dt_Maxbh>().SetColumns(d => new dt_Maxbh {
                                        maxbh = nowBh
                                    }).Where(d => d.BiaoShi == "FAH").ExecuteCommand();
                                    fabh = "FAH" + nowBh.PadLeft(11, '0');
                                });
                            }
                            else
                            {
                                fabh = obj.salesCode;
                            }
                            var prom = new SC_T_PromSales();
                            prom.salesCode = fabh;
                            prom.entid     = user.entId;
                            prom.faType    = obj.faType;
                            prom.salesName = obj.faname;
                            prom.ruleCode  = obj.ruleCode;
                            prom.startDate = obj.startDates;
                            prom.endDate   = obj.endDates;
                            if (string.IsNullOrWhiteSpace(obj.salesCode))
                            {
                                db.Db.Insertable(prom).ExecuteCommand();
                            }
                            else
                            {
                                db.Db.Updateable(prom).Where(d => d.entid == user.entId && d.salesCode == obj.salesCode).ExecuteCommand();
                            }
                            returnJson = JsonMethod.GetError(0, "操作成功");
                        }

                        if (type == "QuerySingleProm")
                        {
                            var db    = new SqlSugarDb();
                            var model = db.Db.Queryable <SC_T_PromSales>().First(d => d.entid == obj.entid && d.salesCode == obj.salesCode);
                            returnJson = JsonConvert.SerializeObject(new PromSalesUpdate()
                            {
                                promSales = model, flag = 0, message = "成功"
                            });
                        }
                        //}
                    }
                }
                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);
        }
Ejemplo n.º 20
0
        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  type     = context.Request.QueryString["type"].Trim(); //请求类型
                    string  json     = context.Request.QueryString["json"].Trim(); //请求参数(json类型)
                    string  proc     = context.Request.QueryString["proc"].Trim(); //存储过程名称
                    string  password = user.password;
                    JObject obj      = (JObject)JsonConvert.DeserializeObject(json);
                    if (obj["type"] != null)
                    {
                        List <string> rolestr = context.Session["role"] != null ? (List <string>)context.Session["role"] : null;
                        RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr);
                        //if (/*rolestr == null || RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr) == 0*/false)
                        //{
                        //    returnJson = JsonMethod.GetError(4, "抱歉您没有权限进入!");
                        //}
                        //else {
                        switch (type)
                        {
                        case "ReturnList":
                            returnJson = GetReturnJson(json, proc, user.userId, user.entId);
                            break;

                        case "ReturnDataSet":
                            returnJson = ReturnDataSetJson(json, proc, user.userId, user.entId);
                            break;

                        case "UpdateUserInfo":
                            returnJson = UpdateUserInfo(json, password);
                            break;

                        case "AuditUser":
                            returnJson = AuditUser(json);
                            break;

                        case "AuditCustomer":
                            returnJson = AuditCustomer(json);
                            break;

                        case "SaveCustomer":
                            returnJson = SaveCustomer(json);
                            break;

                        default:
                            returnJson = JsonMethod.GetError(1, "参数错误!");
                            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);
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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 type = context.Request.QueryString["type"].Trim();//请求类型
                    string json = context.Request.QueryString["json"].Trim();//请求参数(json类型)
                    //string proc = context.Request.QueryString["proc"].Trim();//存储过程名称
                    var obj  = JsonConvert.DeserializeObject <PromData>(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);
                        //if (/*rolestr == null || RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr) == 0*/false)
                        //{
                        //    returnJson = JsonMethod.GetError(4, "抱歉您没有权限进入!");
                        //}
                        //else {
                        //执行查询返回列表
                        if (type == "SaveProm")
                        {
                            var db   = new SqlSugarDb();
                            var fabh = "";
                            if (string.IsNullOrWhiteSpace(obj.ruleCode))
                            {
                                db.Db.Ado.UseTran(() =>
                                {
                                    var maxbh = db.Db.Queryable <dt_Maxbh>().First(d => d.BiaoShi == "FAR")?.maxbh ?? "0";
                                    var nowBh = (int.Parse(maxbh) + 1).ToString();
                                    db.Db.Updateable <dt_Maxbh>().SetColumns(d => new dt_Maxbh {
                                        maxbh = nowBh
                                    }).Where(d => d.BiaoShi == "FAR").ExecuteCommand();
                                    fabh = "FAR" + nowBh.PadLeft(11, '0');
                                });
                            }
                            else
                            {
                                fabh = obj.ruleCode;
                                db.Db.Deleteable <SC_T_PromRuleCondition>().Where(d => d.entid == user.entId && d.ruleCode == fabh).ExecuteCommand();
                                db.Db.Deleteable <SC_T_PromRuleReplenish>().Where(d => d.entid == user.entId && d.ruleCode == fabh).ExecuteCommand();
                            }
                            var prom = new SC_T_PromRule();
                            prom.ruleCode     = fabh;
                            prom.entid        = user.entId;
                            prom.faType       = obj.faType;
                            prom.PromScenario = obj.PromScenario;
                            prom.limitAmount  = obj.xgAmount;
                            prom.Amount       = obj.Quantity;
                            prom.contentType  = obj.contentType;
                            prom.customerType = obj.customerType;
                            prom.describe     = obj.describe;
                            prom.moreBuy      = obj.JieTi;
                            prom.ruleTitle    = obj.faname;
                            var limit     = JsonConvert.DeserializeObject <List <PromLimit> >(obj.lsid);
                            var limitList = new List <SC_T_PromRuleCondition>();
                            var limitSn   = 1;
                            foreach (var item in limit)
                            {
                                limitList.Add(new SC_T_PromRuleCondition()
                                {
                                    rule_sn      = limitSn,
                                    PromScenario = prom.PromScenario,
                                    discount     = decimal.Parse(item.zk),
                                    entid        = user.entId,
                                    faType       = prom.faType,
                                    giftGoodsID  = item.zpid,
                                    giftPrice    = decimal.Parse(item.jg),
                                    giftQuantity = decimal.Parse(item.shl),
                                    meetCount    = decimal.Parse(item.mztj),
                                    ruleCode     = fabh
                                });
                                limitSn++;
                            }

                            db.Db.Insertable(limitList).ExecuteCommand();
                            var scenarioId  = obj.ScenarioId;
                            var scenario    = (EPromScenario)Enum.Parse(typeof(EPromScenario), prom.PromScenario);
                            var repList     = new List <SC_T_PromRuleReplenish>();
                            var replenishSn = 1;
                            switch (scenario)
                            {
                            case EPromScenario.全部商品:
                                break;

                            case EPromScenario.独立商品:
                            case EPromScenario.分类商品:
                                foreach (var item in scenarioId.Split('|'))
                                {
                                    if (string.IsNullOrEmpty(item))
                                    {
                                        continue;
                                    }
                                    var data = item.Split('_');
                                    repList.Add(new SC_T_PromRuleReplenish()
                                    {
                                        entid         = user.entId,
                                        faType        = prom.faType,
                                        rule_sn       = replenishSn,
                                        ruleCode      = fabh,
                                        limitQuantity = decimal.Parse(data[2]),
                                        maxQuantity   = decimal.Parse(data[1]),
                                        ScnarioID     = data[0]
                                    });
                                    replenishSn++;
                                }
                                break;

                            case EPromScenario.品牌商品:
                            case EPromScenario.商品分组:

                                foreach (var item in scenarioId.Split('|'))
                                {
                                    if (string.IsNullOrEmpty(item))
                                    {
                                        continue;
                                    }
                                    repList.Add(new SC_T_PromRuleReplenish()
                                    {
                                        entid     = user.entId,
                                        faType    = prom.faType,
                                        rule_sn   = replenishSn,
                                        ruleCode  = fabh,
                                        ScnarioID = item
                                    });
                                    replenishSn++;
                                }
                                break;

                            default:
                                break;
                            }
                            if (repList.Count > 0)
                            {
                                db.Db.Insertable(repList).ExecuteCommand();
                            }
                            if (string.IsNullOrWhiteSpace(obj.ruleCode))
                            {
                                db.Db.Insertable(prom).ExecuteCommand();
                            }
                            else
                            {
                                db.Db.Updateable(prom).Where(d => d.entid == user.entId && d.ruleCode == obj.ruleCode).ExecuteCommand();
                            }
                            returnJson = JsonMethod.GetError(0, "操作成功");
                        }
                        if (type == "QuerySingleProm")
                        {
                            var db        = new SqlSugarDb();
                            var model     = db.Db.Queryable <SC_T_PromRule>().First(d => d.entid == obj.entid && d.ruleCode == obj.ruleCode);
                            var condition = db.Db.Queryable <SC_T_PromRuleCondition>().Where(d => d.entid == obj.entid && d.ruleCode == obj.ruleCode).ToList();

                            var giftIds       = condition.Select(d => d.giftGoodsID).ToList();
                            var conditionData = condition.Select(d => new PromCondition()
                            {
                                PromScenario = d.PromScenario,
                                discount     = d.discount,
                                entid        = d.entid,
                                rule_sn      = d.rule_sn,
                                faType       = d.faType,
                                giftGoodsID  = d.giftGoodsID,
                                giftPrice    = d.giftPrice,
                                giftQuantity = d.giftQuantity,
                                meetCount    = d.meetCount,
                                ruleCode     = d.ruleCode
                            }).ToList();
                            if (model.faType == "DHG")
                            {
                                var dic = db.Db.Queryable <dt_article_attribute>().Where(d => d.entid == obj.entid && giftIds.Contains(SqlFunc.ToString(d.article_id))).Select(d => new { d.sub_title, d.article_id }).ToList().ToDictionary(d => d.article_id.ToString(), d => d.sub_title);
                                conditionData.ForEach(d => d.giftName = dic[d.giftGoodsID]);
                            }
                            if (model.faType == "DMZ")
                            {
                                var dic = db.Db.Queryable <dt_giftdoc>().Where(d => d.entid == obj.entid && giftIds.Contains(d.goodsid)).Select(d => new { d.goodsname, d.goodsid }).ToList().ToDictionary(d => d.goodsid, d => d.goodsname);
                                conditionData.ForEach(d => d.giftName = dic[d.giftGoodsID]);
                            }

                            var replenish     = db.Db.Queryable <SC_T_PromRuleReplenish>().Where(d => d.entid == obj.entid && d.ruleCode == obj.ruleCode).ToList();
                            var scenario      = (EPromScenario)Enum.Parse(typeof(EPromScenario), model.PromScenario);
                            var scenarios     = replenish.Select(d => d.ScnarioID).ToList();
                            var replenishData = replenish.Select(d => new PromRuleReplenish()
                            {
                                ScnarioID     = d.ScnarioID,
                                entid         = d.entid,
                                faType        = d.faType,
                                InfoContent   = d.InfoContent,
                                rule_sn       = d.rule_sn,
                                limitQuantity = d.limitQuantity,
                                maxQuantity   = d.maxQuantity,
                                ruleCode      = d.ruleCode
                            }).ToList();
                            if (scenario == EPromScenario.分类商品)
                            {
                                var dic = db.Db.Queryable <dt_article_category>().Where(d => d.channel_id == 7 && scenarios.Contains(SqlFunc.ToString(d.id))).Select(d => new { d.title, d.id }).ToList();
                                replenishData.ForEach(d =>
                                {
                                    var mm         = dic.First(m => d.ScnarioID == m.id.ToString());
                                    d.SecnarioName = mm.title;
                                    d.SecnarioCode = mm.id.ToString();
                                });
                            }
                            if (scenario == EPromScenario.独立商品)
                            {
                                var dic = db.Db.Queryable <dt_article_attribute, dt_article_inventory>((d, e) => new object[] { JoinType.Left, d.article_id == e.article_id }).Where((d, e) => d.entid == obj.entid && scenarios.Contains(SqlFunc.ToString(d.article_id))).Select((d, e) => new { d.sub_title, d.article_id, d.goodscode, d.drug_factory, d.drug_spec, d.min_package, d.price, e.stock_quantity }).ToList();


                                replenishData.ForEach(d =>
                                {
                                    var mm         = dic.First(m => d.ScnarioID == m.article_id.ToString());
                                    d.SecnarioName = $"商品:{mm.sub_title}&nbsp;&nbsp;&nbsp;生产公司:{mm.drug_factory}&nbsp;&nbsp;&nbsp;规格:{mm.drug_spec}&nbsp;&nbsp;&nbsp;中包装:{mm.min_package}&nbsp;&nbsp;&nbsp;价格:{mm.price}&nbsp;&nbsp;&nbsp;库存:{mm.stock_quantity}";
                                    d.SecnarioCode = mm.goodscode;
                                });
                            }

                            returnJson = JsonConvert.SerializeObject(new PromUpdate()
                            {
                                flag = 0, promRule = model, conditions = conditionData, replenishes = replenishData
                            });
                        }
                        //}
                    }
                }
                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);
        }
Ejemplo n.º 23
0
        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  type = context.Request.QueryString["type"].Trim(); //请求类型
                    string  json = context.Request.QueryString["json"].Trim(); //请求参数(json类型)
                    string  proc = context.Request.QueryString["proc"].Trim(); //存储过程名称
                    JObject obj  = (JObject)JsonConvert.DeserializeObject(json);
                    if (obj["type"] != null)
                    {
                        List <string> rolestr = context.Session["role"] != null ? (List <string>)context.Session["role"] : null;
                        RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr);
                        //if (/*rolestr == null || RoleFuns.SetAdminLog(user.username, obj["type"].ToString(), rolestr) == 0*/false)
                        //{
                        //    returnJson = JsonMethod.GetError(4, "抱歉您没有权限进入!");
                        //}
                        //else {
                        switch (type)
                        {
                        case "ReturnList":
                            returnJson = GetReturnJson(json, proc, user.userId, user.entId);
                            break;

                        case "ReturnDataSet":
                            returnJson = ReturnDataSetJson(json, proc, user.userId, user.entId);
                            break;

                        case "ReturnNumber":
                            returnJson = GetReturnJsonInt(json, proc, user.userId, user.entId);
                            break;

                        case "ReturnListNumber":
                            returnJson = GetReturnDs(json, proc, user.userId, user.entId);
                            break;

                        case "SaveBase":
                            returnJson = SaveBase(json, proc, user.userId, user.entId);
                            break;

                        case "GetWebSiteBase":
                            returnJson = GetWebSiteBase(json, proc, user.userId, user.entId);
                            break;

                        case "GetConfig":
                            //returnJson = GetWebConfig(json, proc, user.userId, user.entId);
                            break;

                        case "jiancerole":
                            returnJson = GetRoleJson(json, proc, user.userId, user.entId);
                            break;

                        case "Jy":
                            returnJson = UpdateUpJson(context.Request.QueryString["status"].Trim(), context.Request.QueryString["strWhere"].Trim());
                            break;

                        case "Qy":
                            returnJson = UpdateUpJson(context.Request.QueryString["status"].Trim(), context.Request.QueryString["strWhere"].Trim());
                            break;

                        case "delUser":
                            returnJson = DelAdminUserJson(context.Request.QueryString["strWhere"].Trim());
                            break;

                        case "delMethod":
                            returnJson = UpdateDelMethodJson(context.Request.QueryString["status"].Trim(), context.Request.QueryString["strWhere"].Trim());
                            break;

                        case "delRole":
                            returnJson = UpdateDelRoleJson(context.Request.QueryString["status"].Trim(), context.Request.QueryString["strWhere"].Trim());
                            break;

                        default:
                            returnJson = JsonMethod.GetError(4, "参数错误!");
                            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);
        }
Ejemplo n.º 24
0
        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 type = context.Request.Params["type"].Trim(); //请求类型
                    string strWhere;
                    int    pageIndex;
                    string status;
                    int    txtType;
                    switch (type)
                    {
                    case "TemplateLIst":
                        strWhere   = context.Request.Params["strWhere"];
                        pageIndex  = int.Parse(context.Request.Params["pageIndex"]);
                        status     = context.Request.Params["Status"];
                        returnJson = GetTemplateReturnJson(strWhere, status, pageIndex);
                        break;

                    case "TemplateRelationLIst":
                        strWhere   = context.Request.Params["strWhere"];
                        pageIndex  = int.Parse(context.Request.Params["pageIndex"]);
                        status     = context.Request.Params["Status"];
                        txtType    = int.Parse(context.Request.Params["txtType"]);
                        returnJson = GetTemplateRelationReturnJson(strWhere, status, txtType, pageIndex);
                        break;

                    case "SaveTemplate":
                        string title   = context.Request.Params["title"];
                        string content = context.Request.Params["content"];
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = SaveTemplate(title, content, strWhere);
                        break;

                    case "SaveTemplateRelation":
                        var sltTemplateRelation = context.Request.Params["sltTemplateRelation"];
                        txtType = int.Parse(context.Request.Params["txtType"]);
                        int txtSortId   = int.Parse(context.Request.Params["txtSortId"]);
                        var sltcategory = context.Request.Params["sltcategory"];
                        var sltprom     = context.Request.Params["sltprom"];
                        var templateimg = context.Request.Params["txtImgUrl"];
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = SaveTemplateRelation(sltprom, sltTemplateRelation, sltcategory, txtType, templateimg, txtSortId, strWhere);
                        break;

                    case "AuditTemplate":
                        strWhere   = context.Request.Params["id"];
                        status     = context.Request.Params["status"];
                        returnJson = SetTemplateStatu(strWhere, status);
                        break;

                    case "AuditTemplateRelation":
                        strWhere   = context.Request.Params["id"];
                        status     = context.Request.Params["status"];
                        returnJson = SetTemplateRelationStatu(strWhere, status);
                        break;

                    case "TemDel":
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = SetTemplateIsDel(strWhere);
                        break;

                    case "TemRelationDel":
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = SetTemplateRelationIsDel(strWhere);
                        break;

                    case "TemplateDetail":
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = GetTemplateDetail(strWhere);
                        break;

                    case "TemplateRelationDetail":
                        strWhere   = context.Request.Params["strWhere"];
                        returnJson = GetTemplateRelationDetail(strWhere);
                        break;

                    case "selectTemplate":
                        returnJson = GetSelectTemplate();
                        break;

                    case "selectCategory":
                        returnJson = GetSelectCategory();
                        break;

                    case "selectTemPro":
                        returnJson = GetSelectTemPro();
                        break;

                    default:
                        returnJson = JsonMethod.GetError(4, "参数错误!");
                        break;
                    }
                }
                else
                {
                    returnJson = JsonMethod.GetError(2, "登陆超时,请重新登陆!");
                }
            }
            catch (Exception e)
            {
                string msg = e.Message.ToString().Trim().Replace("\"", "\\\"").Replace("\r", "").Replace("\n", "");
                returnJson = JsonMethod.GetError(3, msg);
            }
            context.Response.Write(returnJson);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 返回DataTable(渠道分类)
        /// </summary>
        /// <param name="json"></param>
        /// <param name="proc"></param>
        /// <param name="userId"></param>
        /// <param name="entid"></param>
        /// <returns></returns>
        protected string GetReturnJsonBox(string json, string proc, string typename, 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);

            if (ds.Rows.Count > 0)
            {
                ///加载节点
                string    objList = "";
                DataTable dtc     = ds;
                if (dtc.Rows.Count > 0)
                {
                    switch (typename)
                    {
                    case "Pc_GetClassType":    //设备类型//应用范围
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["Code"] + "'>" + dr_c1["Name"] + "</option>";
                        }
                        break;

                    case "Pc_GetCouponType":    //领取类型
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["typeCoding"] + "'>" + dr_c1["typeName"] + "</option>";
                        }
                        break;

                    case "Pc_GetBrandType":    //品牌类型
                        var num = 0;
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            //;
                            objList += "<input type='checkbox' id='chkPpBox" + num + "' value='" + dr_c1["billno"] + "' title='" + dr_c1["name"] + "' />&nbsp;<label for='chkPpBox" + num + "''>" + dr_c1["name"] + "</label>&nbsp;&nbsp;&nbsp;&nbsp";
                            num++;
                        }
                        break;

                    case "Pc_GoodsGroup":    //商品分组
                        var n = 0;
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            //;
                            objList += "<input type='checkbox' id='chkPpBox" + n + "' value='" + dr_c1["billno"] + "' title='" + dr_c1["name"] + "' />&nbsp;<label for='chkPpBox" + n + "''>" + dr_c1["name"] + "</label>&nbsp;&nbsp;&nbsp;&nbsp";
                            n++;
                        }
                        break;

                    case "Pc_GetHelperType":
                    case "Pc_GetCateGoryType":    //分类类型
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["id"] + "'>" + dr_c1["title"] + "</option>";
                        }
                        break;

                    case "Pc_GetShengType":    //省
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["id"] + "'>" + dr_c1["name"] + "</option>";
                        }
                        break;

                    case "Pc_GetShiType":    //市
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["id"] + "'>" + dr_c1["name"] + "</option>";
                        }
                        break;

                    case "Pc_GetQuType":    //区
                        foreach (DataRow dr_c1 in dtc.Rows)
                        {
                            objList += "<option value='" + dr_c1["id"] + "'>" + dr_c1["name"] + "</option>";
                        }
                        break;

                    default:
                        break;
                    }
                }
                return("{\"flag\":\"0\",\"objList\":\"" + objList + "\"}");
            }
            else
            {
                string error = "无数据";
                return(JsonMethod.GetError(1, error));
            }
        }
Ejemplo n.º 26
0
        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 type = context.Request.QueryString["type"].Trim();//请求类型
                    string json = context.Request.QueryString["json"].Trim();//请求参数(json类型)
                    //string proc = context.Request.QueryString["proc"].Trim();//存储过程名称
                    var obj  = JsonConvert.DeserializeObject <PromData>(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);

                        if (type == "SaveProm")
                        {
                            var db = new SqlSugarDb();

                            var fabh = "";
                            if (string.IsNullOrWhiteSpace(obj.ruleCode))
                            {
                                db.Db.Ado.UseTran(() =>
                                {
                                    var maxbh = db.Db.Queryable <dt_Maxbh>().First(d => d.BiaoShi == "FAR")?.maxbh ?? "0";
                                    var nowBh = (int.Parse(maxbh) + 1).ToString();
                                    db.Db.Updateable <dt_Maxbh>().SetColumns(d => new dt_Maxbh {
                                        maxbh = nowBh
                                    }).Where(d => d.BiaoShi == "FAR").ExecuteCommand();
                                    fabh = "FAR" + nowBh.PadLeft(11, '0');
                                });
                            }
                            else
                            {
                                fabh = obj.ruleCode;
                                db.Db.Deleteable <SC_T_PromRuleCondition>().Where(d => d.entid == user.entId && d.ruleCode == fabh).ExecuteCommand();
                                db.Db.Deleteable <SC_T_PromRuleReplenish>().Where(d => d.entid == user.entId && d.ruleCode == fabh).ExecuteCommand();
                            }
                            var prom = new SC_T_PromRule();
                            prom.ruleCode     = fabh;
                            prom.entid        = user.entId;
                            prom.faType       = obj.faType;
                            prom.PromScenario = "3";
                            prom.limitAmount  = obj.xgAmount;
                            prom.Amount       = obj.Quantity;
                            prom.contentType  = "0";
                            prom.customerType = obj.customerType;
                            prom.describe     = obj.describe;
                            prom.moreBuy      = "0";
                            prom.ruleTitle    = obj.faname;
                            var group     = JsonConvert.DeserializeObject <List <PromGroupModel> >(obj.lsid);
                            var groupList = new List <SC_T_PromRuleCondition>();
                            var repList   = new List <SC_T_PromRuleReplenish>();
                            var groupSn   = 1;
                            var b         = prom.faType == "GZH";//判断是否是组合
                            foreach (var item in group)
                            {
                                groupList.Add(new SC_T_PromRuleCondition()
                                {
                                    rule_sn      = groupSn,
                                    PromScenario = prom.PromScenario,
                                    entid        = user.entId,
                                    faType       = prom.faType,
                                    giftPrice    = decimal.Parse(item.Price),
                                    giftQuantity = b ? decimal.Parse(item.shl) : 0,
                                    meetCount    = b ? 0 : decimal.Parse(item.MeetCount),
                                    ruleCode     = fabh
                                });
                                repList.Add(new SC_T_PromRuleReplenish()
                                {
                                    rule_sn       = groupSn,
                                    entid         = user.entId,
                                    faType        = prom.faType,
                                    ScnarioID     = item.GoodsId,
                                    maxQuantity   = b ? obj.Quantity * decimal.Parse(item.shl) : decimal.Parse(item.Total),
                                    limitQuantity = b ? obj.xgAmount * decimal.Parse(item.shl) : decimal.Parse(item.Limit),
                                    ruleCode      = fabh
                                });
                                groupSn++;
                            }

                            db.Db.Insertable(groupList).ExecuteCommand();
                            db.Db.Insertable(repList).ExecuteCommand();
                            if (string.IsNullOrWhiteSpace(obj.ruleCode))
                            {
                                db.Db.Insertable(prom).ExecuteCommand();
                            }
                            else
                            {
                                db.Db.Updateable(prom).Where(d => d.entid == user.entId && d.ruleCode == obj.ruleCode).ExecuteCommand();
                            }
                            returnJson = JsonMethod.GetError(0, "操作成功");
                        }
                        if (type == "QuerySingleProm")
                        {
                            var db        = new SqlSugarDb();
                            var model     = db.Db.Queryable <SC_T_PromRule>().First(d => d.entid == obj.entid && d.ruleCode == obj.ruleCode);
                            var condition = db.Db.Queryable <SC_T_PromRuleCondition, SC_T_PromRuleReplenish>((d, e) => new object[] {
                                JoinType.Left,
                                d.entid == e.entid && d.ruleCode == e.ruleCode && d.rule_sn == e.rule_sn
                            })
                                            .Where(d => d.entid == obj.entid && d.ruleCode == obj.ruleCode).Select((d, e) => new GroupReplenishes
                            {
                                entid         = d.entid,
                                rule_sn       = d.rule_sn,
                                faType        = d.faType,
                                giftPrice     = d.giftPrice,
                                giftQuantity  = d.giftQuantity,
                                meetCount     = d.meetCount,
                                ruleCode      = d.ruleCode,
                                maxQuantity   = e.maxQuantity,
                                limitQuantity = e.limitQuantity,
                                giftGoodsID   = e.ScnarioID
                            }).ToList();

                            var scenarios = condition.Select(d => d.giftGoodsID).ToList();

                            var dic = db.Db.Queryable <dt_article_attribute, dt_article_inventory>((d, e) => new object[] { JoinType.Left, d.article_id == e.article_id }).Where((d, e) => d.entid == obj.entid && scenarios.Contains(SqlFunc.ToString(d.article_id))).Select((d, e) => new { d.sub_title, d.article_id, d.goodscode, d.drug_factory, d.drug_spec, d.min_package, d.price, e.stock_quantity }).ToList();

                            condition.ForEach(d =>
                            {
                                var goods        = dic.First(m => d.giftGoodsID == m.article_id.ToString());
                                d.stock_quantity = goods.stock_quantity.ToString();
                                d.sub_title      = goods.sub_title;
                                d.price          = goods.price.ToString();
                                d.min_package    = goods.min_package.ToString();
                                d.goodscode      = goods.goodscode;
                                d.drug_spec      = goods.drug_spec;
                                d.drug_factory   = goods.drug_factory;
                            });


                            returnJson = JsonConvert.SerializeObject(new PromGroupUpdate()
                            {
                                flag = 0, promRule = model, conditions = condition
                            });
                        }
                    }
                }
                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);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// 用户退出登陆
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 protected string loginOut(HttpContext context)
 {
     context.Session["user"] = null;
     context.Session["role"] = null;
     return(JsonMethod.GetError(0, "退出成功"));
 }