Inheritance: IEntity
        void btnSaveAndStay_Click(object sender, EventArgs e)
        {
            try
            {
                Product product = new Product
                {
                    Name = txtName.Text,
                    Description = txtDescription.Text,
                    DisplayTextInStockText = txtDisplayTextInStock.Text,
                    DisplayTextInBackOrderText = txtDisplayTextWhenbackOrder.Text,
                    ShortDescription = txtShortDescription.Text,
                    Tags = txtTags.Text,

                    Ean13OrJan = txtEAN13.Text,
                    UPC = txtUpc.Text,
                    Location = txtLocation.Text,
                    IsDownloadable = cbIsDownloadable.Checked,
                    DisplayOnSaleIcon = cbDisplayOnSaleIcon.Checked,

                    IsEnabled = cbIsEnabled.Checked,

                    SizeChart = txtSizeChart.Text,

                    IsDeleted = false,
                    LanguageID = CMSContext.LanguageID,
                    PortalID = CMSContext.PortalID,
                    ModuleID = (int)CMSEnums.ECommerceModule.Product,
                };

                int supplierID = 0;
                int initialStock = 0;
                int minimumQuantity = 0;
                decimal additionalShippingCost = 0;
                int manufacturarID = 0;
                int taxID = 0;

                int.TryParse(cddlSupplier.SelectedValue, out supplierID);
                product.SupplierID = supplierID;

                int.TryParse(txtInitialStock.Text, out initialStock);
                product.InitialStock = initialStock;

                int.TryParse(txtMinimumQuantity.Text, out minimumQuantity);
                product.MinimumQuantity = minimumQuantity;

                decimal.TryParse(txtAdditionalShippingCost.Text, out additionalShippingCost);
                product.AdditionalShippingCost = additionalShippingCost;

                int.TryParse(cddlManufacturar.SelectedValue, out manufacturarID);
                product.ManufacturarID = manufacturarID;

                int.TryParse(cddlTax.SelectedValue, out taxID);
                product.TaxID = taxID;

                int productId = ProductManager.Add(product);

                Response.Redirect("FrmProduct.aspx?ProductID=" + productId);

            }
            catch (Exception ex)
            {
                dvProductProblems.Visible = true;
                dvProductProblems.InnerText = ex.ToString();
            }
            finally
            {
                upnlProduct.Update();
            }
        }
        internal static void FillFromReaderByCatalog(Product Product, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_PRODUCT_ID);
            if (!reader.IsDBNull(colIndex))
                Product.ID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_SUPPLIER_ID);
            if (!reader.IsDBNull(colIndex))
                Product.SupplierID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_EAN13_OR_JAN);
            if (!reader.IsDBNull(colIndex))
                Product.Ean13OrJan = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_UPC);
            if (!reader.IsDBNull(colIndex))
                Product.UPC = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_LOCATION);
            if (!reader.IsDBNull(colIndex))
                Product.Location = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_IS_DOWNLODABLE);
            if (!reader.IsDBNull(colIndex))
                Product.IsDownloadable = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_DISPLAY_ON_SALE_ICON);
            if (!reader.IsDBNull(colIndex))
                Product.DisplayOnSaleIcon = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_INITIAL_STOCK);
            if (!reader.IsDBNull(colIndex))
                Product.InitialStock = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_MINIMUM_QUANTITY);
            if (!reader.IsDBNull(colIndex))
                Product.MinimumQuantity = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_ADDITIONAL_SHIPPING_COST);
            if (!reader.IsDBNull(colIndex))
                Product.AdditionalShippingCost = reader.GetDecimal(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_MANUFACTURER_ID);
            if (!reader.IsDBNull(colIndex))
                Product.ManufacturarID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_IS_ENABLED);
            if (!reader.IsDBNull(colIndex))
                Product.IsEnabled = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_PORTAL_ID);
            if (!reader.IsDBNull(colIndex))
                Product.PortalID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_TAX_ID);
            if (!reader.IsDBNull(colIndex))
                Product.TaxID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_NAME);
            if (!reader.IsDBNull(colIndex))
                Product.Name = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_MESSAGE1);
            if (!reader.IsDBNull(colIndex))
                Product.DisplayTextInStockText = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_MESSAGE2);
            if (!reader.IsDBNull(colIndex))
                Product.DisplayTextInBackOrderText = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_DESC);
            if (!reader.IsDBNull(colIndex))
                Product.Description = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_DESC2);
            if (!reader.IsDBNull(colIndex))
                Product.ShortDescription = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_DETAILS);
            if (!reader.IsDBNull(colIndex))
                Product.SizeChart = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_KEYWORD);
            if (!reader.IsDBNull(colIndex))
                Product.Tags = reader.GetString(colIndex);

            colIndex = reader.GetOrdinal(ECommerceDataMapperBase.CN_ECO_LAN_LAN_ID);
            if (!reader.IsDBNull(colIndex))
                Product.LanguageID = reader.GetInt32(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_IS_ENABLED);
            if (!reader.IsDBNull(colIndex))
                Product.IsDeleted = reader.GetBoolean(colIndex);

            colIndex = reader.GetOrdinal(CN_PRODUCT_ORDER);
            if (!reader.IsDBNull(colIndex))
                Product.Order = reader.GetInt32(colIndex);

        }
        void btnSaveOtherLanguageProduct_Click(object sender, EventArgs e)
        {
            //ToDO : to update product information and then add language part
            try
            {
                if (SelecedProductId > 0)
                {
                    Product product = new Product();
                    if (product != null)
                    {
                        product.Name = txtName.Text;
                        product.Description = txtDescription.Text;
                        product.DisplayTextInStockText = txtDisplayTextInStock.Text;
                        product.DisplayTextInBackOrderText = txtDisplayTextWhenbackOrder.Text;
                        product.ShortDescription = txtShortDescription.Text;
                        product.Tags = txtTags.Text;
                        product.Location = txtLocation.Text;
                        product.SizeChart = txtSizeChart.Text;

                        product.Ean13OrJan = txtEAN13.Text;
                        product.UPC = txtUpc.Text;
                        product.Location = txtLocation.Text;
                        product.IsDownloadable = cbIsDownloadable.Checked;
                        product.DisplayOnSaleIcon = cbDisplayOnSaleIcon.Checked;

                        product.IsEnabled = cbIsEnabled.Checked;

                        product.SizeChart = txtSizeChart.Text;
                        product.LanguageID = ucPortalLanguage.SelectedLanguageID;

                        int supplierID = 0;
                        int initialStock = 0;
                        int minimumQuantity = 0;
                        decimal additionalShippingCost = 0;
                        int manufacturarID = 0;
                        int taxID = 0;

                        int.TryParse(cddlSupplier.SelectedValue, out supplierID);
                        product.SupplierID = supplierID;

                        int.TryParse(txtInitialStock.Text, out initialStock);
                        product.InitialStock = initialStock;

                        int.TryParse(txtMinimumQuantity.Text, out minimumQuantity);
                        product.MinimumQuantity = minimumQuantity;

                        decimal.TryParse(txtAdditionalShippingCost.Text, out additionalShippingCost);
                        product.AdditionalShippingCost = additionalShippingCost;

                        int.TryParse(cddlManufacturar.SelectedValue, out manufacturarID);
                        product.ManufacturarID = manufacturarID;

                        int.TryParse(cddlTax.SelectedValue, out taxID);
                        product.TaxID = taxID;

                        product.LanguageID = ucPortalLanguage.SelectedLanguageID;
                        product.PortalID = CMSContext.PortalID;
                        product.ID = SelecedProductId;

                        ProductManager.Update(product);
                        ProductManager.AddOtherLanguage(product);
                    }
                }
            }
            catch (Exception ex)
            {
                dvProductProblems.Visible = true;
                dvProductProblems.InnerText = ex.ToString();
            }
            finally
            {
                upnlProduct.Update();
            }
        }
        internal static Product GetProduct(List<Product> Products, SqlDataReader reader)
        {
            int colIndex = 0;
            colIndex = reader.GetOrdinal(CN_PRODUCT_ID);
            int value = reader.GetInt32(colIndex);

            Product Product = Products.Where(c => c.ID == value).FirstOrDefault();
            if (Product == null)
            {
                Product = new Product();
                Products.Add(Product);
            }
            return Product;
        }
        internal static Product GetProduct(int id, int portalID, int languageID)
        {
            Product product = null;

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

                SqlParameter sqlParameter = null;
                sqlParameter = new SqlParameter(PN_PRODUCT_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.Product;
                sqlCommand.Parameters.Add(sqlParameter);

                sqlParameter = new SqlParameter(PN_PRODUCT_PORTAL_ID, System.Data.SqlDbType.Int);
                sqlParameter.Direction = System.Data.ParameterDirection.Input;
                sqlParameter.Value = portalID;
                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())
                    {
                        product = new Product();
                        FillFromReader(product, sqlDataReader);
                    }

                    sqlDataReader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return product;
        }
 public static int Add(Product product)
 {
     return ProductDataMapper.Add(product);
 }
 public static void AddOtherLanguage(Product product)
 {
     ProductDataMapper.AddOtherLanguage(product);
 }
 public static void Update(Product product)
 {
     ProductDataMapper.Update(product);
 }