public ActionResult UpdateView(string shipment) { BestradeContext btContext = new BestradeContext(); Shipment shipments = btContext.Shipments.SingleOrDefault(s => s.shipment == shipment); return(View(shipments)); }
public ActionResult AddShipment(string shipment, string date, string company, string cost, string remark) { if (shipment.Length == 0 || date.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "运单号或者日期不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.Shipments.Add(new Shipment { shipment = shipment, date = Convert.ToDateTime(date), company = company, cost = Convert.ToDouble(cost), remark = remark }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "运单号已存在,请创建新的" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "日期格式不对" })); } return(RedirectToAction("ShipmentFromCompany", "Shipment", new { @company = company })); }
public ActionResult AddFBA(string sku, string condition, string mod_num, string remark) { if (sku.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "FBA不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.FBA.Add(new FBA { sku = sku, condition = condition, mod_num = mod_num, remark = remark }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "FBA已存在,请创建新的" })); } return(RedirectToAction("FbaFromMod", "FBA", new { mod_num = mod_num })); }
public ActionResult AddPurchase(string purchase, string date, string supplier) { if (purchase.Length == 0 || date.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "单号或者日期不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.Purchases.Add(new Purchase { purchase = purchase, date = Convert.ToDateTime(date), supplier = supplier }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "单号已存在,请创建新的" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "日期格式不对" })); } return(RedirectToAction("PurchaseFromSupplier", "Purchase", new { supplier = supplier })); }
public ActionResult AddPack(string purchase, string sku, string unit_cost, string qty, string remark) { if (sku.Length == 0 || unit_cost.Length == 0 || qty.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "SKU-单价-数量不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.Packs.Add(new Pack { purchase = purchase, sku = sku, unit_cost = Convert.ToDouble(unit_cost), qty = Convert.ToInt32(qty), remark = remark }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "SKU在本单中重复或者不存在" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "请确认单价-数量是否为正确格式" })); } return(RedirectToAction("PackFromPurchase", "Pack", new { purchase = purchase })); }
public ActionResult UpdateShipment(string shipment, string date, string company, string cost, string remark, bool complete) { if (date.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "日期不能为空" })); } try { using (var btContext = new BestradeContext()) { var result = btContext.Shipments.SingleOrDefault(s => s.shipment == shipment); result.date = Convert.ToDateTime(date); result.company = company; result.cost = Convert.ToDouble(cost); result.complete = complete; result.remark = remark; btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "物流公司不存在" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "请检查日期或数量是否为正确格式" })); } return(RedirectToAction("Index", "Shipment")); }
public ActionResult UpdatePurchase(string purchase, string date, string supplier, string return_view) { if (date.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "日期不能为空" })); } try { using (var btContext = new BestradeContext()) { var result = btContext.Purchases.SingleOrDefault(r => r.purchase == purchase); result.date = Convert.ToDateTime(date); result.supplier = supplier; btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "供货商不存在" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "日期格式不对" })); } if (return_view.Length == 0) { return(RedirectToAction("Index", "Purchase")); } return(RedirectToAction("PurchaseFromSupplier", "Purchase", new { supplier = supplier })); }
// // GET: /Purchase/ public ActionResult Index() { BestradeContext btContext = new BestradeContext(); List <Supplier> suppliers = btContext.Suppliers.ToList(); ViewData["suppliers"] = suppliers; return(View(Purchase.All())); }
public ActionResult PurchaseFromSupplier(string supplier) { BestradeContext btContext = new BestradeContext(); List <Purchase> purchases = btContext.Purchases.Where(p => p.supplier == supplier).ToList(); ViewData["supplier"] = btContext.Suppliers.SingleOrDefault(s => s.supplier == supplier).supplier; return(View(purchases)); }
// // GET: /PackShipment/ public ActionResult Index() { BestradeContext btContext = new BestradeContext(); List <Shipment> shipments = btContext.Shipments.Where(s => s.complete == false).ToList(); ViewData["shipments"] = shipments; return(View(PackShipmentView.view())); }
// // GET: /Shipment/ public ActionResult Index() { BestradeContext btContext = new BestradeContext(); List <Company> companies = btContext.Companies.ToList(); ViewData["companies"] = companies; return(View(Shipment.All())); }
public ActionResult ShipmentFromCompany(string company) { BestradeContext btContext = new BestradeContext(); List <Shipment> shipments = btContext.Shipments.Where(s => s.company == company).ToList(); ViewData["company"] = btContext.Companies.SingleOrDefault(c => c.company == company).company; return(View(shipments)); }
public ActionResult PackFromPurchase(string purchase) { BestradeContext btContext = new BestradeContext(); List <Pack> pack = btContext.Packs.Where(p => p.purchase == purchase).ToList(); ViewData["purchase"] = btContext.Purchases.Single(p => p.purchase == purchase).purchase; return(View(pack)); }
public ActionResult FbaFromMod(string mod_num) { BestradeContext btContext = new BestradeContext(); List <FBA> fba = btContext.FBA.Where(f => f.mod_num == mod_num).ToList(); ViewData["mod_num"] = btContext.Mods.Single(m => m.mod_num == mod_num).mod_num; return(View(fba)); }
public ActionResult DeletePurchase(string purchase, string return_url) { using (var btContext = new BestradeContext()) { var delete = btContext.Purchases.SingleOrDefault(p => p.purchase == purchase); btContext.Purchases.Remove(delete); btContext.SaveChanges(); } return(Redirect(return_url)); }
public ActionResult DeleteShipment(string shipment) { using (var btContext = new BestradeContext()) { var delete = btContext.Shipments.SingleOrDefault(p => p.shipment == shipment); btContext.Shipments.Remove(delete); btContext.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult DeleteFBA(string sku) { using (var btContext = new BestradeContext()) { var delete = btContext.FBA.SingleOrDefault(m => m.sku == sku); btContext.FBA.Remove(delete); btContext.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult CompleteShipment(string shipment) { using (var btContext = new BestradeContext()) { var result = btContext.Shipments.SingleOrDefault(s => s.shipment == shipment); result.complete = true; btContext.SaveChanges(); } return(RedirectToAction("Index", "PackShipment")); }
public ActionResult DeletePackShipment(string purchase, string sku, string shipment) { using (var btContext = new BestradeContext()) { var delete = btContext.PackShipment.SingleOrDefault(p => p.purchase == purchase && p.sku == sku && p.shipment == shipment); btContext.PackShipment.Remove(delete); btContext.SaveChanges(); } return(RedirectToAction("Overview", "PackShipment")); }
public ActionResult DeletePack(string purchase, string sku, string return_url) { using (var btContext = new BestradeContext()) { var delete = btContext.Packs.SingleOrDefault(p => p.purchase == purchase && p.sku == sku); btContext.Packs.Remove(delete); btContext.SaveChanges(); } return(Redirect(return_url)); //return RedirectToAction("Index", "Pack"); }
public ActionResult UpdateMod(string mod_num, string asin, string title, string remark) { using (var btContext = new BestradeContext()) { var result = btContext.Mods.SingleOrDefault(m => m.mod_num == mod_num); result.mod_num = mod_num; result.asin = asin; result.title = title; result.remark = remark; btContext.SaveChanges(); } return(RedirectToAction("Index", "FBA")); }
public ActionResult DeleteMod(string mod_num) { using (var btContext = new BestradeContext()) { var delete = btContext.Mods.SingleOrDefault(m => m.mod_num == mod_num); btContext.Mods.Remove(delete); try { btContext.SaveChanges(); } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "该型号下存在一个或多个SKU,请删除SKU后再删除此型号" })); } } return(RedirectToAction("Index", "FBA")); }
public ActionResult AddPackShipment(string purchase, string sku, string shipment, string qty) { int check_int; if (qty.Length == 0 || !int.TryParse(qty, out check_int) || Convert.ToInt32(qty) <= 0) { return(RedirectToAction("Error", "Shared", new { message = "数量格式不对或者为空或小于等于0" })); } if (purchase.Length == 0 || sku.Length == 0 || shipment.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "请选择Pack和Shipment" })); } try { using (var btContext = new BestradeContext()) { string sql_cmd = String.Format("SELECT p_qty, s_qty FROM PackShipmentView WHERE purchase = '{0}' AND sku = '{1}'", purchase, sku); PackShipmentView view = btContext.Database.SqlQuery <PackShipmentView>(sql_cmd).FirstOrDefault(); int qty_left = view.p_qty - view.s_qty - Convert.ToInt32(qty); if (qty_left < 0) { return(RedirectToAction("Error", "Shared", new { message = "该Pack剩余数量低于寄出数量,请确认数量是否正确" })); } btContext.PackShipment.Add(new PackShipment { purchase = purchase, sku = sku, shipment = shipment, qty = Convert.ToInt32(qty) }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "同样的Pack在同一个Shipment下面已经存在,请做调整" })); } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "数量格式不对" })); } return(RedirectToAction("Index", "PackShipment")); }
public ActionResult UpdateFBA(string sku) { try { using (var btContext = new BestradeContext()) { var result = btContext.FBA.SingleOrDefault(r => r.sku == sku); result.condition = Request.Form["condition"]; result.mod_num = Request.Form["mod_num"]; result.remark = Request.Form["remark"]; btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "型号不存在,请创建型号后添加FBA" })); } return(RedirectToAction("Index")); }
public ActionResult UpdatePackShipment(string purchase, string sku, string shipment, string qty) { int check_int; if (qty.Length == 0 || !int.TryParse(qty, out check_int) || Convert.ToInt32(qty) <= 0) { return(RedirectToAction("Error", "Shared", new { message = "数量格式不对或者为空或小于等于0" })); } try { using (var btContext = new BestradeContext()) { //Check if the number is right to update string sql_cmd = String.Format("SELECT p_qty, s_qty FROM PackShipmentView WHERE purchase = '{0}' AND sku = '{1}'", purchase, sku); PackShipmentView view = btContext.Database.SqlQuery <PackShipmentView>(sql_cmd).FirstOrDefault(); int qty_before_update = btContext.PackShipment.FirstOrDefault(q => q.purchase == purchase && q.sku == sku && q.shipment == shipment).qty; int qty_available = view.p_qty - view.s_qty + qty_before_update; if (qty_available < Convert.ToInt32(qty)) { return(RedirectToAction("Error", "Shared", new { message = "该Pack剩余数量低于寄出数量,请确认数量是否正确" })); } // var result = btContext.PackShipment.SingleOrDefault(p => p.purchase == purchase && p.sku == sku && p.shipment == shipment); result.purchase = purchase; result.sku = sku; result.shipment = shipment; result.qty = Convert.ToInt32(qty); btContext.SaveChanges(); } } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "数量为空或格式不对" })); } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "Pack或Shipment不存在" })); } return(RedirectToAction("Overview", "PackShipment")); }
public ActionResult AddMod(string num, string asin, string title, string remark) { try { using (var btContext = new BestradeContext()) { btContext.Mods.Add(new Mod { mod_num = num, asin = asin, title = title, remark = remark }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "该型号已存在,请创建新的" })); } return(RedirectToAction("Index", "Mod")); }
public ActionResult UpdatePack(string purchase, string sku, string unit_cost, string qty, string remark, string return_view) { try { using (var btContext = new BestradeContext()) { var result = btContext.Packs.SingleOrDefault(s => s.purchase == purchase && s.sku == sku); result.unit_cost = Convert.ToDouble(unit_cost); result.qty = Convert.ToInt32(qty); result.remark = remark; btContext.SaveChanges(); } } catch (FormatException e) { return(RedirectToAction("Error", "Shared", new { message = "请确认单价-数量是否为正确格式" })); } if (return_view.Length == 0) { return(RedirectToAction("Index", "Pack")); } return(RedirectToAction("PackFromPurchase", "Pack", new { purchase = purchase })); }
public ActionResult AddSupplier(string supplier) { if (supplier.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "供货商名字不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.Suppliers.Add(new Supplier { supplier = supplier }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "供货商已存在,请创建新的名字" })); } return(RedirectToAction("Index", "Purchase")); }
public ActionResult AddCompany(string company) { if (company.Length == 0) { return(RedirectToAction("Error", "Shared", new { message = "物流公司名字不能为空" })); } try { using (var btContext = new BestradeContext()) { btContext.Companies.Add(new Company { company = company }); btContext.SaveChanges(); } } catch (DbUpdateException e) { return(RedirectToAction("Error", "Shared", new { message = "物流公司已存在,请创建新的" })); } return(RedirectToAction("Index", "Shipment")); }