Example #1
0
 public List<Maticsoft.Model.Shop.Products.SKUItem> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.SKUItem> list = new List<Maticsoft.Model.Shop.Products.SKUItem>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem();
             if ((dt.Rows[i]["SkuId"] != null) && (dt.Rows[i]["SkuId"].ToString() != ""))
             {
                 item.SkuId = long.Parse(dt.Rows[i]["SkuId"].ToString());
             }
             if ((dt.Rows[i]["AttributeId"] != null) && (dt.Rows[i]["AttributeId"].ToString() != ""))
             {
                 item.AttributeId = long.Parse(dt.Rows[i]["AttributeId"].ToString());
             }
             if ((dt.Rows[i]["ValueId"] != null) && (dt.Rows[i]["ValueId"].ToString() != ""))
             {
                 item.ValueId = long.Parse(dt.Rows[i]["ValueId"].ToString());
             }
             list.Add(item);
         }
     }
     return list;
 }
Example #2
0
 public List<Maticsoft.Model.Shop.Products.SKUItem> AttributeVakueDataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.SKUItem> list = new List<Maticsoft.Model.Shop.Products.SKUItem>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem();
             if ((dt.Rows[i]["ImageUrl"] != null) && (dt.Rows[i]["ImageUrl"].ToString() != ""))
             {
                 item.ImageUrl = dt.Rows[i]["ImageUrl"].ToString();
             }
             if ((dt.Rows[i]["AttributeId"] != null) && (dt.Rows[i]["AttributeId"].ToString() != ""))
             {
                 item.AttributeId = long.Parse(dt.Rows[i]["AttributeId"].ToString());
             }
             if ((dt.Rows[i]["ValueId"] != null) && (dt.Rows[i]["ValueId"].ToString() != ""))
             {
                 item.ValueId = long.Parse(dt.Rows[i]["ValueId"].ToString());
             }
             if ((dt.Rows[i]["ValueStr"] != null) && (dt.Rows[i]["ValueStr"].ToString() != ""))
             {
                 item.ValueStr = dt.Rows[i]["ValueStr"].ToString();
             }
             if ((dt.Rows[i]["UserDefinedPic"] != null) && (dt.Rows[i]["UserDefinedPic"].ToString() != ""))
             {
                 item.UserDefinedPic = bool.Parse(dt.Rows[i]["UserDefinedPic"].ToString());
             }
             if ((dt.Rows[i]["SpecId"] != null) && (dt.Rows[i]["SpecId"].ToString() != ""))
             {
                 item.SpecId = long.Parse(dt.Rows[i]["SpecId"].ToString());
             }
             list.Add(item);
         }
     }
     return list;
 }
Example #3
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;
 }
Example #4
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;
 }
Example #5
0
 public Maticsoft.Model.Shop.Products.SKUItem GetModel(long SkuId, long AttributeId, long ValueId)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("SELECT  TOP 1 SkuId,AttributeId,ValueId FROM Shop_SKUItems ");
     builder.Append(" WHERE SkuId=@SkuId and AttributeId=@AttributeId and ValueId=@ValueId ");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@SkuId", SqlDbType.BigInt, 8), new SqlParameter("@AttributeId", SqlDbType.BigInt, 8), new SqlParameter("@ValueId", SqlDbType.BigInt, 8) };
     cmdParms[0].Value = SkuId;
     cmdParms[1].Value = AttributeId;
     cmdParms[2].Value = ValueId;
     Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem();
     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() != ""))
     {
         item.SkuId = long.Parse(set.Tables[0].Rows[0]["SkuId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["AttributeId"] != null) && (set.Tables[0].Rows[0]["AttributeId"].ToString() != ""))
     {
         item.AttributeId = long.Parse(set.Tables[0].Rows[0]["AttributeId"].ToString());
     }
     if ((set.Tables[0].Rows[0]["ValueId"] != null) && (set.Tables[0].Rows[0]["ValueId"].ToString() != ""))
     {
         item.ValueId = long.Parse(set.Tables[0].Rows[0]["ValueId"].ToString());
     }
     return item;
 }
Example #6
0
 public List<Maticsoft.Model.Shop.Products.SKUItem> SKUItem4AVDataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Shop.Products.SKUItem> list = new List<Maticsoft.Model.Shop.Products.SKUItem>();
     if (dt.Rows.Count >= 1)
     {
         foreach (DataRow row in dt.Rows)
         {
             Maticsoft.Model.Shop.Products.SKUItem item = new Maticsoft.Model.Shop.Products.SKUItem {
                 SkuId = row.Field<long>("SkuId"),
                 SpecId = row.Field<long>("SpecId"),
                 AttributeId = row.Field<long>("AttributeId"),
                 ValueId = row.Field<long>("ValueId"),
                 ImageUrl = row.Field<string>("ImageUrl"),
                 ValueStr = row.Field<string>("ValueStr"),
                 ProductId = row.Field<long>("ProductId"),
                 AttributeName = row.Field<string>("AttributeName"),
                 AB_DisplaySequence = row.Field<int>("AB_DisplaySequence"),
                 UsageMode = row.Field<int>("UsageMode"),
                 UseAttributeImage = row.Field<bool>("UseAttributeImage"),
                 UserDefinedPic = row.Field<bool>("UserDefinedPic"),
                 AV_DisplaySequence = row.Field<int>("AV_DisplaySequence"),
                 AV_ValueStr = row.Field<string>("AV_ValueStr"),
                 AV_ImageUrl = row.Field<string>("AV_ImageUrl")
             };
             list.Add(item);
         }
     }
     return list;
 }