Exemple #1
0
        public static bool Update(ProductInfo proMain, Dictionary <string, ProductFieldInfo> dicField, List <PhotoAlbumInfo> listPhoto)
        {
            proMain.Specifications = Product.GetStringFromDic("Specifications", dicField);
            proMain.ModelNum       = Product.GetStringFromDic("ModelNum", dicField);
            proMain.Size           = Product.GetStringFromDic("Size", dicField);
            proMain.Weight         = Product.GetStringFromDic("Weight", dicField);
            proMain.Color          = Product.GetStringFromDic("Color", dicField);
            proMain.Material       = Product.GetStringFromDic("Material", dicField);
            proMain.ProducingArea  = Product.GetStringFromDic("ProducingArea", dicField);
            proMain.ShortDesc      = Product.GetStringFromDic("ShortDesc", dicField);
            proMain.ProDetail      = Product.GetStringFromDic("ProDetail", dicField);
            bool result;

            if (Product.Update(proMain))
            {
                ProductModelInfo         cacheModelById           = ProductModel.GetCacheModelById(proMain.ModelID);
                IList <ProductFieldInfo> customFieldListByModelID = ProductField.GetCustomFieldListByModelID(proMain.ModelID);
                foreach (ProductFieldInfo current in customFieldListByModelID)
                {
                    if (current.FieldName == "ProID")
                    {
                        current.Value = proMain.AutoID.ToString();
                    }
                    else
                    {
                        current.Value = Product.GetStringFromDic(current.FieldName, dicField);
                    }
                }
                if (Product.ExistsCustomTableData(cacheModelById.TableName, proMain.AutoID))
                {
                    Product.UpdateCustomTable(proMain.AutoID, cacheModelById.TableName, customFieldListByModelID);
                }
                else
                {
                    Product.AddCustomProduct(cacheModelById, customFieldListByModelID);
                }
                PhotoAlbum.DelPhotoByProID(proMain.AutoID);
                if (listPhoto.Count > 0)
                {
                    foreach (PhotoAlbumInfo current2 in listPhoto)
                    {
                        current2.ProID = proMain.AutoID;
                    }
                    PhotoAlbum.AddPhotoList(listPhoto);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemple #2
0
        public static bool Add(ProductInfo proMain, Dictionary <string, ProductFieldInfo> dicField, List <PhotoAlbumInfo> listPhoto)
        {
            proMain.Specifications = Product.GetStringFromDic("Specifications", dicField);
            proMain.ModelNum       = Product.GetStringFromDic("ModelNum", dicField);
            proMain.Size           = Product.GetStringFromDic("Size", dicField);
            proMain.Weight         = Product.GetStringFromDic("Weight", dicField);
            proMain.Color          = Product.GetStringFromDic("Color", dicField);
            proMain.Material       = Product.GetStringFromDic("Material", dicField);
            proMain.ProducingArea  = Product.GetStringFromDic("ProducingArea", dicField);
            proMain.ShortDesc      = Product.GetStringFromDic("ShortDesc", dicField);
            proMain.ProDetail      = Product.GetStringFromDic("ProDetail", dicField);
            proMain.Sort           = Product.MaxSort + 1;
            proMain.AutoTimeStamp  = DateTime.Now;
            proMain.Lang           = JObject.cultureLang;
            int  num = Product.Add(proMain);
            bool result;

            if (num > 0)
            {
                proMain.AutoID = num;
                ProductModelInfo         cacheModelById           = ProductModel.GetCacheModelById(proMain.ModelID);
                IList <ProductFieldInfo> customFieldListByModelID = ProductField.GetCustomFieldListByModelID(proMain.ModelID);
                foreach (ProductFieldInfo current in customFieldListByModelID)
                {
                    if (current.FieldName == "ProID")
                    {
                        current.Value = num.ToString();
                    }
                    else
                    {
                        current.Value = Product.GetStringFromDic(current.FieldName, dicField);
                    }
                }
                Product.AddCustomProduct(cacheModelById, customFieldListByModelID);
                if (listPhoto.Count > 0)
                {
                    foreach (PhotoAlbumInfo current2 in listPhoto)
                    {
                        current2.ProID = num;
                    }
                    PhotoAlbum.AddPhotoList(listPhoto);
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }