/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { SetDownloadProperties(); if (!Page.IsPostBack) { LoadDownloads(); } } catch (Exception ex) { Logger.Error(typeof(downloadedit).Name + ".Page_Load", ex); Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Category event of the Add control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void lbAdd_Click(object sender, CommandEventArgs e) { try { int artifactId = 0; int.TryParse(e.CommandArgument.ToString(), out artifactId); ProductDownloadMap map = new ProductDownloadMap(); map.DownloadId = artifactId; map.ProductId = productId; map.Save(WebUtility.GetUserName()); LoadAvailableDownloads(); LoadAssociatedDownloads(); } catch (Exception ex) { Logger.Error(typeof(downloads).Name + ".Add_Category", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Click event of the btnManualTransaction control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnManualTransaction_Click(object sender, EventArgs e) { try { Order order = new Order(orderId); paymentService = new PaymentService(); if (order.PaymentMethod == "PayPal" && paymentService.PaymentServiceSettings.ProviderSettingsCollection.Find(provider => provider.GetType().Name.Contains("PayPalStandardPaymentProvider")) != null) { OrderController.CommitStandardTransaction(order, txtTransactionId.Text.Trim(), order.Total); } SetOrderStatus(order.OrderStatusDescriptorId.ToString()); base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblManualTransactionSucceeded")); } catch (Exception ex) { Logger.Error(typeof(actions).Name + ".btnManualTransaction_Click", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Click event of the lbDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param> protected void lbDelete_Click(object sender, CommandEventArgs e) { try { Manufacturer manufacturer; int manufacturerId = 0; int.TryParse(e.CommandArgument.ToString(), out manufacturerId); if (manufacturerId > 0) { manufacturer = new Manufacturer(manufacturerId); ProductCollection productCollection = new ProductCollection().Where(Product.Columns.ManufacturerId, Comparison.Equals, manufacturerId).Load(); if (productCollection.Count > 0) { Master.MessageCenter.DisplayFailureMessage(string.Format(LocalizationUtility.GetText("lblUnableToDeleteManufacturers"), manufacturer.Name)); } else { Manufacturer.Delete(manufacturerId); LoadManufacturers(); Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblManufacturerDeleted")); } } } catch (HttpException) { try { if (dgManufacturers.PageCount > 1) { dgManufacturers.CurrentPageIndex = dgManufacturers.CurrentPageIndex - 1; } else { dgManufacturers.CurrentPageIndex = 0; } dgManufacturers.DataBind(); Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblManufacturerDeleted")); } catch (Exception exe) { Logger.Error(typeof(manufacturers).Name + ".lbDelete_Click", exe); Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(exe.Message)); } } catch (Exception ex) { Logger.Error(typeof(manufacturers).Name + ".lbDelete_Click", ex); Master.MessageCenter.DisplayCriticalMessage(ex.Message); } }
/// <summary> /// Handles the Click event of the lbDelete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param> protected void lbDelete_Click(object sender, CommandEventArgs e) { try { int artifactId = 0; bool isParsed = int.TryParse(e.CommandArgument.ToString(), out artifactId); if (isParsed) { Query query = new Query(ProductDownloadMap.Schema).WHERE(ProductDownloadMap.Columns.DownloadId, artifactId).AND(ProductDownloadMap.Columns.ProductId, productId); query.QueryType = QueryType.Delete; query.Execute(); LoadAvailableDownloads(); LoadAssociatedDownloads(); } } catch (Exception ex) { Logger.Error(typeof(downloads).Name + ".lbDelete_Click", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { productId = Utility.GetIntParameter("productId"); view = Utility.GetParameter("view"); if (view == "dl") { if (!Page.IsPostBack) { LoadAvailableDownloads(); LoadAssociatedDownloads(); } } } catch (Exception ex) { Logger.Error(typeof(downloads).Name + ".Page_Load", ex); base.MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Download event of the Edit control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void Edit_Download(object sender, DataGridCommandEventArgs e) { try { int artifactId = 0; bool isParsed = int.TryParse(dgDownloads.DataKeys[e.Item.ItemIndex].ToString(), out artifactId); if (isParsed) { Download artifact = Download.FetchByID(artifactId); lblDownloadId.Text = artifact.DownloadId.ToString(); txtTitle.Text = artifact.Title; txtDescriptor.Value = HttpUtility.HtmlDecode(artifact.Description); chkForPurchaseOnly.Checked = artifact.ForPurchaseOnly; } LoadDownloads(); } catch (Exception ex) { Logger.Error(typeof(downloadedit).Name + ".Edit_Download", ex); Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Download event of the Delete control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void Delete_Download(object sender, DataGridCommandEventArgs e) { try { int artifactId = 0; bool isParsed = int.TryParse(dgDownloads.DataKeys[e.Item.ItemIndex].ToString(), out artifactId); if (isParsed) { Download artifact = new Download(artifactId); File.Delete(Server.MapPath(artifact.DownloadFile)); Download.Delete(artifactId); } LoadDownloads(); txtTitle.Text = string.Empty; txtDescriptor.Value = string.Empty; } catch (Exception ex) { Logger.Error(typeof(downloadedit).Name + ".Delete_Download", ex); Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { try { HttpPostedFile file = fuFile.PostedFile; if (file.ContentLength > 0) { FileWriter fileWriter = new FileWriter(); string finalPath = HttpContext.Current.Server.MapPath(DOWNLOAD_PATH) + fuFile.FileName; fileWriter.Write(finalPath, file.InputStream); } Download artifact = null; if (!string.IsNullOrEmpty(lblDownloadId.Text)) { artifact = new Download(lblDownloadId.Text.Trim()); } else { artifact = new Download(); } artifact.DownloadFile = (file.ContentLength > 0) ? DOWNLOAD_PATH + fuFile.FileName : artifact.DownloadFile; artifact.Title = txtTitle.Text; artifact.Description = HttpUtility.HtmlEncode(txtDescriptor.Value); artifact.ForPurchaseOnly = chkForPurchaseOnly.Checked; artifact.ContentType = (file.ContentLength > 0) ? file.ContentType : artifact.ContentType; artifact.Save(WebUtility.GetUserName()); chkForPurchaseOnly.Checked = false; txtTitle.Text = string.Empty; txtDescriptor.Value = string.Empty; LoadDownloads(); Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblDownloadSaved")); } catch (Exception ex) { Logger.Error(typeof(downloadedit).Name + ".btnSave_Click", ex); Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message)); } }