protected void btnUploadProductPicture_Click(object sender, EventArgs e) { try { Product product = ProductManager.GetProductByID(this.ProductID); if (product != null) { Picture picture = null; HttpPostedFile productPictureFile = fuProductPicture.PostedFile; if ((productPictureFile != null) && (!String.IsNullOrEmpty(productPictureFile.FileName))) { byte[] productPictureBinary = PictureManager.GetPictureBits(productPictureFile.InputStream, productPictureFile.ContentLength); picture = PictureManager.InsertPicture(productPictureBinary, productPictureFile.ContentType, true); } if (picture != null) { ProductPicture productPicture = ProductManager.InsertProductPicture(product.ProductID, picture.PictureID, txtProductPictureDisplayOrder.Value); } BindData(); } } catch (Exception exc) { ProcessException(exc); } }
public Manufacturer SaveInfo() { var manufacturer = ManufacturerManager.GetManufacturerById(this.ManufacturerId); if (manufacturer != null) { Picture manufacturerPicture = manufacturer.Picture; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = PictureManager.GetPictureBits(manufacturerPictureFile.InputStream, manufacturerPictureFile.ContentLength); if (manufacturerPicture != null) { manufacturerPicture = PictureManager.UpdatePicture(manufacturerPicture.PictureId, manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } else { manufacturerPicture = PictureManager.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } } int manufacturerPictureId = 0; if (manufacturerPicture != null) { manufacturerPictureId = manufacturerPicture.PictureId; } manufacturer = ManufacturerManager.UpdateManufacturer(manufacturer.ManufacturerId, txtName.Text, txtDescription.Content, int.Parse(this.ddlTemplate.SelectedItem.Value), manufacturer.MetaKeywords, manufacturer.MetaDescription, manufacturer.MetaTitle, manufacturer.SEName, manufacturerPictureId, manufacturer.PageSize, txtPriceRanges.Text, cbPublished.Checked, manufacturer.Deleted, txtDisplayOrder.Value, manufacturer.CreatedOn, DateTime.UtcNow); } else { Picture manufacturerPicture = null; HttpPostedFile manufacturerPictureFile = fuManufacturerPicture.PostedFile; if ((manufacturerPictureFile != null) && (!String.IsNullOrEmpty(manufacturerPictureFile.FileName))) { byte[] manufacturerPictureBinary = PictureManager.GetPictureBits(manufacturerPictureFile.InputStream, manufacturerPictureFile.ContentLength); manufacturerPicture = PictureManager.InsertPicture(manufacturerPictureBinary, manufacturerPictureFile.ContentType, true); } int manufacturerPictureId = 0; if (manufacturerPicture != null) { manufacturerPictureId = manufacturerPicture.PictureId; } DateTime nowDt = DateTime.UtcNow; manufacturer = ManufacturerManager.InsertManufacturer(txtName.Text, txtDescription.Content, int.Parse(this.ddlTemplate.SelectedItem.Value), string.Empty, string.Empty, string.Empty, string.Empty, manufacturerPictureId, 10, txtPriceRanges.Text, cbPublished.Checked, false, txtDisplayOrder.Value, nowDt, nowDt); } SaveLocalizableContent(manufacturer); return(manufacturer); }
public Category SaveInfo() { Category category = CategoryManager.GetCategoryById(this.CategoryId); if (category != null) { Picture categoryPicture = category.Picture; HttpPostedFile categoryPictureFile = fuCategoryPicture.PostedFile; if ((categoryPictureFile != null) && (!String.IsNullOrEmpty(categoryPictureFile.FileName))) { byte[] categoryPictureBinary = PictureManager.GetPictureBits(categoryPictureFile.InputStream, categoryPictureFile.ContentLength); if (categoryPicture != null) { categoryPicture = PictureManager.UpdatePicture(categoryPicture.PictureId, categoryPictureBinary, categoryPictureFile.ContentType, true); } else { categoryPicture = PictureManager.InsertPicture(categoryPictureBinary, categoryPictureFile.ContentType, true); } } int categoryPictureId = 0; if (categoryPicture != null) { categoryPictureId = categoryPicture.PictureId; } category = CategoryManager.UpdateCategory(category.CategoryId, txtName.Text, txtDescription.Content, int.Parse(this.ddlTemplate.SelectedItem.Value), category.MetaKeywords, category.MetaDescription, category.MetaTitle, category.SEName, ParentCategory.SelectedCategoryId, categoryPictureId, category.PageSize, txtPriceRanges.Text, cbShowOnHomePage.Checked, cbPublished.Checked, category.Deleted, txtDisplayOrder.Value, category.CreatedOn, DateTime.UtcNow); } else { Picture categoryPicture = null; HttpPostedFile categoryPictureFile = fuCategoryPicture.PostedFile; if ((categoryPictureFile != null) && (!String.IsNullOrEmpty(categoryPictureFile.FileName))) { byte[] categoryPictureBinary = PictureManager.GetPictureBits(categoryPictureFile.InputStream, categoryPictureFile.ContentLength); categoryPicture = PictureManager.InsertPicture(categoryPictureBinary, categoryPictureFile.ContentType, true); } int categoryPictureId = 0; if (categoryPicture != null) { categoryPictureId = categoryPicture.PictureId; } DateTime nowDT = DateTime.UtcNow; category = CategoryManager.InsertCategory(txtName.Text, txtDescription.Content, int.Parse(this.ddlTemplate.SelectedItem.Value), string.Empty, string.Empty, string.Empty, string.Empty, ParentCategory.SelectedCategoryId, categoryPictureId, 10, txtPriceRanges.Text, cbShowOnHomePage.Checked, cbPublished.Checked, false, txtDisplayOrder.Value, nowDT, nowDT); } SaveLocalizableContent(category); return(category); }
protected void btnUploadAvatar_Click(object sender, EventArgs e) { try { if (Page.IsValid) { if (!CustomerManager.AllowCustomersToUploadAvatars) { throw new NopException("Uploading avatars is not allowed"); } var customerAvatar = NopContext.Current.User.Avatar; var customerPictureFile = fuAvatar.PostedFile; if ((customerPictureFile != null) && (!String.IsNullOrEmpty(customerPictureFile.FileName))) { int avatarMaxSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarMaxSizeBytes", 20000); if (customerPictureFile.ContentLength > avatarMaxSize) { throw new NopException(string.Format("Maximum avatar size is {0} bytes", avatarMaxSize)); } byte[] customerPictureBinary = PictureManager.GetPictureBits(customerPictureFile.InputStream, customerPictureFile.ContentLength); if (customerAvatar != null) { customerAvatar = PictureManager.UpdatePicture(customerAvatar.PictureId, customerPictureBinary, customerPictureFile.ContentType, true); } else { customerAvatar = PictureManager.InsertPicture(customerPictureBinary, customerPictureFile.ContentType, true); } } int customerAvatarId = 0; if (customerAvatar != null) { customerAvatarId = customerAvatar.PictureId; } NopContext.Current.User = CustomerManager.SetCustomerAvatarId(NopContext.Current.User.CustomerId, customerAvatarId); BindData(); } } catch (Exception exc) { pnlCustomerAvatarError.Visible = true; lCustomerAvatarErrorMessage.Text = Server.HtmlEncode(exc.Message); } }
protected void btnUploadAvatar_Click(object sender, EventArgs e) { try { if (Page.IsValid) { Customer customer = CustomerManager.GetCustomerById(this.CustomerId); if (customer != null) { var customerAvatar = customer.Avatar; var customerPictureFile = uplAvatar.PostedFile; if ((customerPictureFile != null) && (!String.IsNullOrEmpty(customerPictureFile.FileName))) { int avatarMaxSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarMaxSizeBytes", 20000); if (customerPictureFile.ContentLength > avatarMaxSize) { throw new NopException(string.Format("Maximum avatar size is {0} bytes", avatarMaxSize)); } byte[] customerPictureBinary = PictureManager.GetPictureBits(customerPictureFile.InputStream, customerPictureFile.ContentLength); if (customerAvatar != null) { customerAvatar = PictureManager.UpdatePicture(customerAvatar.PictureId, customerPictureBinary, customerPictureFile.ContentType, true); } else { customerAvatar = PictureManager.InsertPicture(customerPictureBinary, customerPictureFile.ContentType, true); } } int customerAvatarId = 0; if (customerAvatar != null) { customerAvatarId = customerAvatar.PictureId; } CustomerManager.SetCustomerAvatarId(customer.CustomerId, customerAvatarId); BindData(); } } } catch (Exception exc) { ShowError(exc.Message); } }
protected void cmdUpload_Click(object sender, EventArgs e) { HttpPostedFile categoryPictureFile = fuNewPicture.PostedFile; if (!string.IsNullOrEmpty(fuNewPicture.FileName)) { byte[] categoryPictureBinary = PictureManager.GetPictureBits(categoryPictureFile.InputStream, categoryPictureFile.ContentLength); Picture picture = PictureManager.InsertPicture(categoryPictureBinary, categoryPictureFile.ContentType, true); if (picture != null) { string redirectURL = Common.Utils.CommonHelper.ModifyQueryString(Request.Url.PathAndQuery, "PictureID=" + picture.PictureId.ToString(), null); Response.Redirect(redirectURL); } } }
private string SavePictureIcon(FileUpload fileupload) { Picture pic = null; lwg_Catalog lwg = new CatalogBiz().GetByID(ProductId); if (lwg != null) { if (!string.IsNullOrEmpty(lwg.SoundIcon)) { pic = PictureManager.GetPictureById(int.Parse(lwg.SoundIcon)); } } HttpPostedFile PictureFile = fileupload.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] pictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); if (pic != null) { pic = PictureManager.UpdatePicture(pic.PictureId, pictureBinary, PictureFile.ContentType, true); } else { pic = PictureManager.InsertPicture(pictureBinary, PictureFile.ContentType, true); } } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; //\ string pictureUrl = PictureManager.GetPictureUrl(pic, 100); imgSoundIcon.Visible = true; imgSoundIcon.ImageUrl = pictureUrl; } return(PictureId.ToString()); }
private bool save() { int emailid = 0; Nop_EmailDirectory email = null; if (Request.QueryString["emailid"] != null && int.TryParse(Request.QueryString["emailid"], out emailid)) { email = emailbiz.GetEmailByID(emailid); } if (email != null) { Picture pic = PictureManager.GetPictureById(email.PictureID.Value); HttpPostedFile PictureFile = fuPicture.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] categoryPictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); if (pic != null) { pic = PictureManager.UpdatePicture(pic.PictureId, categoryPictureBinary, PictureFile.ContentType, true); } else { pic = PictureManager.InsertPicture(categoryPictureBinary, PictureFile.ContentType, true); } } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; } email.Description = this.txtDescription.Content; email.EmailAddress = txtEmailAddress.Text; email.FirstName = txtFirstName.Text; email.LastName = txtLastName.Text; email.PhoneNumber = txtPhoneNumber.Text; email.PictureID = PictureId; email.JobTitle = txtJobTitle.Text; bool b = emailbiz.SaveEmail(email); BindData(); return(b); } else { Picture pic = null; HttpPostedFile PictureFile = fuPicture.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] PictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); pic = PictureManager.InsertPicture(PictureBinary, PictureFile.ContentType, true); } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; } Nop_EmailDirectory newemail = new Nop_EmailDirectory(); newemail.Description = this.txtDescription.Content; newemail.EmailAddress = txtEmailAddress.Text; newemail.FirstName = txtFirstName.Text; newemail.LastName = txtLastName.Text; newemail.PhoneNumber = txtPhoneNumber.Text; newemail.PictureID = PictureId; newemail.JobTitle = txtJobTitle.Text; bool b = emailbiz.SaveEmail(newemail); Response.Redirect("EmailDirectory.aspx"); return(b); } }
public ProductVariant SaveInfo() { DateTime nowDT = DateTime.Now; string name = txtName.Text.Trim(); string sku = txtSKU.Text.Trim(); string description = txtDescription.Value.Trim(); string adminComment = txtAdminComment.Text.Trim(); string manufacturerPartNumber = txtManufacturerPartNumber.Text.Trim(); bool isDownload = cbIsDownload.Checked; bool unlimitedDownloads = cbUnlimitedDownloads.Checked; int maxNumberOfDownloads = txtMaxNumberOfDownloads.Value; bool hasSampleDownload = cbHasSampleDownload.Checked; bool isShipEnabled = cbIsShipEnabled.Checked; bool isFreeShipping = cbIsFreeShipping.Checked; decimal additionalShippingCharge = txtAdditionalShippingCharge.Value; bool isTaxExempt = cbIsTaxExempt.Checked; int taxCategoryID = int.Parse(this.ddlTaxCategory.SelectedItem.Value); bool manageStock = cbManageStock.Checked; int stockQuantity = txtStockQuantity.Value; int minStockQuantity = txtMinStockQuantity.Value; LowStockActivityEnum lowStockActivity = (LowStockActivityEnum)Enum.ToObject(typeof(LowStockActivityEnum), int.Parse(this.ddlLowStockActivity.SelectedItem.Value)); int notifyForQuantityBelow = txtNotifyForQuantityBelow.Value; int orderMinimumQuantity = txtOrderMinimumQuantity.Value; int orderMaximumQuantity = txtOrderMaximumQuantity.Value; int warehouseID = int.Parse(this.ddlWarehouse.SelectedItem.Value); bool disableBuyButton = cbDisableBuyButton.Checked; decimal price = txtPrice.Value; decimal oldPrice = txtOldPrice.Value; decimal weight = txtWeight.Value; decimal length = txtLength.Value; decimal width = txtWidth.Value; decimal height = txtHeight.Value; DateTime?availableStartDateTime = null; DateTime?availableEndDateTime = null; DateTime availableStartDateTimeTmp = nowDT; if (DateTime.TryParse(txtAvailableStartDateTime.Text, out availableStartDateTimeTmp)) { availableStartDateTime = DateTime.SpecifyKind(availableStartDateTimeTmp, DateTimeKind.Utc); } DateTime availableEndDateTimeTmp = nowDT; if (DateTime.TryParse(txtAvailableEndDateTime.Text, out availableEndDateTimeTmp)) { availableEndDateTime = DateTime.SpecifyKind(availableEndDateTimeTmp, DateTimeKind.Utc); } bool published = cbPublished.Checked; int displayOrder = txtDisplayOrder.Value; ProductVariant productVariant = ProductManager.GetProductVariantByID(ProductVariantID); if (productVariant != null) { #region Update Picture productVariantPicture = productVariant.Picture; HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile; if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName))) { byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength); if (productVariantPicture != null) { productVariantPicture = PictureManager.UpdatePicture(productVariantPicture.PictureID, productVariantPictureBinary, productVariantPictureFile.ContentType, true); } else { productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true); } } int productVariantPictureID = 0; if (productVariantPicture != null) { productVariantPictureID = productVariantPicture.PictureID; } int productVariantDownloadID = 0; if (isDownload) { Download productVariantDownload = productVariant.Download; bool useDownloadURL = cbUseDownloadURL.Checked; string downloadURL = txtDownloadURL.Text.Trim(); byte[] productVariantDownloadBinary = null; string downloadContentType = string.Empty; string downloadExtension = string.Empty; if (productVariantDownload != null) { productVariantDownloadBinary = productVariantDownload.DownloadBinary; downloadContentType = productVariantDownload.ContentType; downloadExtension = productVariantDownload.Extension; } HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile; if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName))) { productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength); downloadContentType = productVariantDownloadFile.ContentType; downloadExtension = Path.GetExtension(productVariantDownloadFile.FileName); } if (productVariantDownload != null) { productVariantDownload = DownloadManager.UpdateDownload(productVariantDownload.DownloadID, useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadExtension, true); } else { productVariantDownload = DownloadManager.InsertDownload(useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadExtension, true); } productVariantDownloadID = productVariantDownload.DownloadID; } int productVariantSampleDownloadID = 0; if (hasSampleDownload) { Download productVariantSampleDownload = productVariant.SampleDownload; bool useSampleDownloadURL = cbUseSampleDownloadURL.Checked; string sampleDownloadURL = txtSampleDownloadURL.Text.Trim(); byte[] productVariantSampleDownloadBinary = null; string sampleDownloadContentType = string.Empty; string sampleDownloadExtension = string.Empty; if (productVariantSampleDownload != null) { productVariantSampleDownloadBinary = productVariantSampleDownload.DownloadBinary; sampleDownloadContentType = productVariantSampleDownload.ContentType; sampleDownloadExtension = productVariantSampleDownload.Extension; } HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile; if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName))) { productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength); sampleDownloadContentType = productVariantSampleDownloadFile.ContentType; sampleDownloadExtension = Path.GetExtension(productVariantSampleDownloadFile.FileName); } if (productVariantSampleDownload != null) { productVariantSampleDownload = DownloadManager.UpdateDownload(productVariantSampleDownload.DownloadID, useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadExtension, true); } else { productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadExtension, true); } productVariantSampleDownloadID = productVariantSampleDownload.DownloadID; } productVariant = ProductManager.UpdateProductVariant(ProductVariantID, productVariant.ProductID, name, sku, description, adminComment, manufacturerPartNumber, isDownload, productVariantDownloadID, unlimitedDownloads, maxNumberOfDownloads, hasSampleDownload, productVariantSampleDownloadID, isShipEnabled, isFreeShipping, additionalShippingCharge, isTaxExempt, taxCategoryID, manageStock, stockQuantity, minStockQuantity, lowStockActivity, notifyForQuantityBelow, orderMinimumQuantity, orderMaximumQuantity, warehouseID, disableBuyButton, price, oldPrice, weight, length, width, height, productVariantPictureID, availableStartDateTime, availableEndDateTime, published, productVariant.Deleted, displayOrder, productVariant.CreatedOn, nowDT); #endregion } else { #region Insert Product product = ProductManager.GetProductByID(this.ProductID); if (product != null) { Picture productVariantPicture = null; HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile; if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName))) { byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength); productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true); } int productVariantPictureID = 0; if (productVariantPicture != null) { productVariantPictureID = productVariantPicture.PictureID; } int productVariantDownloadID = 0; if (isDownload) { bool useDownloadURL = cbUseDownloadURL.Checked; string downloadURL = txtDownloadURL.Text.Trim(); byte[] productVariantDownloadBinary = null; string downloadContentType = string.Empty; string downloadExtension = string.Empty; HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile; if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName))) { productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength); downloadContentType = productVariantDownloadFile.ContentType; downloadExtension = Path.GetExtension(productVariantDownloadFile.FileName); } Download productVariantDownload = DownloadManager.InsertDownload(useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadExtension, true); productVariantDownloadID = productVariantDownload.DownloadID; } int productVariantSampleDownloadID = 0; if (hasSampleDownload) { bool useSampleDownloadURL = cbUseSampleDownloadURL.Checked; string sampleDownloadURL = txtSampleDownloadURL.Text.Trim(); byte[] productVariantSampleDownloadBinary = null; string sampleDownloadContentType = string.Empty; string sampleDownloadExtension = string.Empty; HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile; if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName))) { productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength); sampleDownloadContentType = productVariantSampleDownloadFile.ContentType; sampleDownloadExtension = Path.GetExtension(productVariantSampleDownloadFile.FileName); } Download productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadExtension, true); productVariantSampleDownloadID = productVariantSampleDownload.DownloadID; } productVariant = ProductManager.InsertProductVariant(product.ProductID, name, sku, description, adminComment, manufacturerPartNumber, isDownload, productVariantDownloadID, unlimitedDownloads, maxNumberOfDownloads, hasSampleDownload, productVariantSampleDownloadID, isShipEnabled, isFreeShipping, additionalShippingCharge, isTaxExempt, taxCategoryID, cbManageStock.Checked, txtStockQuantity.Value, minStockQuantity, lowStockActivity, notifyForQuantityBelow, orderMinimumQuantity, orderMaximumQuantity, warehouseID, disableBuyButton, price, oldPrice, weight, length, width, height, productVariantPictureID, availableStartDateTime, availableEndDateTime, published, false, displayOrder, nowDT, nowDT); } else { Response.Redirect("Products.aspx"); } #endregion } return(productVariant); }
public string SaveInfo() { PersonBiz pBiz = new PersonBiz(); lwg_Person person = pBiz.GetByID(this.ComposerId); Picture pic = null; if (person == null) { person = new lwg_Person(); } else { if (person.PictureID.HasValue) { if (person.PictureID.Value > 0) { pic = PictureManager.GetPictureById(person.PictureID.Value); } } } HttpPostedFile PictureFile = fuPicture.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] pictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); if (pic != null) { pic = PictureManager.UpdatePicture(pic.PictureId, pictureBinary, PictureFile.ContentType, true); } else { pic = PictureManager.InsertPicture(pictureBinary, PictureFile.ContentType, true); } } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; } person.Biography = Server.HtmlEncode(txtBiography.Content); if (txtDOB.Text.Trim() != person.DOB) { person.DOB = txtDOB.Text.Trim(); } if (txtDOD.Text.Trim() != person.DOD) { person.DOD = txtDOD.Text.Trim(); } string lastName = txtLastName.Text.Trim(); person.FirstLetter = lastName.Length > 0 ? lastName.Substring(0, 1).ToUpper() : string.Empty; person.FirstName = txtFirstName.Text.Trim(); person.LastName = lastName; person.NameDisplay = txtNameDisplay.Text.Trim(); person.NameList = txtNameList.Text.Trim(); person.NameSort = txtNameSort.Text.Trim(); person.PictureID = PictureId; pBiz.SavePerson(person); return(person.PersonId.ToString()); }
public ProductVariant SaveInfo() { DateTime nowDT = DateTime.UtcNow; string name = txtName.Text.Trim(); string sku = txtSKU.Text.Trim(); string description = txtDescription.Content; string adminComment = txtAdminComment.Text.Trim(); string manufacturerPartNumber = txtManufacturerPartNumber.Text.Trim(); bool isGiftCard = cbIsGiftCard.Checked; int giftCardType = int.Parse(this.ddlGiftCardType.SelectedItem.Value); bool isDownload = cbIsDownload.Checked; bool unlimitedDownloads = cbUnlimitedDownloads.Checked; int maxNumberOfDownloads = txtMaxNumberOfDownloads.Value; int? downloadExpirationDays = null; if (!String.IsNullOrEmpty(txtDownloadExpirationDays.Text.Trim())) { downloadExpirationDays = int.Parse(txtDownloadExpirationDays.Text.Trim()); } DownloadActivationTypeEnum downloadActivationType = (DownloadActivationTypeEnum)Enum.ToObject(typeof(DownloadActivationTypeEnum), int.Parse(this.ddlDownloadActivationType.SelectedItem.Value)); bool hasUserAgreement = cbHasUserAgreement.Checked; string userAgreementText = txtUserAgreementText.Content; bool hasSampleDownload = cbHasSampleDownload.Checked; bool isRecurring = cbIsRecurring.Checked; int cycleLength = txtCycleLength.Value; RecurringProductCyclePeriodEnum cyclePeriod = (RecurringProductCyclePeriodEnum)Enum.ToObject(typeof(RecurringProductCyclePeriodEnum), int.Parse(this.ddlCyclePeriod.SelectedItem.Value)); int totalCycles = txtTotalCycles.Value; bool isShipEnabled = cbIsShipEnabled.Checked; bool isFreeShipping = cbIsFreeShipping.Checked; decimal additionalShippingCharge = txtAdditionalShippingCharge.Value; bool isTaxExempt = cbIsTaxExempt.Checked; int taxCategoryId = int.Parse(this.ddlTaxCategory.SelectedItem.Value); int manageStock = Convert.ToInt32(ddlManageStock.SelectedValue); int stockQuantity = txtStockQuantity.Value; bool displayStockAvailability = cbDisplayStockAvailability.Checked; bool displayStockQuantity = cbDisplayStockQuantity.Checked; int minStockQuantity = txtMinStockQuantity.Value; LowStockActivityEnum lowStockActivity = (LowStockActivityEnum)Enum.ToObject(typeof(LowStockActivityEnum), int.Parse(this.ddlLowStockActivity.SelectedItem.Value)); int notifyForQuantityBelow = txtNotifyForQuantityBelow.Value; int backorders = int.Parse(this.ddlBackorders.SelectedItem.Value); int orderMinimumQuantity = txtOrderMinimumQuantity.Value; int orderMaximumQuantity = txtOrderMaximumQuantity.Value; int warehouseId = int.Parse(this.ddlWarehouse.SelectedItem.Value); bool disableBuyButton = cbDisableBuyButton.Checked; bool callForPrice = cbCallForPrice.Checked; decimal price = txtPrice.Value; decimal oldPrice = txtOldPrice.Value; decimal productCost = txtProductCost.Value; bool customerEntersPrice = cbCustomerEntersPrice.Checked; decimal minimumCustomerEnteredPrice = txtMinimumCustomerEnteredPrice.Value; decimal maximumCustomerEnteredPrice = txtMaximumCustomerEnteredPrice.Value; decimal weight = txtWeight.Value; decimal length = txtLength.Value; decimal width = txtWidth.Value; decimal height = txtHeight.Value; DateTime?availableStartDateTime = ctrlAvailableStartDateTimePicker.SelectedDate; DateTime?availableEndDateTime = ctrlAvailableEndDateTimePicker.SelectedDate; if (availableStartDateTime.HasValue) { availableStartDateTime = DateTime.SpecifyKind(availableStartDateTime.Value, DateTimeKind.Utc); } if (availableEndDateTime.HasValue) { availableEndDateTime = DateTime.SpecifyKind(availableEndDateTime.Value, DateTimeKind.Utc); } bool published = cbPublished.Checked; int displayOrder = txtDisplayOrder.Value; ProductVariant productVariant = ProductManager.GetProductVariantById(ProductVariantId); if (productVariant != null) { #region Update Picture productVariantPicture = productVariant.Picture; HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile; if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName))) { byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength); if (productVariantPicture != null) { productVariantPicture = PictureManager.UpdatePicture(productVariantPicture.PictureId, productVariantPictureBinary, productVariantPictureFile.ContentType, true); } else { productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true); } } int productVariantPictureId = 0; if (productVariantPicture != null) { productVariantPictureId = productVariantPicture.PictureId; } int productVariantDownloadId = 0; if (isDownload) { Download productVariantDownload = productVariant.Download; bool useDownloadURL = cbUseDownloadURL.Checked; string downloadURL = txtDownloadURL.Text.Trim(); byte[] productVariantDownloadBinary = null; string downloadContentType = string.Empty; string downloadFilename = string.Empty; string downloadExtension = string.Empty; if (productVariantDownload != null) { productVariantDownloadBinary = productVariantDownload.DownloadBinary; downloadContentType = productVariantDownload.ContentType; downloadFilename = productVariantDownload.Filename; downloadExtension = productVariantDownload.Extension; } HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile; if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName))) { productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength); downloadContentType = productVariantDownloadFile.ContentType; downloadFilename = Path.GetFileNameWithoutExtension(productVariantDownloadFile.FileName); downloadExtension = Path.GetExtension(productVariantDownloadFile.FileName); } if (productVariantDownload != null) { productVariantDownload = DownloadManager.UpdateDownload(productVariantDownload.DownloadId, useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadFilename, downloadExtension, true); } else { productVariantDownload = DownloadManager.InsertDownload(useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadFilename, downloadExtension, true); } productVariantDownloadId = productVariantDownload.DownloadId; } int productVariantSampleDownloadId = 0; if (hasSampleDownload) { Download productVariantSampleDownload = productVariant.SampleDownload; bool useSampleDownloadURL = cbUseSampleDownloadURL.Checked; string sampleDownloadURL = txtSampleDownloadURL.Text.Trim(); byte[] productVariantSampleDownloadBinary = null; string sampleDownloadContentType = string.Empty; string sampleDownloadFilename = string.Empty; string sampleDownloadExtension = string.Empty; if (productVariantSampleDownload != null) { productVariantSampleDownloadBinary = productVariantSampleDownload.DownloadBinary; sampleDownloadContentType = productVariantSampleDownload.ContentType; sampleDownloadFilename = productVariantSampleDownload.Filename; sampleDownloadExtension = productVariantSampleDownload.Extension; } HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile; if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName))) { productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength); sampleDownloadContentType = productVariantSampleDownloadFile.ContentType; sampleDownloadFilename = Path.GetFileNameWithoutExtension(productVariantSampleDownloadFile.FileName); sampleDownloadExtension = Path.GetExtension(productVariantSampleDownloadFile.FileName); } if (productVariantSampleDownload != null) { productVariantSampleDownload = DownloadManager.UpdateDownload(productVariantSampleDownload.DownloadId, useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true); } else { productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true); } productVariantSampleDownloadId = productVariantSampleDownload.DownloadId; } productVariant = ProductManager.UpdateProductVariant(ProductVariantId, productVariant.ProductId, name, sku, description, adminComment, manufacturerPartNumber, isGiftCard, giftCardType, isDownload, productVariantDownloadId, unlimitedDownloads, maxNumberOfDownloads, downloadExpirationDays, downloadActivationType, hasSampleDownload, productVariantSampleDownloadId, hasUserAgreement, userAgreementText, isRecurring, cycleLength, (int)cyclePeriod, totalCycles, isShipEnabled, isFreeShipping, additionalShippingCharge, isTaxExempt, taxCategoryId, manageStock, stockQuantity, displayStockAvailability, displayStockQuantity, minStockQuantity, lowStockActivity, notifyForQuantityBelow, backorders, orderMinimumQuantity, orderMaximumQuantity, warehouseId, disableBuyButton, callForPrice, price, oldPrice, productCost, customerEntersPrice, minimumCustomerEnteredPrice, maximumCustomerEnteredPrice, weight, length, width, height, productVariantPictureId, availableStartDateTime, availableEndDateTime, published, productVariant.Deleted, displayOrder, productVariant.CreatedOn, nowDT); #endregion } else { #region Insert Product product = ProductManager.GetProductById(this.ProductId); if (product != null) { Picture productVariantPicture = null; HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile; if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName))) { byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength); productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true); } int productVariantPictureId = 0; if (productVariantPicture != null) { productVariantPictureId = productVariantPicture.PictureId; } int productVariantDownloadId = 0; if (isDownload) { bool useDownloadURL = cbUseDownloadURL.Checked; string downloadURL = txtDownloadURL.Text.Trim(); byte[] productVariantDownloadBinary = null; string downloadContentType = string.Empty; string downloadFilename = string.Empty; string downloadExtension = string.Empty; HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile; if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName))) { productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength); downloadContentType = productVariantDownloadFile.ContentType; downloadFilename = Path.GetFileNameWithoutExtension(productVariantDownloadFile.FileName); downloadExtension = Path.GetExtension(productVariantDownloadFile.FileName); } Download productVariantDownload = DownloadManager.InsertDownload(useDownloadURL, downloadURL, productVariantDownloadBinary, downloadContentType, downloadFilename, downloadExtension, true); productVariantDownloadId = productVariantDownload.DownloadId; } int productVariantSampleDownloadId = 0; if (hasSampleDownload) { bool useSampleDownloadURL = cbUseSampleDownloadURL.Checked; string sampleDownloadURL = txtSampleDownloadURL.Text.Trim(); byte[] productVariantSampleDownloadBinary = null; string sampleDownloadContentType = string.Empty; string sampleDownloadFilename = string.Empty; string sampleDownloadExtension = string.Empty; HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile; if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName))) { productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength); sampleDownloadContentType = productVariantSampleDownloadFile.ContentType; sampleDownloadFilename = Path.GetFileNameWithoutExtension(productVariantSampleDownloadFile.FileName); sampleDownloadExtension = Path.GetExtension(productVariantSampleDownloadFile.FileName); } Download productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary, sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true); productVariantSampleDownloadId = productVariantSampleDownload.DownloadId; } productVariant = ProductManager.InsertProductVariant(product.ProductId, name, sku, description, adminComment, manufacturerPartNumber, isGiftCard, giftCardType, isDownload, productVariantDownloadId, unlimitedDownloads, maxNumberOfDownloads, downloadExpirationDays, downloadActivationType, hasSampleDownload, productVariantSampleDownloadId, hasUserAgreement, userAgreementText, isRecurring, cycleLength, (int)cyclePeriod, totalCycles, isShipEnabled, isFreeShipping, additionalShippingCharge, isTaxExempt, taxCategoryId, manageStock, stockQuantity, displayStockAvailability, displayStockQuantity, minStockQuantity, lowStockActivity, notifyForQuantityBelow, backorders, orderMinimumQuantity, orderMaximumQuantity, warehouseId, disableBuyButton, callForPrice, price, oldPrice, productCost, customerEntersPrice, minimumCustomerEnteredPrice, maximumCustomerEnteredPrice, weight, length, width, height, productVariantPictureId, availableStartDateTime, availableEndDateTime, published, false, displayOrder, nowDT, nowDT); } else { Response.Redirect("Products.aspx"); } #endregion } SaveLocalizableContent(productVariant); return(productVariant); }