示例#1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     String name = TextBox1.Text.Trim();
     decimal price = Convert.ToDecimal(TextBox2.Text.Trim());
     decimal marketprice = Convert.ToDecimal(TextBox3.Text.Trim());
     int qty = Convert.ToInt32(TextBox4.Text.Trim());
     int brandId = Convert.ToInt32(DropDownList1.SelectedValue);
     int genderId = Convert.ToInt32(DropDownList2.SelectedValue);
     int id;
     using (LiBoClothesShopEntities context = new LiBoClothesShopEntities())
     {
         Cloth cloth = new Cloth();
         cloth.Name = name;
         cloth.Price = price;
         cloth.OriginalPrice = marketprice;
         cloth.Qty = qty;
         cloth.BrandId = brandId;
         cloth.GenderId = genderId;
         context.AddToClothes(cloth);
         context.SaveChanges();
         id = cloth.Id;
         foreach (ListItem item in CheckBoxList1.Items)
         {
             if (item.Selected)
             {
                 ClothSzie size = new ClothSzie();
                 size.Cloth = cloth;
                 size.SizeId = Convert.ToInt32(item.Value);
                 context.AddToClothSzies(size);
             }
         }
         context.SaveChanges();
         foreach (ListItem item in CheckBoxList2.Items)
         {
             if (item.Selected)
             {
                 ColthColor color = new ColthColor();
                 color.Cloth = cloth;
                 color.ColorId = Convert.ToInt32(item.Value);
                 context.AddToColthColors(color);
             }
         }
         context.SaveChanges();
     }
     Response.Redirect(String.Format("~/AddClothStep2.aspx?id={0}", id));
 }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ColthColors EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToColthColors(ColthColor colthColor)
 {
     base.AddObject("ColthColors", colthColor);
 }
示例#3
0
 /// <summary>
 /// Create a new ColthColor object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="clothId">Initial value of the ClothId property.</param>
 /// <param name="colorId">Initial value of the ColorId property.</param>
 public static ColthColor CreateColthColor(global::System.Int32 id, global::System.Int32 clothId, global::System.Int32 colorId)
 {
     ColthColor colthColor = new ColthColor();
     colthColor.Id = id;
     colthColor.ClothId = clothId;
     colthColor.ColorId = colorId;
     return colthColor;
 }