public void FindCommodityByName_Test() { var expected = commodity; var actual = CommodityManager.FindCommodityByName("HP"); Assert.AreEqual(expected, actual); }
public WvsShop( IApplicationLifetime appLifetime, ICacheClient cache, IMessageBus messageBus, IOptions <ShopServiceInfo> info, IDataContextFactory dataContextFactory, ITemplateManager templateManager ) : base(appLifetime, cache, messageBus, info, dataContextFactory) { TemplateManager = templateManager; CommodityManager = new CommodityManager(TemplateManager); }
public ShopService( IOptions <ShopServiceInfo> info, ICacheClient cacheClient, IMessageBusFactory messageBusFactory, IDataStore dataStore, ITemplateManager templateManager ) : base(info.Value, cacheClient, messageBusFactory) { DataStore = dataStore; TemplateManager = templateManager; CommodityManager = new CommodityManager(TemplateManager); }
protected void Button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtContent.Text)) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请输入信息后再点击!');</script>"); } else { Model.Commodity ns = new Model.Commodity(); ns.C_Name = TextBox1.Text.Trim(); ns.C_Price = TextBox2.Text.Trim(); ns.C_Color = TextBox3.Text.Trim(); ns.C_Kucun = TextBox4.Text.Trim(); ns.C_Size = TextBox5.Text.Trim(); ns.C_Biaoshi = TextBox6.Text.Trim(); ns.C_Content = txtContent.Text.Trim(); try { if (FileUpload1.HasFile) { string filePath = FileUpload1.PostedFile.FileName; string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1); string serverpath = Server.MapPath(@"img\") + filename; string relativepath = @"img\" + filename; FileUpload1.PostedFile.SaveAs(serverpath); ns.C_Photo = relativepath; } else { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('请先上传商品图片!');</script>"); return; } if (CommodityManager.publishShangping(ns) == 1) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } }
private void BindCommodity() { int id = Request.QueryString["id"] != null?int.Parse(Request.QueryString["id"]) : 0; if (id != 0) { DataTable dt = CommodityManager.SelectID(id); if (dt != null && dt.Rows.Count != 0) { DataList1.DataSource = dt; DataList1.DataBind(); } } }