Пример #1
0
        public static dynamic GetByID(int workId)
        {
            var Request = HttpContext.Current.Request;

            using (SL.Data.Database db = SL.Data.Database.Open())
            {
                var data = db.QuerySingle("select w.WorkID,w.WorkName,w.WorkDesc,w.ProductID,w.Swf,a.ProductName,a.Price,w.SoldNum,a.BaseInfo,a.Content,a.SubID,b.SubName,c.CategoryID,c.CategoryName from Work w join Product a on w.ProductID=a.ProductID join SubCate b on a.SubID=b.SubID join Category c on b.CategoryID=c.CategoryID where w.WorkID=@p0 and w.Deleted=0 and a.Deleted=0", workId);
                if (data == null)
                {
                    return(null);
                }
                int    productId = (int)data["ProductID"];
                string baseInfo  = (string)data["BaseInfo"];
                if (!string.IsNullOrEmpty(baseInfo))
                {
                    data["BaseInfo"] = Json.Decode <IList <IDictionary <string, object> > >(baseInfo);
                }
                else if (baseInfo == "")
                {
                    data["BaseInfo"] = null;
                }

                if (!string.IsNullOrEmpty((string)data["Content"]))
                {
                    data["Content"] = System.Text.RegularExpressions.Regex.Replace(data["Content"].ToString(), @"src=""/", "src=\"http://" + Request.Url.Authority + "/", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                }

                data["Colors"] = db.Query("select ColorID,ColorName,ColorCode from Color where ProductID=@p0", productId);
                data["Styles"] = db.Query("select a.StyleID,StyleName,Rect,ColorID,SizeID,[Print],Content from Style a left join Customization b on a.StyleID=b.StyleID where WorkID=@p0 order by a.StyleID", workId);
                data["Size"]   = db.Query("select SizeID,SizeName,StyleID from ProductSize where ProductID=@p0", productId);

                var styleColorPic = db.Query("select PicID,StyleID,ColorID,Picture from StyleColorPic where ProductID=@p0", productId);
                data["StyleColorPic"] = styleColorPic;

                if (styleColorPic != null)
                {
                    styleColorPic.All(a =>
                    {
                        if (!string.IsNullOrEmpty(a.Picture))
                        {
                            a.Picture = Regex.Replace(a.Picture, @"http://([^/])+/", "http://" + Request.Url.Authority + "/");
                        }
                        return(true);
                    });
                }

                return(data);
            }
        }
Пример #2
0
        public static IList <dynamic> GetOrders(int page, int pageSize, out int total, string sqlWhere, IEnumerable <object> sqlParams)
        {
            using (SL.Data.Database db = SL.Data.Database.Open())
            {
                string where = "1=1";
                List <object> parameters = new List <object>();

                if (!string.IsNullOrEmpty(sqlWhere))
                {
                    where += " and " + sqlWhere;
                    parameters.AddRange(sqlParams);
                }

                var list = db.QueryPage("OrderID", "OrderID,OrderCode,Amount,Freight,a.Discount,a.AddTime,a.Status,a.UserID,a.PaymentID,a.Receiver,a.Address,a.Mobile,a.Phone,a.Zip,b.Account,a.CityID,a.RegionID,c.CityName,e.RegionName,d.ProvName",
                                        "OrderInfo a join Users b on a.UserID=b.UserID left join City c on a.CityID=c.CityID left join Province d on c.ProvID=d.ProvID left join Region e on a.RegionID=e.RegionID",
                                        where,
                                        page,
                                        pageSize,
                                        parameters.ToArray(),
                                        out total);

                if (list != null)
                {
                    foreach (var data in list)
                    {
                        var detailList = db.Query("select c.OrderID,c.OrderDetailID,c.UserWorkID,c.Qty,a.ProductID,b.ProductName,a.Picture,b.Price from OrderDetail c join UserWork a on c.UserWorkID=a.UserWorkID join Product b on a.ProductID=b.ProductID where OrderID=@p0", (int)data.OrderID);

                        string url = "http://" + HttpContext.Current.Request.Url.Authority + "/";
                        detailList.All(a =>
                        {
                            a["Picture"] = url + a["Picture"];
                            a["Styles"]  = db.Query("select a.StyleID,StyleName,Rect,b.ColorID,c.ColorName,b.SizeID,SizeName from Style a left join UserCustomization b on a.StyleID=b.StyleID left join Color c on b.ColorID=c.ColorID left join ProductSize d on b.SizeID=d.SizeID where UserWorkID=@p0 order by a.StyleID", a["UserWorkID"]);
                            return(true);
                        });
                        data["Details"] = detailList;

                        data["PaymentName"] = PaymentService.Payments.First(a => (int)a["PaymentID"] == (int)data["PaymentID"])["PaymentName"];
                        data["Total"]       = (decimal)data["Freight"] + (decimal)data["Amount"];
                    }
                }
                return(list);
            }
        }
Пример #3
0
        public static dynamic GetOrder(int orderid, int uid)
        {
            using (SL.Data.Database db = SL.Data.Database.Open())
            {
                var data = db.QuerySingle("select OrderID,OrderCode,Inv,Amount,Freight,a.Discount,a.AddTime,a.Status,a.UserID,a.PaymentID,a.Receiver,a.Address,a.Mobile,a.Phone,a.Zip,b.Account,a.CityID,a.RegionID,c.CityName,e.RegionName,d.ProvName from OrderInfo a join Users b on a.UserID=b.UserID left join City c on a.CityID=c.CityID left join Province d on c.ProvID=d.ProvID left join Region e on a.RegionID=e.RegionID where OrderID=@p0 and a.UserID=@p1", orderid, uid);

                var detailList = db.Query("select c.OrderID,c.OrderDetailID,c.UserWorkID,c.Qty,a.ProductID,b.ProductName,a.Picture,b.Price from OrderDetail c join UserWork a on c.UserWorkID=a.UserWorkID join Product b on a.ProductID=b.ProductID where OrderID=@p0", orderid);

                string url = "http://" + HttpContext.Current.Request.Url.Authority + "/";
                detailList.All(a =>
                {
                    a["Picture"] = url + a["Picture"];
                    a["Styles"]  = db.Query("select a.StyleID,StyleName,Rect,b.ColorID,c.ColorName,b.SizeID,SizeName from Style a left join UserCustomization b on a.StyleID=b.StyleID left join Color c on b.ColorID=c.ColorID left join ProductSize d on b.SizeID=d.SizeID where UserWorkID=@p0 order by a.StyleID", a["UserWorkID"]);
                    return(true);
                });
                data["Details"] = detailList;

                data["PaymentName"] = PaymentService.Payments.First(a => (int)a["PaymentID"] == (int)data["PaymentID"])["PaymentName"];
                data["Total"]       = (decimal)data["Freight"] + (decimal)data["Amount"];

                return(data);
            }
        }