Beispiel #1
0
 public OptionCheckedListBox(ApplicationProduct product)
 {
     this.selectedItems     = new List <ProductOptionBase>();
     this.Product           = product;
     this.FormattingEnabled = true;
     this.Size = new System.Drawing.Size(180, 130);
 }
        public FrmProductContacts(ApplicationProduct product)
        {
            InitializeComponent();

            this.product = product;
            this.dgvContacts.DataSource = this.product.ProductContacts;
        }
        public static MvcHtmlString SoftwareScreenshot(this HtmlHelper html, ApplicationProduct product, string url)
        {
            StringBuilder ret = new StringBuilder();

            if (product.Screenshots.Count > 0)
            {
                ret.Append("<div class=\"screenshot_zoom\">");
                ret.AppendFormat("<div class=\"icon_zoom_in float_{0}\"></div>", UiResources.UiTexts.float_left);
                ret.AppendFormat("<b><a href=\"{0}/Screenshots\">{1}</a></b>",
                                 url,
                                 UiResources.UiTexts.more_images);
                ret.Append("</div>");

                ret.Append("<div>");
                ret.AppendFormat("<a href=\"{2}/Screenshots\"><img alt=\"Product screenshot:{3}\" src=\"{4}\" width=\"{0}px\" height=\"{1}px\" /></a>",
                                 400, 300,
                                 url,
                                 product.Screenshots[0].Description,
                                 product.Screenshots[0].Url);
                ret.Append("</div>");
            }
            else
            {
                ret.Append("<img alt=\"Product screenshot:No Image Available\" src=\"/Content/Products/Common/no_screenshot.png\" width=\"400px\" height=\"300px\" />");
            }

            return(MvcHtmlString.Create(ret.ToString()));
        }
        public static void Remove(ProductOptionBase option, ApplicationProduct Product, string table)
        {
            string query = string.Format("DELETE FROM {0} WHERE ProductId = @ProductId AND OptionId = @OptionId", tables[table]);

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", Product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@OptionId", option.Id));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }
                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    /*
                     * if (affected == 0)
                     * {
                     * }
                     */

                    cnn.Close();
                }
            }
        }
 public ProductCategoriesCheckedListBox(ApplicationProduct product)
 {
     this.selectedItems     = new CategoryCollection();
     this.Product           = product;
     this.FormattingEnabled = true;
     this.Size = new System.Drawing.Size(180, 130);
 }
        public static MvcHtmlString LanguageOverview(this HtmlHelper html, ApplicationProduct product, string url)
        {
            StringBuilder ret = new StringBuilder();

            if (product.SupportedLanguages.Count > 2)
            {
                ret.Append(string.Format("<a href=\"{0}#languages\">{1} {2}</a>",
                                         url,
                                         product.SupportedLanguages.Count,
                                         UiResources.UiTexts.product_language));
            }
            else
            {
                foreach (ProductLanguage language in product.SupportedLanguages)
                {
                    if (ret.Length > 0)
                    {
                        ret.Append(", ");
                    }
                    ret.Append(language.Name);
                }
            }

            return(MvcHtmlString.Create(ret.ToString()));
        }
Beispiel #7
0
        public FrmBrands(ApplicationProduct product)
        {
            InitializeComponent();

            this.product = product;

            BindList();
        }
        internal static bool Remove(ApplicationProduct product, ProductBrand brand)
        {
            string query =
                "DELETE FROM ProductBrands WHERE BrandId = @BrandId AND ProductId = @ProductId; " +
                "DELETE FROM ListBrands WHERE BrandId = @BrandId; ";

            bool ok = false;

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                SqlTransaction transaction = null;
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;

                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@BrandId", brand.BrandId));

                    try
                    {
                        foreach (SqlParameter Parameter in cmd.Parameters)
                        {
                            if (Parameter.Value == null)
                            {
                                Parameter.Value = DBNull.Value;
                            }
                        }
                        cnn.Open();
                        transaction     = cnn.BeginTransaction();
                        cmd.Transaction = transaction;

                        int affected = cmd.ExecuteNonQuery();
                        if (affected >= 2)
                        {
                            ok = true;
                        }

                        if (ok)
                        {
                            transaction.Commit();
                        }
                        else
                        {
                            transaction.Rollback();
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        System.Diagnostics.Debug.WriteLine(string.Format("Exception:{0}", ex));
                    }

                    cnn.Close();
                }
            }

            return(ok);
        }
Beispiel #9
0
        public FrmProductScreenshots(ApplicationProduct product)
            : this()
        {
            this.product = product;

            this.productScreenshotDirectory =
                DataAdministration.Properties.Settings.Default.ProductResDirBase +
                this.product.Catalog.UrlName +
                DataAdministration.Properties.Settings.Default.ScreenshotDirName;
        }
Beispiel #10
0
        public FrmProductCatalog(ApplicationProduct product)
        {
            InitializeComponent();
            this.product = product;

            this.tbxUrlName.DataBindings.Add(new Binding("Text", this.product.Catalog, "UrlName", true, DataSourceUpdateMode.OnPropertyChanged, ""));
            this.tbxSearchPriority.DataBindings.Add(new Binding("Text", this.product.Catalog, "SearchPriority", true, DataSourceUpdateMode.OnPropertyChanged, ""));

            this.chbxIsEnabled.DataBindings.Add(new Binding("Checked", this.product.Catalog, "IsEnabled"));
            this.chbxIsFeatured.DataBindings.Add(new Binding("Checked", this.product.Catalog, "IsFeatured"));
        }
        public FrmProductEditor(ApplicationProduct product)
        {
            this.Product = product;

            InitializeComponent();

            InitializeOptionBoxes();

            EnableControls();

            BindProduct();
        }
        public static MvcHtmlString SoftwareAwards(this HtmlHelper html, ApplicationProduct product, string url)
        {
            /*
             * StringBuilder ret = new StringBuilder();
             *
             * ret.AppendFormat("<a href=\"{0}\"><img alt=\"Early-Adapter Seal\" src=\"/Content/Images/seal_early_adapters.gif\" /></a>",
             *  url);
             *
             * return MvcHtmlString.Create(ret.ToString());
             */

            return(MvcHtmlString.Create(string.Empty));
        }
Beispiel #13
0
        public static void LoadDemoVersions(ApplicationProduct product, string cultureId)
        {
            try
            {
                // Load product screenshots
                if (!string.IsNullOrWhiteSpace(product.Catalog.UrlName))
                {
                    // Product resource directory is base dir + UrlName
                    string demoDir =
                        Configurations.ProductResDirBase +
                        product.Catalog.UrlName +
                        DemoDirName;

                    // Find Common demo file
                    string             dirPath = demoDir + CommonDemoDirName;
                    System.IO.FileInfo fi      = GetLatestDemoFile(dirPath);
                    string             fileUrl = string.Format("{0}{1}", dirPath, fi.Name);

                    if (!string.IsNullOrWhiteSpace(fileUrl))
                    {
                        product.Demo.CommonVersion      = new ProductDemo();
                        product.Demo.CommonVersion.Url  = fileUrl;
                        product.Demo.CommonVersion.Size = FormatFileSize(fi.Length);
                    }

                    // Find latest in culture file
                    dirPath = demoDir + cultureId + "/";
                    fi      = GetLatestDemoFile(dirPath);
                    fileUrl = string.Format("{0}{1}", dirPath, fi.Name);
                    if (!string.IsNullOrWhiteSpace(fileUrl))
                    {
                        ProductDemo demo = product.Demo[cultureId];
                        if (demo == null)
                        {
                            demo = new ProductDemo();
                            product.Demo.Add(demo);
                        }

                        demo.Url      = fileUrl;
                        demo.Size     = FormatFileSize(fi.Length);
                        demo.Language = Repository.Memory.Languages.Instance.Items[cultureId];
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Exception:{0}", ex));
            }
        }
Beispiel #14
0
        public static Int64?Insert(ApplicationProduct product)
        {
            string query = string.Format(
                "DECLARE @productId BIGINT " +
                "SET @productId = -1 " +
                "INSERT INTO SoftwareProduct " +
                "(ProductWebsite, ProductVersion, ProductReleaseDate, ProductPrice, MinimumVolumeSize, IsMultiUser, IsMultiLanguage, IsLanguageExtendable) " +
                "VALUES " +
                "(@ProductWebsite, @ProductVersion, @ProductReleaseDate, @ProductPrice, @MinimumVolumeSize, @IsMultiUser, @IsMultiLanguage, @IsLanguageExtendable) " +
                "SELECT @productId = SCOPE_IDENTITY(); " +
                "SELECT @productId; "
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductWebsite", product.ProductWebsite));
                    cmd.Parameters.Add(new SqlParameter("@ProductVersion", product.ProductVersion));
                    cmd.Parameters.Add(new SqlParameter("@ProductReleaseDate", product.ProductReleaseDate));
                    cmd.Parameters.Add(new SqlParameter("@ProductPrice", product.Price));
                    cmd.Parameters.Add(new SqlParameter("@MinimumVolumeSize", product.MinimumVolumeSize));
                    cmd.Parameters.Add(new SqlParameter("@IsMultiUser", product.MultiUser));
                    cmd.Parameters.Add(new SqlParameter("@IsMultiLanguage", product.MultiLanguage));
                    cmd.Parameters.Add(new SqlParameter("@IsLanguageExtendable", product.LanguageExtendable));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }
                    cnn.Open();

                    object res = cmd.ExecuteScalar();

                    if (res != null && res != DBNull.Value)
                    {
                        product.ProductId = Convert.ToInt64(res);
                    }


                    cnn.Close();
                }

                return(product.ProductId);
            }
        }
Beispiel #15
0
        internal static bool Update(ApplicationProduct product)
        {
            bool res = false;

            string query = string.Format(
                "UPDATE SoftwareProduct SET " +
                "ProductWebsite = @ProductWebsite, " +
                "ProductVersion = @ProductVersion, ProductReleaseDate = @ProductReleaseDate, " +
                "ProductPrice = @ProductPrice, MinimumVolumeSize = @MinimumVolumeSize, " +
                "IsMultiUser = @IsMultiUser, IsMultiLanguage = @IsMultiLanguage, IsLanguageExtendable = @IsLanguageExtendable " +
                "WHERE ProductId = @ProductId"
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@ProductWebsite", product.ProductWebsite));
                    cmd.Parameters.Add(new SqlParameter("@ProductVersion", product.ProductVersion));
                    cmd.Parameters.Add(new SqlParameter("@ProductReleaseDate", product.ProductReleaseDate));
                    cmd.Parameters.Add(new SqlParameter("@ProductPrice", product.Price));
                    cmd.Parameters.Add(new SqlParameter("@MinimumVolumeSize", product.MinimumVolumeSize));
                    cmd.Parameters.Add(new SqlParameter("@IsMultiUser", product.MultiUser));
                    cmd.Parameters.Add(new SqlParameter("@IsMultiLanguage", product.MultiLanguage));
                    cmd.Parameters.Add(new SqlParameter("@IsLanguageExtendable", product.LanguageExtendable));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }
                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    res = (affected > 0);

                    cnn.Close();
                }
            }

            return(res);
        }
Beispiel #16
0
        internal static bool UpdateArticle(ApplicationProduct product)
        {
            bool res = false;

            string query = string.Format(
                "IF EXISTS (SELECT ProductId FROM ProductArticles WHERE ProductId=@ProductId AND LanguageId=@LanguageId) BEGIN " +
                "UPDATE ProductArticles SET ArticleContent=@ArticleContent WHERE ProductId=@ProductId AND LanguageId=@LanguageId " +
                "END ELSE BEGIN " +
                "INSERT INTO ProductArticles " +
                "(ProductId, LanguageId, ArticleContent) " +
                "VALUES " +
                "(@ProductId, @LanguageId, @ArticleContent) " +
                "END"
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@LanguageId", product.ArticleLanguage));
                    cmd.Parameters.Add(new SqlParameter("@ArticleContent", product.Article.Content));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }
                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    if (affected > 0)
                    {
                        res = true;
                    }


                    cnn.Close();
                }
            }

            return(res);
        }
Beispiel #17
0
        internal static bool InsertDetail(ApplicationProduct product, int languageId, string ProductName, string ProductDescription, string PriceDetails, string GuarantyDetails)
        {
            bool res = false;

            string query = string.Format(
                "INSERT INTO SoftwareProductDetails " +
                "(ProductId, LanguageId, ProductName, BriefDescription, PriceDetails, GuarantyDetails) " +
                "VALUES " +
                "(@ProductId, @LanguageId, @ProductName, @BriefDescription, @PriceDetails, @GuarantyDetails) "
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@LanguageId", languageId));
                    cmd.Parameters.Add(new SqlParameter("@ProductName", ProductName));
                    cmd.Parameters.Add(new SqlParameter("@BriefDescription", ProductDescription));
                    cmd.Parameters.Add(new SqlParameter("@PriceDetails", PriceDetails));
                    cmd.Parameters.Add(new SqlParameter("@GuarantyDetails", GuarantyDetails));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }
                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    if (affected > 0)
                    {
                        res = true;
                    }


                    cnn.Close();
                }
            }

            return(res);
        }
        internal static void Reload(ApplicationProduct product)
        {
            string query = string.Format(
                "SELECT Contacts.ContactId, ContactValue, ContactPerson, UnitTitleName, Contacts.ContactMediaId, ContactUnitTitleId, ListContactMedias.ContactMediaName " +
                "FROM Contacts, ListContactUnitTitles, ListContactMedias " +
                "WHERE Contacts.ContactId IN (SELECT ContactId FROM ProductContacts WHERE ProductId = {0}) " +
                "AND Contacts.ContactMediaId = ListContactMedias.ContactMediaId AND " +
                "ListContactUnitTitles.UnitTitleId = Contacts.ContactUnitTitleId AND" +
                " ListContactUnitTitles.LanguageId = {1} AND ListContactMedias.LanguageId = {1}",
                product.ProductId, product.ArticleLanguage);

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cnn.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader != null && reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ProductContact contact = new ProductContact();
                                contact.Id             = Repository.Utils.Convert.ToInt64(reader[0]);
                                contact.ContactValue   = Repository.Utils.Convert.ToString(reader[1]);
                                contact.ContactPerson  = Repository.Utils.Convert.ToString(reader[2]);
                                contact.Unit.Name      = Repository.Utils.Convert.ToString(reader[3]);
                                contact.MediaType.Id   = Repository.Utils.Convert.ToInt32(reader[4]);
                                contact.Unit.Id        = Repository.Utils.Convert.ToInt32(reader[5]);
                                contact.MediaType.Name = Repository.Utils.Convert.ToString(reader[6]);

                                product.ProductContacts.Add(contact);
                            }

                            reader.Close();
                        }
                    }

                    cnn.Close();
                }
            }
        }
        public ActionResult Catalog(string productName)
        {
            if (!DomainModel.Security.InputController.IsValid(productName))
            {
                return(RedirectToAction(
                           WebUi.ViewModels.NavigationKeys.SecurityBadInputAction,
                           WebUi.ViewModels.NavigationKeys.SecurityController));
            }


            // productName is in fact products' urlName
            ApplicationProduct product = new ApplicationProduct();

            if (DomainModel.Repository.Sql.Catalog.Load(
                    productName,
                    WebUi.Models.AppCulture.CurrentCulture.CultureId,
                    product,
                    Models.Security.CurrentUser == null ? -1 : Models.Security.CurrentUser.Id))
            {
                DomainModel.Repository.Disk.Catalog.LoadScreenshots(
                    product,
                    WebUi.Models.AppCulture.CurrentCulture.CultureId,
                    false);

                DomainModel.Repository.Disk.Catalog.LoadDemoVersions(
                    product,
                    WebUi.Models.AppCulture.CurrentCulture.CultureId);

                // UNDONE: ADD MESSAGE DATA TO PRODUCT CONTROLLER
                DomainModel.Repository.Sql.Discussions.LoadProductDiscussions
                    (product, 0, 1000);

                ViewData["productName"]    = product.ProductName;
                ViewData["productUrlName"] = productName;

                return(View(product));
            }

            return(RedirectToAction(
                       WebUi.ViewModels.NavigationKeys.Errors404Action,
                       WebUi.ViewModels.NavigationKeys.ErrorsController));
        }
Beispiel #20
0
        public static bool UpdateDetails(ApplicationProduct product)
        {
            bool res = false;

            string query = string.Format(
                "UPDATE SoftwareProductDetails SET " +
                "ProductName = @ProductName, BriefDescription = @BriefDescription, " +
                "PriceDetails = @PriceDetails, GuarantyDetails = @GuarantyDetails " +
                "WHERE ProductId = @ProductId AND LanguageId=@LanguageId"
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@LanguageId", product.ArticleLanguage));
                    cmd.Parameters.Add(new SqlParameter("@ProductName", product.ProductName));
                    cmd.Parameters.Add(new SqlParameter("@BriefDescription", product.BriefDescription));
                    cmd.Parameters.Add(new SqlParameter("@PriceDetails", product.PriceDetails));
                    cmd.Parameters.Add(new SqlParameter("@GuarantyDetails", product.GuarantyDetails));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }

                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    res = (affected > 0);

                    cnn.Close();
                }
            }

            return(res);
        }
Beispiel #21
0
        public async Task <IActionResult> Insert([FromBody] CRUDModel <ApplicationProduct> crud)
        {
            var product = new ApplicationProduct
            {
                Name        = crud.Value.Name,
                Description = crud.Value.Description,
                Suspended   = crud.Value.Suspended
            };

            if (await dbContext.Products.FirstOrDefaultAsync(p => p.Name == product.Name) != null)
            {
                return(StatusCode(400, "Insert failed, product with this name already exists!"));
            }

            await dbContext.AddAsync(product);

            await dbContext.SaveChangesAsync();

            return(Json(crud.Value));
        }
        public FrmProductDetails(ApplicationProduct product)
            : this()
        {
            this.product = product;

            if (product == null)
            {
                this.tbxProductName.DataBindings.Add(new Binding("Text", this, "ProductName", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxProductDescription.DataBindings.Add(new Binding("Text", this, "ProductDescription", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxProductPriceDetails.DataBindings.Add(new Binding("Text", this, "PriceDetails", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxGuarantyDetails.DataBindings.Add(new Binding("Text", this, "GuarantyDetails", true, DataSourceUpdateMode.OnPropertyChanged, ""));
            }
            else
            {
                this.tbxProductName.DataBindings.Add(new Binding("Text", this.product, "ProductName", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxProductDescription.DataBindings.Add(new Binding("Text", this.product, "BriefDescription", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxProductPriceDetails.DataBindings.Add(new Binding("Text", this.product, "PriceDetails", true, DataSourceUpdateMode.OnPropertyChanged, ""));
                this.tbxGuarantyDetails.DataBindings.Add(new Binding("Text", this.product, "GuarantyDetails", true, DataSourceUpdateMode.OnPropertyChanged, ""));
            }
        }
 internal static void Reload(ApplicationProduct product)
 {
     Reload(product.SupportedPlatforms, typeof(SoftwarePlatform), "ListSoftwarePlatforms", product.ProductId, product.ArticleLanguage);
     Reload(product.BackupOptions, typeof(ProductDataBackupOption), "ListDataBackupOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.CustomizationOptions, typeof(ProductCustomizationOption), "ListCustomizationOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.DemoOptions, typeof(ProductDemoOption), "ListDemoOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.EnvironmentOptions, typeof(ProductEnvironmentOption), "ListEnvironmentOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.ExtensionOptions, typeof(ProductExtensionOptions), "ListExtensionOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.GuarantyOptions, typeof(ProductGuarantyOption), "ListGuarantyOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.InstallationOptions, typeof(ProductInstallationOption), "ListInstallationOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.PaymentOptions, typeof(ProductPaymentOption), "ListPaymentOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.PublishOptions, typeof(ProductPublishOption), "ListPublishOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.SourceOptions, typeof(ProductSourceOption), "ListSourceOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.SupportOptions, typeof(ProductSupportOption), "ListSupportOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.TrainingOptions, typeof(ProductTrainingOption), "ListTrainingOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.UpdateOptions, typeof(ProductUpdateOption), "ListUpdateOptions", product.ProductId, product.ArticleLanguage);
     Reload(product.SupportTypes, typeof(ProductSupportType), "ListSupportTypes", product.ProductId, product.ArticleLanguage);
     Reload(product.SupportedLanguages, typeof(ProductLanguage), "ListLanguages", product.ProductId, -1);
     Reload(product.ProductTechnologies, typeof(ProductTechnology), "ListProductTechnologies", product.ProductId, product.ArticleLanguage);
     Reload(product.Tags, typeof(ProductTag), "ListTags", product.ProductId, product.ArticleLanguage);
 }
Beispiel #24
0
        internal static bool UpdateCatalog(ApplicationProduct product)
        {
            bool res = false;

            string query = string.Format(
                "UPDATE ProductCatalog " +
                "SET UrlName=@UrlName, SearchPriority=@SearchPriority, IsEnabled=@IsEnabled, IsFeatured=@IsFeatured WHERE ProductId=@ProductId "
                );

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@UrlName", product.Catalog.UrlName));
                    cmd.Parameters.Add(new SqlParameter("@SearchPriority", product.Catalog.SearchPriority));
                    cmd.Parameters.Add(new SqlParameter("@IsEnabled", product.Catalog.IsEnabled));
                    cmd.Parameters.Add(new SqlParameter("@IsFeatured", product.Catalog.IsFeatured));

                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }

                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    res = (affected > 0);

                    cnn.Close();
                }
            }

            return(res);
        }
        internal static void Reload(ApplicationProduct product)
        {
            product.Brands.Clear();

            string query = string.Format(
                "SELECT BrandId, BrandName, OwnerId " +
                "FROM dbo.ListBrands, dbo.BrandDetails " +
                "WHERE BrandId IN (SELECT BrandId FROM dbo.ProductBrands WHERE ProductId = {0})",
                product.ProductId);

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cnn.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader != null && reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ProductBrand brand = new ProductBrand();

                                brand.BrandId   = Repository.Utils.Convert.ToInt32(reader[0]);
                                brand.BrandName = Repository.Utils.Convert.ToString(reader[1]);

                                product.Brands.Add(brand);
                            }

                            reader.Close();
                        }
                    }

                    cnn.Close();
                }
            }
        }
        public static MvcHtmlString HardwareRequirements(this HtmlHelper html, ApplicationProduct product)
        {
            StringBuilder ret = new StringBuilder();

            if (product.HardwareRequirements.Count <= 0)
            {
                ret.Append(UiResources.UiTexts.nothing_special);
            }
            else
            {
                ret.Append("<ul>");
                foreach (string req in product.HardwareRequirements)
                {
                    ret.AppendFormat("<li class=\"article_li_{0}\">", UiResources.UiTexts.float_right);
                    ret.Append(req);
                    ret.Append("</li>");
                }
                ret.Append("</ul>");
            }

            return(MvcHtmlString.Create(ret.ToString()));
        }
Beispiel #27
0
        public static void Insert(Category option, ApplicationProduct Product)
        {
            string query = string.Format(
                "INSERT INTO ProductCategories (ProductId, CategoryId, LanguageId) " +
                "VALUES (@ProductId, @CategoryId, @LanguageId)");

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.Add(new SqlParameter("@ProductId", Product.ProductId));
                    cmd.Parameters.Add(new SqlParameter("@CategoryId", option.CategoryId));
                    cmd.Parameters.Add(new SqlParameter("@LanguageId", Product.ArticleLanguage));

                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }

                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();

                    /*
                     * if (affected == 0)
                     * {
                     * }
                     */

                    cnn.Close();
                }
            }
        }
        internal static bool Add(ApplicationProduct product, ProductBrand brand)
        {
            string query =
                "DECLARE @Id BIGINT " +
                "SET @Id = -1 " +
                "INSERT INTO dbo.ListBrands " +
                "(BrandName, ResourceUrl) " +
                "VALUES " +
                "(@BrandName, @ResourceUrl);" +
                "SELECT @Id = SCOPE_IDENTITY(); " +
                "SELECT @Id; ";

            bool ok = false;

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    SqlTransaction transaction = null;
                    cmd.CommandType = CommandType.Text;

                    cmd.Parameters.Add(new SqlParameter("@BrandName", brand.BrandName));
                    foreach (SqlParameter Parameter in cmd.Parameters)
                    {
                        if (Parameter.Value == null)
                        {
                            Parameter.Value = DBNull.Value;
                        }
                    }

                    try
                    {
                        cnn.Open();
                        transaction     = cnn.BeginTransaction();
                        cmd.Transaction = transaction;

                        object res = cmd.ExecuteScalar();
                        if (res != null && res != DBNull.Value)
                        {
                            brand.BrandId = Convert.ToInt64(res);
                            if (InsertProductBrand(brand.BrandId, product.ProductId.Value, cnn, transaction))
                            {
                                ok = true;
                            }
                        }

                        if (ok)
                        {
                            transaction.Commit();
                        }
                        else
                        {
                            transaction.Rollback();
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        System.Diagnostics.Debug.WriteLine(string.Format("Exception:{0}", ex));
                    }

                    cnn.Close();
                }
            }

            return(ok);
        }
Beispiel #29
0
 public static void LoadScreenshots(ApplicationProduct product, string cultureId, bool loadAll)
 {
     GetScreenShots(product.Catalog.UrlName, cultureId, product.Screenshots, loadAll);
 }
Beispiel #30
0
        internal static ApplicationProduct GetById(Int64 ProductId, int LanguageId)
        {
            ApplicationProduct product = null;
            string             query   = string.Format(
                "SELECT * FROM SoftwareProduct WHERE ProductId = {0};" +
                "SELECT * FROM ProductCatalog WHERE ProductId = {0};" +
                "SELECT * FROM SoftwareProductDetails WHERE ProductId={0} AND LanguageId={1};" +
                "SELECT * FROM ProductArticles WHERE ProductId={0} AND LanguageId={1};" +
                "SELECT * FROM Categories WHERE CategoryId IN (SELECT CategoryId FROM ProductCategories WHERE ProductId={0} AND LanguageId={1});"
                , ProductId, LanguageId);

            using (SqlConnection cnn = new SqlConnection(Properties.Settings.Default.PersianSoftwareConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, cnn))
                {
                    cmd.CommandType = CommandType.Text;
                    cnn.Open();

                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader != null)
                    {
                        if (reader.Read())
                        {
                            product = new ApplicationProduct();

                            product.ProductId          = ProductId;
                            product.Price              = Repository.Utils.Convert.ToDecimal(reader["ProductPrice"]);
                            product.ProductReleaseDate = Repository.Utils.Convert.ToDateTime(reader["ProductReleaseDate"]);
                            product.ProductVersion     = Repository.Utils.Convert.ToString(reader["ProductVersion"]);
                            product.MinimumVolumeSize  = Repository.Utils.Convert.ToFloat(reader["MinimumVolumeSize"]);
                            product.ProductWebsite     = Repository.Utils.Convert.ToString(reader["ProductWebsite"]);
                            product.LanguageExtendable = Repository.Utils.Convert.ToBool(reader["IsLanguageExtendable"]);
                            product.MultiLanguage      = Repository.Utils.Convert.ToBool(reader["IsMultiLanguage"]);
                            product.MultiUser          = Repository.Utils.Convert.ToBool(reader["IsMultiUser"]);
                        }

                        // Read next table: ProductCatalog
                        reader.NextResult();
                        if (reader.Read())
                        {
                            product.Catalog.UrlName        = Repository.Utils.Convert.ToString(reader["UrlName"]);
                            product.Catalog.SearchPriority = Repository.Utils.Convert.ToInt32(reader["SearchPriority"]);
                            product.Catalog.IsEnabled      = Repository.Utils.Convert.ToBool(reader["IsEnabled"]);
                            product.Catalog.IsFeatured     = Repository.Utils.Convert.ToBool(reader["IsFeatured"]);
                        }

                        // Read next table: SoftwareProductDetails
                        reader.NextResult();
                        if (reader.Read())
                        {
                            product.ArticleLanguage  = LanguageId;
                            product.ProductName      = Repository.Utils.Convert.ToString(reader["ProductName"]);
                            product.BriefDescription = Repository.Utils.Convert.ToString(reader["BriefDescription"]);
                            product.PriceDetails     = Repository.Utils.Convert.ToString(reader["PriceDetails"]);
                            product.GuarantyDetails  = Repository.Utils.Convert.ToString(reader["GuarantyDetails"]);
                        }

                        // Read next table: ProductArticles
                        reader.NextResult();
                        if (reader.Read())
                        {
                            product.Article.Content = Repository.Utils.Convert.ToString(reader["ArticleContent"]);
                        }

                        // Read next table: ProductCategories
                        reader.NextResult();
                        if (reader != null)
                        {
                            while (reader.Read())
                            {
                                Category category = new Category();
                                category.CategoryId   = Repository.Utils.Convert.ToInt32(reader["CategoryId"]);
                                category.CategoryName = Repository.Utils.Convert.ToString(reader["CategoryName"]);
                                category.UrlName      = Repository.Utils.Convert.ToString(reader["UrlName"]);

                                product.Categories.Add(category);
                            }
                        }

                        reader.Close();
                    }


                    cnn.Close();
                }

                return(product);
            }
        }