Example #1
0
        private string getDataDetail(HttpContext context)
        {
            string id = "";

            if (context.Request.Params["id"] != null)
            {
                id = context.Request.Params["id"];
            }
            WK.BLL.bus_market   bll   = new WK.BLL.bus_market();
            WK.Model.bus_market model = bll.GetModel(int.Parse(id));

            #region 自提点
            WK.BLL.bus_pickup_market marketBll = new BLL.bus_pickup_market();
            StringBuilder            strWhere  = new StringBuilder();
            strWhere.Append(" is_delete != 1");
            strWhere.AppendFormat(" and market_id = {0}", id);
            DataSet ds = new DataSet();
            ds = marketBll.GetList(strWhere.ToString());
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                model.pickup_address_id = int.Parse(ds.Tables[0].Rows[0]["pickup_address_id"].ToString());
            }
            #endregion

            #region 图片
            WK.BLL.bus_image imageBll   = new BLL.bus_image();
            StringBuilder    imageWhere = new StringBuilder();
            imageWhere.Append(" is_delete != 1");
            imageWhere.AppendFormat(" and correlation_id  = {0}", id);
            imageWhere.AppendFormat(" and bus_type   = {0}", 1);
            DataSet dsImage = new DataSet();
            dsImage = imageBll.GetList(imageWhere.ToString());
            string imageList = string.Empty;
            if (dsImage != null && dsImage.Tables.Count > 0 && dsImage.Tables[0].Rows.Count > 0)
            {
                int imageCount = dsImage.Tables[0].Rows.Count;
                for (int i = 0; i < imageCount; i++)
                {
                    imageList += dsImage.Tables[0].Rows[i]["url"] + "||" + dsImage.Tables[0].Rows[i]["img_type"] + ";";
                }
            }
            model.imageList = imageList;
            #endregion

            return(Newtonsoft.Json.JsonConvert.SerializeObject(model));
        }
Example #2
0
        private string editData(HttpContext context)
        {
            WK.Model.bus_dish model = new Model.bus_dish();
            int id = 0;

            if (context.Request.Params["id"] != null && context.Request.Params["id"].ToString() != "")
            {
                id = int.Parse(context.Request.Params["id"]);
            }
            model.id = id;
            //model.create_by
            //model.create_date
            model.description_cn = context.Request.Params["description_cn"];
            model.description_en = context.Request.Params["description_en"];
            model.discount_price = decimal.Parse(context.Request.Params["discount_price"]);
            model.dish_tag       = context.Request.Params["dish_tag"];             //
            model.dish_time      = int.Parse(context.Request.Params["dish_time"]); //菜品提供的时间,1周末2工作日3全周
            model.eat_type       = int.Parse(context.Request.Params["eat_type"]);  //1午餐2晚餐3所有
            model.is_delete      = 0;
            model.market_id      = int.Parse(context.Request.Params["market_id"]);
            model.name_cn        = context.Request.Params["name_cn"];
            model.name_en        = context.Request.Params["name_en"];
            model.original_price = decimal.Parse(context.Request.Params["original_price"]);
            model.remark         = context.Request.Params["remark"];
            model.sales_total    = int.Parse(context.Request.Params["sales_total"]);
            model.sort           = int.Parse(context.Request.Params["sort"]);
            model.status         = int.Parse(context.Request.Params["status"]);//1启用 2停用
            //model.update_by
            //model.update_date

            WK.BLL.bus_dish bll = new WK.BLL.bus_dish();
            id = model.id > 0 ? model.id : bll.GetMaxId();
            ReturnInfo returnInfo = new ReturnInfo();

            returnInfo.isSuccess = model.id > 0 ? bll.Update(model) : bll.Add(model);

            #region 菜品规格
            string dishSizeList = string.Empty;
            if (context.Request.Params["dishSizeList"] != null)
            {
                dishSizeList = context.Request.Params["dishSizeList"].ToString();
            }
            if (dishSizeList != "")
            {
                WK.BLL.bus_dish_size sizeBll   = new BLL.bus_dish_size();
                StringBuilder        sizeWhere = new StringBuilder();
                sizeWhere.Append(" is_delete != 1");
                sizeWhere.AppendFormat(" and dish_id  = {0}", id);
                DataSet dsSize = sizeBll.GetList(sizeWhere.ToString());
                if (dsSize != null &&
                    dsSize.Tables.Count > 0 &&
                    dsSize.Tables[0].Rows.Count > 0)
                {
                    int dsSizeCount = dsSize.Tables[0].Rows.Count;
                    for (int i = 0; i < dsSizeCount; i++)
                    {
                        int sizeId = int.Parse(dsSize.Tables[0].Rows[i]["id"].ToString());
                        sizeBll.Delete(sizeId);
                    }
                }

                Object anArray           = Newtonsoft.Json.JsonConvert.DeserializeObject(dishSizeList);
                int    dishSizeListCount = ((Newtonsoft.Json.Linq.JContainer)(anArray)).Count;
                for (int i = 0; i < dishSizeListCount; i++)
                {
                    string name         = ((Newtonsoft.Json.Linq.JContainer)(anArray))[i]["name"].ToString();
                    string affect_price = ((Newtonsoft.Json.Linq.JContainer)(anArray))[i]["affect_price"].ToString();
                    WK.Model.bus_dish_size sizeModel = new Model.bus_dish_size();
                    sizeModel.affect_price = decimal.Parse(affect_price);
                    sizeModel.dish_id      = id;
                    sizeModel.is_delete    = 0;
                    sizeModel.name         = name;
                    sizeBll.Add(sizeModel);
                }
            }
            #endregion

            #region 图片
            string listImage = string.Empty;
            if (context.Request.Params["listImage"] != null)
            {
                listImage = context.Request.Params["listImage"].ToString();
            }
            if (listImage != "")
            {
                WK.BLL.bus_image imageBll   = new BLL.bus_image();
                StringBuilder    imageWhere = new StringBuilder();
                imageWhere.Append(" is_delete != 1");
                imageWhere.AppendFormat(" and correlation_id  = {0}", id);
                imageWhere.AppendFormat(" and bus_type   = {0}", 2);
                DataSet dsImage = new DataSet();
                dsImage = imageBll.GetList(imageWhere.ToString());
                string imageList = string.Empty;
                if (dsImage != null && dsImage.Tables.Count > 0 && dsImage.Tables[0].Rows.Count > 0)
                {
                    int imageCount = dsImage.Tables[0].Rows.Count;
                    for (int i = 0; i < imageCount; i++)
                    {
                        int imageId = int.Parse(dsImage.Tables[0].Rows[i]["id"].ToString());
                        imageBll.Delete(imageId);
                    }
                }

                Object imageArray     = Newtonsoft.Json.JsonConvert.DeserializeObject(listImage);
                int    listImageCount = ((Newtonsoft.Json.Linq.JContainer)(imageArray)).Count;
                for (int i = 0; i < listImageCount; i++)
                {
                    string             url        = ((Newtonsoft.Json.Linq.JContainer)(imageArray))[i]["url"].ToString();
                    WK.Model.bus_image imageModel = new Model.bus_image();
                    imageModel.bus_type       = 2;
                    imageModel.correlation_id = id;
                    imageModel.img_type       = 1;
                    imageModel.sort           = i + 1;
                    imageModel.url            = url;
                    imageBll.Add(imageModel);
                }
            }
            #endregion


            return(Newtonsoft.Json.JsonConvert.SerializeObject(returnInfo));
        }
Example #3
0
        private string getDataDetail(HttpContext context)
        {
            string id = "";

            if (context.Request.Params["id"] != null)
            {
                id = context.Request.Params["id"];
            }
            WK.BLL.bus_dish   bll   = new WK.BLL.bus_dish();
            WK.Model.bus_dish model = bll.GetModel(int.Parse(id));

            #region 菜品规格
            List <WK.Model.bus_dish_size> listSize = new List <Model.bus_dish_size>();
            WK.BLL.bus_dish_size          sizeBll  = new BLL.bus_dish_size();
            StringBuilder sizeWhere = new StringBuilder();
            sizeWhere.Append(" is_delete != 1");
            sizeWhere.AppendFormat(" and dish_id  = {0}", id);
            DataSet dsSize       = sizeBll.GetList(sizeWhere.ToString());
            string  dishSizeList = string.Empty;
            if (dsSize != null &&
                dsSize.Tables.Count > 0 &&
                dsSize.Tables[0].Rows.Count > 0)
            {
                int sizeCount = dsSize.Tables[0].Rows.Count;
                for (int i = 0; i < sizeCount; i++)
                {
                    WK.Model.bus_dish_size sizeModel = new Model.bus_dish_size();
                    sizeModel.id           = int.Parse(dsSize.Tables[0].Rows[i]["id"].ToString());
                    sizeModel.affect_price = decimal.Parse(dsSize.Tables[0].Rows[i]["affect_price"].ToString());
                    sizeModel.dish_id      = int.Parse(dsSize.Tables[0].Rows[i]["dish_id"].ToString());
                    sizeModel.name         = dsSize.Tables[0].Rows[i]["name"].ToString();
                    listSize.Add(sizeModel);
                }
            }
            model.listSize = listSize;
            #endregion

            #region 图片
            List <WK.Model.bus_image> listImage  = new List <Model.bus_image>();
            WK.BLL.bus_image          imageBll   = new BLL.bus_image();
            StringBuilder             imageWhere = new StringBuilder();
            imageWhere.Append(" is_delete != 1");
            imageWhere.AppendFormat(" and correlation_id  = {0}", id);
            imageWhere.AppendFormat(" and bus_type   = {0}", 2);
            DataSet dsImage = new DataSet();
            dsImage = imageBll.GetList(imageWhere.ToString());
            string imageList = string.Empty;
            if (dsImage != null && dsImage.Tables.Count > 0 && dsImage.Tables[0].Rows.Count > 0)
            {
                int imageCount = dsImage.Tables[0].Rows.Count;
                for (int i = 0; i < imageCount; i++)
                {
                    WK.Model.bus_image imageModel = new Model.bus_image();
                    imageModel.bus_type       = int.Parse(dsImage.Tables[0].Rows[i]["bus_type"].ToString());
                    imageModel.correlation_id = int.Parse(dsImage.Tables[0].Rows[i]["correlation_id"].ToString());
                    imageModel.img_type       = int.Parse(dsImage.Tables[0].Rows[i]["img_type"].ToString());
                    imageModel.sort           = int.Parse(dsImage.Tables[0].Rows[i]["sort"].ToString());
                    imageModel.url            = dsImage.Tables[0].Rows[i]["url"].ToString();
                    listImage.Add(imageModel);
                }
            }
            model.listImage = listImage;
            #endregion
            return(Newtonsoft.Json.JsonConvert.SerializeObject(model));
        }
Example #4
0
        private string editData(HttpContext context)
        {
            WK.Model.bus_market model = new Model.bus_market();

            model.id = 0;
            if (context.Request.Params["id"] != null && context.Request.Params["id"].ToString() != "")
            {
                model.id = int.Parse(context.Request.Params["id"]);
            }
            model.address = context.Request.Params["address"];
            model.area_id = 0;
            if (context.Request.Params["area_id"] != null &&
                context.Request.Params["area_id"].ToString() != "")
            {
                model.area_id = int.Parse(context.Request.Params["area_id"]);
            }
            model.description_cn = context.Request.Params["description_cn"];
            model.description_en = context.Request.Params["description_en"];
            model.lat            = decimal.Parse(context.Request.Params["lat"]);
            model.lon            = decimal.Parse(context.Request.Params["lon"]);
            model.market_type    = context.Request.Params["market_type"];
            model.markket_code   = context.Request.Params["markket_code"];
            model.name_cn        = context.Request.Params["name_cn"];
            model.name_en        = context.Request.Params["name_en"];
            model.remark         = context.Request.Params["remark"];
            model.sort           = int.Parse(context.Request.Params["sort"]);
            model.status         = int.Parse(context.Request.Params["status"]);
            model.address        = context.Request.Params["address"];


            WK.BLL.bus_market bll = new WK.BLL.bus_market();
            int market_id         = 0;

            if (model.id > 0)
            {
                market_id = model.id;
            }
            else
            {
                market_id = bll.GetMaxId();
            }
            ReturnInfo returnInfo = new ReturnInfo();

            returnInfo.isSuccess = model.id > 0 ? bll.Update(model) : bll.Add(model);

            #region 自提点列表
            int pickup_address_id = 0;
            if (context.Request.Params["pickup_address_id"] != null &&
                context.Request.Params["pickup_address_id"].ToString() != "")
            {
                pickup_address_id = int.Parse(context.Request.Params["pickup_address_id"]);
            }
            if (pickup_address_id > 0)
            {
                WK.BLL.bus_pickup_market marketBll = new BLL.bus_pickup_market();
                StringBuilder            strWhere  = new StringBuilder();
                strWhere.Append(" is_delete != 1");
                strWhere.AppendFormat(" and market_id = {0}", market_id);
                DataSet ds = new DataSet();
                ds = marketBll.GetList(strWhere.ToString());
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                }
                else
                {
                    WK.Model.bus_pickup_market marketModel = new Model.bus_pickup_market();
                    marketModel.is_delete         = 0;
                    marketModel.market_id         = market_id;
                    marketModel.pickup_address_id = pickup_address_id;
                    marketBll.Add(marketModel);
                }
            }
            #endregion

            #region 图片列表

            WK.BLL.bus_image imageBll   = new BLL.bus_image();
            StringBuilder    imageWhere = new StringBuilder();
            imageWhere.Append(" is_delete != 1");
            imageWhere.AppendFormat(" and correlation_id  = {0}", market_id);
            imageWhere.AppendFormat(" and bus_type   = {0}", 1);
            DataSet dsImage = new DataSet();
            dsImage = imageBll.GetList(imageWhere.ToString());

            if (dsImage != null && dsImage.Tables.Count > 0 && dsImage.Tables[0].Rows.Count > 0)
            {
                int imageCount = dsImage.Tables[0].Rows.Count;
                for (int i = 0; i < imageCount; i++)
                {
                    int imageId = int.Parse(dsImage.Tables[0].Rows[i]["id"].ToString());
                    imageBll.Delete(imageId);
                }
            }

            string imageList      = context.Request.Params["imageList"].ToString();
            Object anArray        = Newtonsoft.Json.JsonConvert.DeserializeObject(imageList);
            int    imageListCount = ((Newtonsoft.Json.Linq.JContainer)(anArray)).Count;
            for (int i = 0; i < imageListCount; i++)
            {
                string             imageKey   = ((Newtonsoft.Json.Linq.JContainer)(anArray))[i]["imageKey"].ToString();
                WK.Model.bus_image imageModel = new Model.bus_image();
                imageModel.bus_type       = 1; //业务类型(商户/菜)
                imageModel.correlation_id = market_id;
                imageModel.img_type       = 1; //图片类型(详情图/缩略图)
                imageModel.is_delete      = 0;
                imageModel.url            = imageKey;
                imageBll.Add(imageModel);
            }
            #endregion

            return(Newtonsoft.Json.JsonConvert.SerializeObject(returnInfo));
        }