本文整理汇总了C#中Product.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Product.Create方法的具体用法?C# Product.Create怎么用?C# Product.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.Create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btn_AddProduct_Click
protected void btn_AddProduct_Click(object sender, EventArgs e)
{
if (txt_Brand.Text != "" && txt_Category.Text != "" && txt_Date_of_Production.Text != "" && txt_OffPercentage.Text != "" &&
txt_Price.Text != "" && txt_ProductId.Text != "" && txt_ProductName.Text != "" && txt_Stock.Text != "" &&
FileUpload_ImageProduct.FileName != "")
{
//check the DB to existent of same info with this product (as image name ProductId and...) !important
FileUpload_ImageProduct.SaveAs(MapPath(@"~\Images\Products\" + FileUpload_ImageProduct.FileName));
Product item = new Product();
item.Brand = txt_Brand.Text;
item.Category = txt_Category.Text;
item.Date_of_Production = txt_Date_of_Production.Text;
item.Discount = FileUpload_ImageProduct.FileName;
item.Off_Percentage = int.Parse(txt_OffPercentage.Text);
item.Price = txt_Price.Text;
item.ProductId = txt_ProductId.Text;
item.ProductName = txt_ProductName.Text;
item.Stock = long.Parse(txt_Stock.Text);
item.Date_Created = DateTime.Now.ToShortDateString();
item.Total_Rate = 0;
item.Create();
}
else
{
lbl_error.Text = "فیلدهای خالی را پر کنید!";
}
}
示例2: Main
static void Main(string[] args)
{
try
{
Manufacturer m = new Manufacturer();
m.Name = "Roland";
m.Create();
Product p = new Product();
p.Manufacturer = m;
p.Name = "Juno G";
p.Create();
//create a different date updated
System.Threading.Thread.Sleep(2000);
p.Name = "Juno D 61 Key Pro Keyboard";
p.Update();
Product[] products = Product.FindAll();
foreach (Product product in products)
{
Console.WriteLine("{0} by {1} was last modified on {2}",
product.Name, product.Manufacturer.Name, product.ModifiedDate);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.GetBaseException().Message);
}
}
示例3: CompositeUserTypeWithAccess
public void CompositeUserTypeWithAccess()
{
ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Product));
Recreate();
Product product = new Product(new string[]{"John", "Doe"}, new string[]{"Acme", "Inc"});
product.Create();
Product loaded = Product.Find(product.Id);
Assert.IsNotNull(loaded);
Assert.AreEqual("John", loaded.Name[0]);
Assert.AreEqual("Doe", loaded.Name[1]);
Assert.AreEqual("Acme", loaded.ManufacturerName[0]);
Assert.AreEqual("Inc", loaded.ManufacturerName[1]);
}
示例4: Create
public ActionResult Create(Product item)
{
item.Supplier = Supplier.TryFind (item.SupplierId);
if (!ModelState.IsValid) {
return PartialView ("_Create", item);
}
item.MinimumOrderQuantity = 1;
item.TaxRate = WebConfig.DefaultVAT;
item.IsTaxIncluded = WebConfig.IsTaxIncluded;
item.PriceType = WebConfig.DefaultPriceType;
item.Photo = WebConfig.DefaultPhotoFile;
using (var scope = new TransactionScope ()) {
item.Create ();
foreach (var l in PriceList.Queryable.ToList ()) {
var price = new ProductPrice {
Product = item,
List = l,
Value = WebConfig.DefaultPrice
};
price.Create ();
}
scope.Flush ();
}
return PartialView ("_CreateSuccesful", item);
}
示例5: CreateProduct
public void CreateProduct(string Title, string Group, string SubGroup, string Partcode, string Manufacturer, string Description, string InternalNotes, string Availability, string ProductLines)
{
Product p = new Product();
p.Title = Title;
p.Group = Group;
p.SubGroup = SubGroup;
p.Partcode = Partcode;
p.Manufacturer = Manufacturer;
p.Description = Description;
p.InternalNotes = InternalNotes;
p.Availability = Availability;
Product newProduct = p.Create();
foreach (string productLineId in ProductLines.Split(','))
{
if (!String.IsNullOrEmpty(productLineId))
newProduct.AttachProductLine(Convert.ToInt32(productLineId));
}
}