Esempio n. 1
0
 public List<Maticsoft.Model.Shop.Products.SKUInfo> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.SKUInfo> list = new List<Maticsoft.Model.Shop.Products.SKUInfo>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.SKUInfo item = new Maticsoft.Model.Shop.Products.SKUInfo();
             if ((dt.Rows[i]["SkuId"] != null) && (dt.Rows[i]["SkuId"].ToString() != ""))
             {
                 item.SkuId = long.Parse(dt.Rows[i]["SkuId"].ToString());
             }
             if ((dt.Rows[i]["ProductId"] != null) && (dt.Rows[i]["ProductId"].ToString() != ""))
             {
                 item.ProductId = long.Parse(dt.Rows[i]["ProductId"].ToString());
             }
             if ((dt.Rows[i]["SKU"] != null) && (dt.Rows[i]["SKU"].ToString() != ""))
             {
                 item.SKU = dt.Rows[i]["SKU"].ToString();
             }
             if ((dt.Rows[i]["Weight"] != null) && (dt.Rows[i]["Weight"].ToString() != ""))
             {
                 item.Weight = new int?(int.Parse(dt.Rows[i]["Weight"].ToString()));
             }
             if ((dt.Rows[i]["Stock"] != null) && (dt.Rows[i]["Stock"].ToString() != ""))
             {
                 item.Stock = int.Parse(dt.Rows[i]["Stock"].ToString());
             }
             if ((dt.Rows[i]["AlertStock"] != null) && (dt.Rows[i]["AlertStock"].ToString() != ""))
             {
                 item.AlertStock = int.Parse(dt.Rows[i]["AlertStock"].ToString());
             }
             if ((dt.Rows[i]["CostPrice"] != null) && (dt.Rows[i]["CostPrice"].ToString() != ""))
             {
                 item.CostPrice = new decimal?(decimal.Parse(dt.Rows[i]["CostPrice"].ToString()));
             }
             if ((dt.Rows[i]["SalePrice"] != null) && (dt.Rows[i]["SalePrice"].ToString() != ""))
             {
                 item.SalePrice = decimal.Parse(dt.Rows[i]["SalePrice"].ToString());
             }
             if ((dt.Rows[i]["Upselling"] != null) && (dt.Rows[i]["Upselling"].ToString() != ""))
             {
                 if ((dt.Rows[i]["Upselling"].ToString() == "1") || (dt.Rows[i]["Upselling"].ToString().ToLower() == "true"))
                 {
                     item.Upselling = true;
                 }
                 else
                 {
                     item.Upselling = false;
                 }
             }
             list.Add(item);
         }
     }
     return list;
 }
Esempio n. 2
0
 private Maticsoft.Model.Shop.Products.SKUInfo GetSKUInfo4Obj(JsonData jsonData)
 {
     Maticsoft.Model.Shop.Products.SKUInfo info = null;
     if (!jsonData.IsObject)
     {
         return null;
     }
     info = new Maticsoft.Model.Shop.Products.SKUInfo {
         SKU = jsonData["SKU"].ToString()
     };
     string str = jsonData["CostPrice"].ToString();
     if (!string.IsNullOrWhiteSpace(str))
     {
         info.CostPrice = new decimal?(Globals.SafeDecimal(str, (decimal) -1M));
     }
     info.SalePrice = Globals.SafeDecimal(jsonData["SalePrice"].ToString(), (decimal) -1M);
     this.salePriceList.Add(info.SalePrice);
     info.Stock = Globals.SafeInt(jsonData["Stock"].ToString(), -1);
     info.AlertStock = Globals.SafeInt(jsonData["AlertStock"].ToString(), -1);
     info.Weight = new int?(Globals.SafeInt(jsonData["Weight"].ToString(), -1));
     info.Upselling = Globals.SafeBool(jsonData["Upselling"].ToString(), false);
     if (jsonData["SKUItems"].IsArray && (jsonData["SKUItems"].Count > 0))
     {
         foreach (JsonData data in (IEnumerable) jsonData["SKUItems"])
         {
             string str2 = string.Empty;
             if (!string.IsNullOrWhiteSpace(data["ImageUrl"].ToString()))
             {
                 str2 = data["ImageUrl"].ToString().Replace(this.tempFile, this.skuImageFile);
                 string format = data["ImageUrl"].ToString().Replace(this.tempFile, "");
                 if (!this.skuImageList.Contains(string.Format(format, "T32X32_")))
                 {
                     this.skuImageList.Add(string.Format(format, "T32X32_"));
                     this.skuImageList.Add(string.Format(format, "T130X130_"));
                     this.skuImageList.Add(string.Format(format, "T300X390_"));
                 }
             }
             Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem {
                 AttributeId = Globals.SafeLong(data["AttributeId"].ToString(), (long) (-1L)),
                 ValueId = Globals.SafeLong(data["ValueId"].ToString(), (long) (-1L)),
                 ImageUrl = str2,
                 ValueStr = data["ValueStr"].ToString()
             };
             info.SkuItems.Add(item);
         }
     }
     return info;
 }
Esempio n. 3
0
 private List<Maticsoft.Model.Shop.Products.SKUInfo> GetSKUInfosData(string where, string orderby, int startIndex, int endIndex, out int dataCount, long productId)
 {
     Predicate<Maticsoft.Model.Shop.Products.SKUInfo> match = null;
     long tmpSkuId;
     List<Maticsoft.Model.Shop.Products.SKUInfo> list = new List<Maticsoft.Model.Shop.Products.SKUInfo>();
     DataSet ds = this.dal.GetSKUListByPage(where, orderby, startIndex, endIndex, out dataCount, productId);
     if (DataSetTools.DataSetIsNull(ds))
     {
         return null;
     }
     foreach (DataRow row in ds.Tables[0].Rows)
     {
         tmpSkuId = row.Field<long>("SkuId");
         if (match == null)
         {
             match = info => info.SkuId == tmpSkuId;
         }
         Maticsoft.Model.Shop.Products.SKUInfo info = list.Find(match);
         if (info == null)
         {
             info = new Maticsoft.Model.Shop.Products.SKUInfo {
                 SkuId = tmpSkuId,
                 ProductId = row.Field<long>("ProductId"),
                 SKU = row.Field<string>("SKU"),
                 Weight = row.Field<int?>("Weight"),
                 Stock = row.Field<int>("Stock"),
                 AlertStock = row.Field<int>("AlertStock"),
                 CostPrice = row.Field<decimal?>("CostPrice"),
                 SalePrice = row.Field<decimal>("SalePrice"),
                 Upselling = row.Field<bool>("Upselling"),
                 ProductName = row.Field<string>("ProductName"),
                 ProductImageUrl = row.Field<string>("ImageUrl"),
                 ProductThumbnailUrl = row.Field<string>("ThumbnailUrl1")
             };
             list.Add(info);
         }
         Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem {
             AttributeId = row.Field<long>("AttributeId"),
             ValueId = row.Field<long>("ValueId"),
             ValueStr = row.Field<string>("ValueStr"),
             ImageUrl = row.Field<string>("ImageUrl")
         };
         info.SkuItems.Add(item);
     }
     List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = new List<Maticsoft.Model.Shop.Products.SKUInfo>();
     dataCount = list.Count;
     if (dataCount <= (startIndex - 1))
     {
         return list;
     }
     for (int i = startIndex - 1; (i < endIndex) && (i < list.Count); i++)
     {
         list2.Add(list[i]);
     }
     return list2;
 }
Esempio n. 4
0
 public Maticsoft.Model.Shop.Products.SKUInfo GetModelBySKU(string sku)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT  TOP 1 SkuId,ProductId,SKU,Weight,Stock,AlertStock,CostPrice,SalePrice,Upselling FROM Shop_SKUs ");
     builder.Append(" WHERE SKU=@SKU");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@SKU", SqlDbType.NVarChar, 50) };
     cmdParms[0].Value = sku;
     Maticsoft.Model.Shop.Products.SKUInfo info = new Maticsoft.Model.Shop.Products.SKUInfo();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["SkuId"] != null) && (set.Tables[0].Rows[0]["SkuId"].ToString() != ""))
     {
         info.SkuId = long.Parse(set.Tables[0].Rows[0]["SkuId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ProductId"] != null) && (set.Tables[0].Rows[0]["ProductId"].ToString() != ""))
     {
         info.ProductId = long.Parse(set.Tables[0].Rows[0]["ProductId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["SKU"] != null) && (set.Tables[0].Rows[0]["SKU"].ToString() != ""))
     {
         info.SKU = set.Tables[0].Rows[0]["SKU"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Weight"] != null) && (set.Tables[0].Rows[0]["Weight"].ToString() != ""))
     {
         info.Weight = new int?(int.Parse(set.Tables[0].Rows[0]["Weight"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Stock"] != null) && (set.Tables[0].Rows[0]["Stock"].ToString() != ""))
     {
         info.Stock = int.Parse(set.Tables[0].Rows[0]["Stock"].ToString());
     }
     if ((set.Tables[0].Rows[0]["AlertStock"] != null) && (set.Tables[0].Rows[0]["AlertStock"].ToString() != ""))
     {
         info.AlertStock = int.Parse(set.Tables[0].Rows[0]["AlertStock"].ToString());
     }
     if ((set.Tables[0].Rows[0]["CostPrice"] != null) && (set.Tables[0].Rows[0]["CostPrice"].ToString() != ""))
     {
         info.CostPrice = new decimal?(decimal.Parse(set.Tables[0].Rows[0]["CostPrice"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["SalePrice"] != null) && (set.Tables[0].Rows[0]["SalePrice"].ToString() != ""))
     {
         info.SalePrice = decimal.Parse(set.Tables[0].Rows[0]["SalePrice"].ToString());
     }
     if ((set.Tables[0].Rows[0]["Upselling"] != null) && (set.Tables[0].Rows[0]["Upselling"].ToString() != ""))
     {
         if ((set.Tables[0].Rows[0]["Upselling"].ToString() == "1") || (set.Tables[0].Rows[0]["Upselling"].ToString().ToLower() == "true"))
         {
             info.Upselling = true;
             return info;
         }
         info.Upselling = false;
     }
     return info;
 }