internal static void FillFromReader(ProductImage ProductImage, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_PROD_IMAGE_ID);
            if (!reader.IsDBNull(colIndex))
                ProductImage.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PROD_PRODUCT_ID);
            if (!reader.IsDBNull(colIndex))
                ProductImage.ProductID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PROD_IMAGE_NAME);
            if (!reader.IsDBNull(colIndex))
                ProductImage.Image = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_PROD_IMAGE_IS_COVER_IMAGE);
            if (!reader.IsDBNull(colIndex))
                ProductImage.IsCoverImage = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_NAME);
            if (!reader.IsDBNull(colIndex))
                ProductImage.ImageCaption = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_PROD_IMAGE_IS_DELETED);
            if (!reader.IsDBNull(colIndex))
                ProductImage.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_LAN_ID);
            if (!reader.IsDBNull(colIndex))
                ProductImage.LanguageID = reader.GetInt32(colIndex);
        }
        internal static int Add(ProductImage entity)
        {
            ProductImage ProductImageEntity = (ProductImage)(entity);

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_PRODUCT_IMAGE_ADD, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;

                sqlParameter = new SqlParameter(PN_PROD_IMAGE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Output;
                sqlParameter.Value = ProductImageEntity.ID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_PROD_PRODUCT_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = ProductImageEntity.ProductID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_PROD_IMAGE_NAME, System.Data.SqlDbType.NVarChar);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = ProductImageEntity.Image;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_PROD_IMAGE_IS_COVER_IMAGE, System.Data.SqlDbType.Bit);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = ProductImageEntity.IsCoverImage;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_PROD_IMAGE_CAPTION, System.Data.SqlDbType.NVarChar);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = ProductImageEntity.ImageCaption;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_MODULE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = (int)CMSEnums.ECommerceModule.ProductImage;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_ECO_LAN_LAN_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = ProductImageEntity.LanguageID;
                sqlCommand.Parameters.Add(sqlParameter);

                try
                {
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                    sqlCommand.Connection.Close();

                    ProductImageEntity.ID = Convert.ToInt32(sqlCommand.Parameters[PN_PROD_IMAGE_ID].Value);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return ProductImageEntity.ID;
        }
        internal static ProductImage GetProductImage(List<ProductImage> ProductImages, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_PROD_IMAGE_ID);
            int value = reader.GetInt32(colIndex);

            ProductImage ProductImage = ProductImages.Where(c => c.ID == value).FirstOrDefault();
            if (ProductImage == null)
            {
                ProductImage = new ProductImage();
                ProductImages.Add(ProductImage);
            }
            return ProductImage;
        }
        internal static ProductImage GetProductImage(int id, int languageID)
        {
            ProductImage productImage = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_PRODUCT_IMAGE_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter sqlParameter = null;
                sqlParameter = new SqlParameter(PN_PROD_IMAGE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = id;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_MODULE_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = (int)CMSEnums.ECommerceModule.ProductImage;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_ECO_LAN_LAN_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = languageID;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (sqlDataReader.Read())
                    {
                        productImage = new ProductImage();
                        FillFromReader(productImage, sqlDataReader);
                    }

                    sqlDataReader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return productImage;
        }
        void btnSaveProdcutImage_Click(object sender, EventArgs e)
        {
            try
            {
                ProductImage productImage = null;
                List<string> imagesNames = ucSWFUploadProductImage.GetFilesName();

                if (imagesNames != null && imagesNames.Count > 0)
                {
                    for (int i = 0; i <= imagesNames.Count - 1; i++)
                    {
                        productImage = new ProductImage
                        {
                            Image = imagesNames[i],
                            ImageCaption = txtCaption.Text,
                            IsCoverImage = cbIsCoverImage.Checked,
                            LanguageID = CMSContext.LanguageID,
                            ModuleID = (int)CMSEnums.ECommerceModule.ProductImage,
                            IsDeleted = false,
                            ProductID = SelecedProductId,
                        };

                        ProductImageManager.Add(productImage);
                    }
                }

                FillProdcutImages(SelecedProductId);
                BeginProductImageAddMode();
            }
            catch (Exception ex)
            {
                dvProdcutImageProblems.Visible = true;
                dvProdcutImageProblems.InnerText = ex.ToString();
            }
            finally
            {
                upnlProductImage.Update();
            }
        }
Exemplo n.º 6
0
 public static int Add(ProductImage productImage)
 {
     return ProductImageDataMapper.Add(productImage);
 }
Exemplo n.º 7
0
 public static void Update(ProductImage productImage)
 {
     ProductImageDataMapper.Update(productImage);
 }
Exemplo n.º 8
0
 public static void AddOtherLanguage(ProductImage productImage)
 {
     ProductImageDataMapper.AddOtherLanguage(productImage);
 }