Esempio n. 1
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 join City c on a.CityID=c.CityID 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 + "/Content/";
                        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);
            }
        }
Esempio n. 2
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,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 join City c on a.CityID=c.CityID 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 + "/Content/";
                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);
            }
        }