/// <summary> /// get商品列表 /// </summary> /// <returns></returns> public static List <GoodModel> GetGoodsList2() { string sqlText = "select * from Goods where goods_is_delete = 0"; SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText); List <GoodModel> goodsList = new List <GoodModel>(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { GoodModel goodModel = new GoodModel(); goodModel.GoodsId = Convert.ToInt32(sdr["Goods_id"]); goodModel.GoodsName = sdr["Goods_name"].ToString(); goodModel.GoodsPrice = Convert.ToInt32(sdr["Goods_price"]); goodModel.GoodsSalesVolume = Convert.ToInt32(sdr["Goods_sales_volume"]); goodModel.GoodsStock = Convert.ToInt32(sdr["Goods_stock"]); goodModel.GoodsPicture = sdr["Goods_picture"].ToString(); goodsList.Add(goodModel); } sdr.Close(); return(goodsList); } else { return(null); } } else { return(null); } }
/// <summary> /// 根据商品类型 get商品列表 /// </summary> /// <param name="effectId"></param> /// <returns></returns> public static List <GoodModel> GetGoodsListByEffectId(string effectId) { string sqlText = "SELECT * FROM Goods WHERE Goods_is_delete = 0 and Goods_GoodsType = @Goods_GoodsType"; SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText, new SqlParameter("@Goods_GoodsType", effectId)); List <GoodModel> goodsList = new List <GoodModel>(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { GoodModel goodModel = new GoodModel(); goodModel.GoodsId = Convert.ToInt32(sdr["Goods_id"]); goodModel.GoodsName = sdr["Goods_name"].ToString(); goodModel.GoodsPrice = Convert.ToInt32(sdr["Goods_price"]); goodModel.GoodsSalesVolume = Convert.ToInt32(sdr["Goods_sales_volume"]); goodModel.GoodsPicture = sdr["Goods_picture"].ToString(); goodsList.Add(goodModel); } sdr.Close(); return(goodsList); } else { return(null); } } else { return(null); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; int id = context.Request.QueryString["goods_id"] == null ? 0 : Int32.Parse(context.Request.QueryString["goods_id"]); string temp = File.ReadAllText(context.Server.MapPath("drugstore_details.html")); GoodModel good = GoodsBLL.GetAGoodDetail(id); temp = temp.Replace("@goods_id", good.GoodsId.ToString()); temp = temp.Replace("@a1", good.GoodsName); temp = temp.Replace("@a2", good.GoodsEffect); temp = temp.Replace("@a3", good.GoodsPrice.ToString()); temp = temp.Replace("@a4", "商品规格:" + good.GoodsNorms); temp = temp.Replace("@a5", "生产厂家:" + good.GoodsFactory); temp = temp.Replace("@a6", "库存状态: " + good.GoodsStock); temp = temp.Replace("@a7", "../Images/product_img/" + good.GoodsPicture); if (context.Session["users_id"] != null) { temp = temp.Replace("@user_name", context.Session["user_name"].ToString()); } else { temp = temp.Replace("@user_name", "游客"); } context.Response.Write(temp); }
public Good Convert(GoodModel model) { Good good = context.CreateEmptyGood(); good.Barcode = model.Barcode; good.Name = model.Name; good.NdsNo = model.NdsNo; good.Nds0 = model.Nds0 / CopecksInRouble; good.Nds10 = model.Nds10 / CopecksInRouble; good.Nds18 = model.Nds18 / CopecksInRouble; good.NdsCalculated10 = model.NdsCalculated10 / CopecksInRouble; good.NdsCalculated18 = model.NdsCalculated18 / CopecksInRouble; good.Price = model.Price / CopecksInRouble; good.Quantity = model.Quantity; good.Sum = model.Sum / CopecksInRouble; foreach (ModifierModel item in model.Modifiers) { good.Modifiers.Add(Convert(item)); } foreach (ReceiptPropertyModel property in model.Properties) { good.Properties.Add(Convert(property)); } return(good); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CreationDate,Name,Price,Description,InStock,Attachment")] GoodModel goodModel) { if (id != goodModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(goodModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GoodModelExists(goodModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(goodModel)); }
public ActionResult DeleteConfirmed(int id) { GoodModel goodModel = db.GoodModels.Find(id); db.GoodModels.Remove(goodModel); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddWishListItem(int SelectedGroup) { GoodModel lmd = new GoodModel(); lmd.GG_Id = Convert.ToInt16(SelectedGroup); lmd.Gd_Name = ""; lmd.Gd_RequiredNo = 0; return(View(lmd)); }
public async Task <IActionResult> Create([Bind("Id,CreationDate,Name,Price,Description,InStock,Attachment")] GoodModel goodModel) { if (ModelState.IsValid) { _context.Add(goodModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(goodModel)); }
public ActionResult Edit([Bind(Include = "Id,Name,Articul,Country,Measure,Weight,Capasity,VAT,AutoOst,PriseIn,PriseOut,ConterpartyId,Description")] GoodModel goodModel) { if (ModelState.IsValid) { db.Entry(goodModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ConterpartyId = new SelectList(db.Conterparties, "Id", "Name", goodModel.ConterpartyId); return(View(goodModel)); }
public bool UpdateGood(GoodModel good) { DatabaseContextEngine databaseContext = new DatabaseContextEngine(); var findCopy = databaseContext.Goods.Find(good.ActualID); findCopy.Price = good.Price; findCopy.Name = good.Name; findCopy.ImageName = good.ImagePath; databaseContext.Update(findCopy); databaseContext.SaveChanges(); return(true); }
protected bool CanExecuteModifySelectedStorageCommandDo() { if (GoodBatch.Equals("") || GoodModel.Equals("") || _goodCount == 0 || GoodName.Equals("")) { return(false); } else { return(true); } }
// GET: Good/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GoodModel goodModel = db.GoodModels.Find(id); if (goodModel == null) { return(HttpNotFound()); } return(View(goodModel)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; if (context.Session["id"] != null) { string temp = File.ReadAllText(context.Server.MapPath("drugstore_admin_order.html")); if (context.Request.Form["goods_number"] != null) { int i = OrderBLL.SendOrder(context.Request.Form["goods_number"].ToString()); } List <OrdersModel> orderList = new List <OrdersModel>(); if (context.Request.Form["name"] == null) { orderList = OrderBLL.GetOrderByIsend(); } else { orderList = OrderBLL.GetOrderByName(context.Request.Form["name"].ToString()); } StringBuilder sb = new StringBuilder(); if (orderList != null) { foreach (OrdersModel item in orderList) { sb.AppendFormat("<div class='panel panel-default'><div class='panel-heading'><b>{0}</b>订单号: <span>{1}</span> <span class='pull-right'>是否发货:{5}</span><span class='pull-right'>买家ID:{2}</span><span class='pull-right'> </span><span class='pull-right'>手机:{3}</span><span class='pull-right'> </span><span class='pull-right'>{4}</span> </div><table class='table table-bordered'><thead><tr><td>#</td><td>药品名</td><td>治疗症状</td><td>数量</td></tr></thead><tbody>", item.Ordertime, item.Ordernumber, item.Orderusersid.ToString(), item.Orderphone, item.Orderadress, item.OrderIssend); List <GoodsorderModel> dt1 = GoodsOrderBLL.GetGoodsOrderListById(item.Orderid); foreach (GoodsorderModel item1 in dt1) { GoodModel goods = GoodsBLL.GetAGoodDetail(item1.Gdod_goods_id); //dt2.Rows[0].item[""] sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", goods.GoodsId, goods.GoodsName, goods.GoodsEffect, item1.Gdod_order_count); } sb.AppendFormat("</tbody></table></div> "); } } temp = temp.Replace("@admin", context.Session["admin_name"].ToString()); temp = temp.Replace("@content", sb.ToString()); context.Response.Write(temp); } else { context.Response.Redirect("~/admin_login.html"); } }
// GET: Good/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GoodModel goodModel = db.GoodModels.Find(id); if (goodModel == null) { return(HttpNotFound()); } ViewBag.ConterpartyId = new SelectList(db.Conterparties, "Id", "Name", goodModel.ConterpartyId); return(View(goodModel)); }
public Good(GoodModel goodModel) { Name = goodModel.Name; Price = goodModel.Price; IsAvailable = goodModel.IsAvailable; Description = goodModel.Description; ProducerId = goodModel.ProducerId; ManufacturerId = goodModel.ManufacturerId; MaterialValue = goodModel.Material; ColorValue = goodModel.Color; if (goodModel.UserId != null && goodModel.UserId != new Guid()) { UserId = goodModel.UserId; } }
public bool AddGood(GoodModel good) { DatabaseContextEngine databaseContextEngine = new DatabaseContextEngine(); var user = databaseContextEngine.Users.Find(good.CreatorID); databaseContextEngine.Goods.Add(new Good { Creator = user, DateTime = DateTime.Now, ImageName = good.ImagePath, Name = good.Name, Price = good.Price }); databaseContextEngine.SaveChanges(); return(true); }
/// <summary> /// 修改商品 /// </summary> /// <param name="good"></param> /// <returns></returns> public static int UpdateGood(GoodModel good) { string sqlText = "UPDATE Goods SET Goods_name= @Goods_name,Goods_effect=@Goods_effect, Goods_price=@Goods_price, Goods_norms=@Goods_norms, Goods_factory=@Goods_factory, Goods_picture=@Goods_picture, Goods_stock=@Goods_stock,Goods_GoodsType=@Goods_GoodsType WHERE Goods_id=@Goods_id"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@Goods_id", good.GoodsId), new SqlParameter("@Goods_name", good.GoodsName), new SqlParameter("@Goods_effect", good.GoodsEffect), new SqlParameter("@Goods_price", good.GoodsPrice), new SqlParameter("@Goods_factory", good.GoodsFactory), new SqlParameter("@Goods_stock", good.GoodsStock), new SqlParameter("@Goods_norms", good.GoodsNorms), new SqlParameter("@Goods_picture", good.GoodsPicture), new SqlParameter("@Goods_GoodsType", good.GoodsGoodsType) }; return(SQLHelper.ExecuteNonQuery(sqlText, paras)); }
/// <summary> /// 添加 /// </summary> /// <param name="good"></param> /// <returns></returns> public static int AddGood(GoodModel good) { string sqlText = "INSERT into Goods VALUES(@Goods_name,@Goods_effect,@Goods_price,@Goods_norms,@Goods_factory,@Goods_stock,'',@Goods_shelf_time,@Goods_picture,@Goods_is_delete,@Goods_GoodsType)"; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@Goods_name", good.GoodsName), new SqlParameter("@Goods_effect", good.GoodsEffect), new SqlParameter("@Goods_price", good.GoodsPrice), new SqlParameter("@Goods_factory", good.GoodsFactory), new SqlParameter("@Goods_stock", good.GoodsStock), new SqlParameter("@Goods_norms", good.GoodsNorms), new SqlParameter("@Goods_picture", good.GoodsPicture), new SqlParameter("@Goods_shelf_time", good.GoodsShelfTime), new SqlParameter("@Goods_is_delete", ""), new SqlParameter("@Goods_GoodsType", good.GoodsGoodsType) }; return(SQLHelper.ExecuteNonQuery(sqlText, paras)); }
public async Task <int> AddGood(GoodModel goodModel, string email) { try { goodModel.UserId = (await _context.Users.FirstOrDefaultAsync(user => user.Email == email)).Id; var good = new Good(goodModel); await AddGoodData(goodModel.ImageIds, good); await _context.Goods.AddAsync(good); await _context.SaveChangesAsync(); return(1); } catch (Exception ex) { throw; } }
/// <summary> /// get商品信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public static GoodModel GetAGoodDetail(int id) { string sqlText = "select * from Goods where Goods_id=@goods_id"; SqlParameter[] spa = new SqlParameter[] { new SqlParameter("@goods_id", id) }; SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText, spa); GoodModel goodModel = new GoodModel(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { goodModel.GoodsId = Convert.ToInt32(sdr["Goods_id"]); goodModel.GoodsName = sdr["Goods_name"].ToString(); goodModel.GoodsEffect = sdr["Goods_effect"].ToString(); goodModel.GoodsPrice = Convert.ToInt32(sdr["Goods_price"]); goodModel.GoodsNorms = sdr["Goods_norms"].ToString(); goodModel.GoodsFactory = sdr["Goods_factory"].ToString(); goodModel.GoodsSalesVolume = Convert.ToInt32(sdr["Goods_sales_volume"]); goodModel.GoodsStock = Convert.ToInt32(sdr["Goods_stock"]); goodModel.GoodsPicture = sdr["Goods_picture"].ToString(); goodModel.GoodsGoodsType = Convert.ToInt32(sdr["Goods_GoodsType"]); } sdr.Close(); return(goodModel); } else { return(null); } } else { return(null); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; if (context.Session["id"] != null) { int id = context.Request.QueryString["goods_id"] == null ? 0 : Int32.Parse(context.Request.QueryString["goods_id"]); string temp = File.ReadAllText(context.Server.MapPath("admin_product_save.html")); GoodModel good = GoodsBLL.GetAGoodDetail(id); temp = temp.Replace("@Goods_name", good.GoodsName); temp = temp.Replace("@Goods_effect", good.GoodsEffect); temp = temp.Replace("@Goods_price", good.GoodsPrice.ToString()); temp = temp.Replace("@Goods_norms", good.GoodsNorms.ToString()); temp = temp.Replace("@Goods_factory", good.GoodsFactory.ToString()); temp = temp.Replace("@Goods_stock", good.GoodsStock.ToString()); temp = temp.Replace("@Goods_id", id.ToString()); List <GoodsTypeModel> goodsType = GoodsTypeBLL.GetGoodsTypeList(); StringBuilder sb = new StringBuilder(); string selectedHtml = ""; foreach (GoodsTypeModel item in goodsType) { if (good.GoodsGoodsType == item.GoodsTypeid) { selectedHtml = "selected = 'true'"; } sb.AppendFormat(@"<option value='{0}' {2}>{1}</option>", item.GoodsTypeid, item.GoodsTypename, selectedHtml); selectedHtml = ""; } temp = temp.Replace("@admin", context.Session["admin_name"].ToString()); temp = temp.Replace("@product_type", sb.ToString()); context.Response.Write(temp); } else { context.Response.Redirect("~/admin_login.html"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; if (context.Session["id"] != null) { string id = context.Request.QueryString["Goods_id"]; string name = context.Request.Form["name"]; string effect = context.Request.Form["effect"]; string price = context.Request.Form["price"]; string factory = context.Request.Form["factory"]; string stock = context.Request.Form["stock"]; string norms = context.Request.Form["norms"]; string type = context.Request.Form["type"]; HttpPostedFile imgFile = context.Request.Files[0]; //Image img = new Bitmap(imgFile.InputStream); string newFileName = DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + System.IO.Path.GetExtension(imgFile.FileName).ToLower(); imgFile.SaveAs(context.Server.MapPath("~/Images/product_img/" + newFileName)); GoodModel good = new GoodModel(name, effect, Convert.ToDouble(price), norms, factory, Convert.ToInt32(stock), DateTime.Now, newFileName, Convert.ToInt32(type)); good.GoodsId = Convert.ToInt32(id); int i = GoodsBLL.UpdateGood(good); if (i > 0) { context.Response.Write("修改成功!"); } else { context.Response.Write("修改失败!"); } context.Response.Write("<a href='ProcessAdminProduct.ashx'>回到商品首页</a>"); //context.Response.Write(name + "/" + effect + "/" + price + "/" + factory + "/" + stock + "/"+newFileName); } else { context.Response.Redirect("~/admin_login.html"); } }
public void ParseReceiptItem() { // Data string name = "Мега сет"; decimal nds0 = 1; decimal nds10 = 2; decimal nds18 = 3; decimal ndsCalculated10 = 4; decimal ndsCalculated18 = 5; decimal ndsNo = 6; decimal price = 7; decimal quantity = 8.0m; decimal sum = 9; string jsonItem = $"{{\"modifiers\": null,\"name\": \"{name}\",\"nds0\": {nds0}," + $"\"nds10\": {nds10},\"nds18\": {nds18}," + $"\"ndsCalculated10\": {ndsCalculated10}," + $"\"ndsCalculated18\": {ndsCalculated18}," + $"\"ndsNo\": {ndsNo},\"price\": {price}," + $"\"quantity\": 8.0,\"sum\": {sum},\"storno\": false}}"; // Act GoodModel mode = JsonSerializer.DeserializeFromString <GoodModel>(jsonItem); // Assert Assert.AreEqual(null, mode.Modifiers); Assert.AreEqual(name, mode.Name); Assert.AreEqual(nds0, mode.Nds0); Assert.AreEqual(nds10, mode.Nds10); Assert.AreEqual(nds18, mode.Nds18); Assert.AreEqual(ndsCalculated10, mode.NdsCalculated10); Assert.AreEqual(ndsCalculated18, mode.NdsCalculated18); Assert.AreEqual(ndsNo, mode.NdsNo); Assert.AreEqual(price, mode.Price); Assert.AreEqual(quantity, mode.Quantity); Assert.AreEqual(sum, mode.Sum); }
/// <summary> /// 获得分页后该页显示的商品列表 /// </summary> /// <param name="pageIndex">当前页</param> /// <param name="pageSize">分页大小</param> /// <returns>商品列</returns> public static List <GoodModel> GetGoodsList(int pageIndex, int pageSize) { int start = (pageIndex - 1) * pageSize + 1; //int end = pageIndex * pageSize; string sqlText = getPaginationSql(start, pageSize, "goods", "*", "Goods_is_delete = 0", "goods_id"); SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText); List <GoodModel> goodsList = new List <GoodModel>(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { GoodModel goodModel = new GoodModel(); goodModel.GoodsId = Convert.ToInt32(sdr["Goods_id"]); goodModel.GoodsName = sdr["Goods_name"].ToString(); goodModel.GoodsPrice = Convert.ToInt32(sdr["Goods_price"]); goodModel.GoodsSalesVolume = Convert.ToInt32(sdr["Goods_sales_volume"]); goodModel.GoodsPicture = sdr["Goods_picture"].ToString(); goodsList.Add(goodModel); } sdr.Close(); return(goodsList); } else { return(null); } } else { return(null); } }
/// <summary> /// 根据搜索值 get商品列表 /// </summary> /// <param name="goodsName"></param> /// <returns></returns> public static List <GoodModel> GetGoodsListBySearch(string goodsName) { string sqlText = "SELECT * FROM Goods WHERE Goods_name LIKE @Goods_name and Goods_is_delete = 0"; SqlParameter para = new SqlParameter("@Goods_name", "%" + goodsName + "%"); SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText, para); List <GoodModel> goodsList = new List <GoodModel>(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { GoodModel goodModel = new GoodModel(); goodModel.GoodsId = Convert.ToInt32(sdr["Goods_id"]); goodModel.GoodsName = sdr["Goods_name"].ToString(); goodModel.GoodsPrice = Convert.ToInt32(sdr["Goods_price"]); goodModel.GoodsSalesVolume = Convert.ToInt32(sdr["Goods_sales_volume"]); goodModel.GoodsStock = Convert.ToInt32(sdr["Goods_stock"]); goodModel.GoodsPicture = sdr["Goods_picture"].ToString(); goodsList.Add(goodModel); } sdr.Close(); return(goodsList); } else { return(null); } } else { return(null); } }
public async Task <int> AddGood([FromBody] GoodModel goodModel) { return(await _goodsCreator.AddGood(goodModel, User.Identity.Name)); }
public bool AddGoodToDb(GoodPresenter goodToAdd) { using (var DbContext = new InvoicingMachineDbContext()) { var newGood = new GoodModel(); bool goodIsCorrect = false; if (!string.IsNullOrWhiteSpace(goodToAdd.GoodKey) && goodToAdd.GoodKey.Length <= 20) { newGood.GoodKey = goodToAdd.GoodKey; goodIsCorrect = true; } else { return(false); } if (!string.IsNullOrWhiteSpace(goodToAdd.Name)) { newGood.Name = goodToAdd.Name; goodIsCorrect = true; } else { return(false); } if (!string.IsNullOrWhiteSpace(goodToAdd.Unit)) { newGood.Unit = goodToAdd.Unit; goodIsCorrect = true; } else { return(false); } if (float.IsNaN(goodToAdd.VAT)) { newGood.VAT = goodToAdd.VAT; goodIsCorrect = true; } else { return(false); } if (!float.IsNaN(goodToAdd.NetPrice)) { newGood.NetPrice = goodToAdd.NetPrice; goodIsCorrect = true; } else { return(false); } if (!float.IsNaN(goodToAdd.GrossPrice)) { newGood.GrossPrice = goodToAdd.GrossPrice; goodIsCorrect = true; } else { return(false); } if (goodIsCorrect) { DbContext.Goods.Add(newGood); DbContext.SaveChanges(); } return(goodIsCorrect); } }
public void ValidateModel(GoodModel goodModel) { throw new NotImplementedException(); }
public void Delete(GoodModel goodModel) { throw new NotImplementedException(); }