protected void btn_Submit_Click(object sender, EventArgs e) { using (var db = new Solution.AdventureWorksEntities()) { var obj = new Solution.Product(); obj.Color = txt_Color.Text; obj.ListPrice = Convert.ToDecimal(txt_ListPrice.Text); obj.ModifiedDate = DateTime.Now; obj.Name = txt_Name.Text; obj.ProductCategoryID = Convert.ToInt32(ddl_Category2.SelectedValue); obj.ProductNumber = txt_ProductNumber.Text; obj.SellStartDate = DateTime.Now; obj.Size = txt_Size.Text; obj.StandardCost = Convert.ToDecimal(txt_StandardCost.Text); obj.ThumbnailPhotoFileName = ""; obj.ThumbNailPhoto = null; obj.rowguid = Guid.NewGuid(); obj.Weight = Convert.ToDecimal(txt_Weight.Text); db.Products.AddObject(obj); db.SaveChanges(); GV.SelectedIndex = -1; GV.DataBind(); TC.ActiveTabIndex = 0; } }
/// <summary> /// Deprecated Method for adding a new object to the Products EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProducts(Product product) { base.AddObject("Products", product); }
/// <summary> /// Create a new Product object. /// </summary> /// <param name="productID">Initial value of the ProductID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="productNumber">Initial value of the ProductNumber property.</param> /// <param name="standardCost">Initial value of the StandardCost property.</param> /// <param name="listPrice">Initial value of the ListPrice property.</param> /// <param name="sellStartDate">Initial value of the SellStartDate property.</param> /// <param name="rowguid">Initial value of the rowguid property.</param> /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param> public static Product CreateProduct(global::System.Int32 productID, global::System.String name, global::System.String productNumber, global::System.Decimal standardCost, global::System.Decimal listPrice, global::System.DateTime sellStartDate, global::System.Guid rowguid, global::System.DateTime modifiedDate) { Product product = new Product(); product.ProductID = productID; product.Name = name; product.ProductNumber = productNumber; product.StandardCost = standardCost; product.ListPrice = listPrice; product.SellStartDate = sellStartDate; product.rowguid = rowguid; product.ModifiedDate = modifiedDate; return product; }