コード例 #1
0
ファイル: NewItemForm.cs プロジェクト: rew170/soomecode
 private void SetProductImages(Product item)
 {
     if (item == null) return;
     imageSelector.Tag = item.Image;
     imageSelector.ImageFile = manager.GetProductImageFile(item.Id, item.Image);
     List<ProductImage> imageList = manager.GetImagesInfoByProductId(item.Id);
     int index = 1;
     foreach(ProductImage obj in imageList)
     {
         if (obj.IsMain) continue;
         ImageSelector selector = (ImageSelector)ImageGroup.Controls["ProductImage" + index];
         selector.ImageFile = manager.GetProductImageFile(item.Id, obj);
         selector.Tag = obj;
         index++;
     }
 }
コード例 #2
0
ファイル: NewItemForm.cs プロジェクト: rew170/soomecode
 protected void LoadUpdatedProduct(Product obj)
 {
     if (obj == null)
     {
         return;
     }
     this.PName.Text = obj.Name;
     this.ProductModel.Text = obj.Model;
     this.Weight.Text = obj.Weight;
     this.ProductPrice.Text = obj.Price.ToString("###0.00");
     this.Psize.Text = obj.Size;
     this.Minimum.Text = obj.Minimum.ToString();
     this.Packing.Text = obj.Packing;
     AliHelperUtils.LoadAppDicComboBoxValue(this.ProductStatus, obj.Status);
     LoadPriceCateComboBoxValue(this.PriceCate, obj.PriceCate);
     this.selectedCategory = new Categories();
     this.selectedCategory.Id = obj.CategoryId;
     SetProductImages(obj);
     this.webBrowser1.Document.InvokeScript("SetData", new object[] { HttpUtility.HtmlDecode(obj.Description) });
 }
コード例 #3
0
ファイル: NewItemForm.cs プロジェクト: rew170/soomecode
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (selectedCategory == null)
     {
         MessageBox.Show("产品分类必须选择!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (this.PName.Text.Trim() == null)
     {
         MessageBox.Show("产品名称必须填写!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (this.ProductModel.Text.Trim() == null)
     {
         MessageBox.Show("产品型号必须填写!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (string.IsNullOrEmpty(this.imageSelector.ImageFile))
     {
         MessageBox.Show("产品图片必须!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     Product item = null;
     if (UpdatedProduct == null)
     {
         item = new Product();
     }
     else {
         item = UpdatedProduct;
     }
     item.Name = this.PName.Text.Trim();
     item.Model = this.ProductModel.Text.Trim();
     item.Price = Convert.ToDouble(this.ProductPrice.Text);
     item.CategoryId = selectedCategory.Id;
     item.Weight = this.Weight.Text.Trim();
     item.Size = this.Psize.Text.Trim();
     item.Minimum = Convert.ToInt32(this.Minimum.Text.Trim());
     item.Packing = this.Packing.Text.Trim();
     item.Status = ((AppDic)this.ProductStatus.SelectedItem).Key;
     item.Description = (string)this.webBrowser1.Document.InvokeScript("GetData", null);
     List<ProductImage> imageList = GetProductImages();
     manager.InsertOrUpdateProduct(item, imageList);
     this.Close();
 }