private void btnDelete_Click(object sender, EventArgs e) { int id = this.GetIdInDvg(); if (id > 0) { if (MessageBox.Show("Esta operação é irreversível. Deseja continuar?", "Confirmação de exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { string message = ProductCtrl.Delete(id); UpdateDgvProducts(); } catch (AggregateException ex) { MessageBox.Show("Aplicação servidora não responde: " + ex.Message); } catch (Exception ex) { MessageBox.Show("Problema na solicitação: " + ex.Message); } } } else { MessageBox.Show("Nenhum item selecionado!"); } }
public JObject GetProductList(QueryProduct query, int page, int limit) { string acc = "AC003"; ProductCtrl productCtrl = new ProductCtrl(acc); var que = productCtrl.GetList().AsQueryable(); if (!string.IsNullOrWhiteSpace(query.ProID)) { que = que.Where(x => x.SID.Contains(query.ProID)); } if (!string.IsNullOrWhiteSpace(query.ProName)) { que = que.Where(x => x.ProName.Contains(query.ProName)); } if (!string.IsNullOrWhiteSpace(query.Models)) { que = que.Where(x => x.Model.Contains(query.Models)); } if (!string.IsNullOrWhiteSpace(query.Specs)) { que = que.Where(x => x.Specs.Contains(query.Specs)); } var list = que.Skip((page - 1) * limit).Take(limit).ToList(); JObject json = new JObject( new JProperty("code", 0), new JProperty("msg", ""), new JProperty("count", que.ToList().Count), new JProperty("data", new JArray( from r in list select new JObject( new JProperty("AssistCode", r.AssistCode), new JProperty("BarCode", r.BarCode), new JProperty("CreatDate", r.CreatDate), new JProperty("Creator", r.Creator), new JProperty("FactryName", r.FactryName), new JProperty("ID", r.ID), new JProperty("Model", r.Model), new JProperty("PinyinCode", r.PinyinCode), new JProperty("OnlyUnit", r.OnlyUnit), new JProperty("ClassName", r.ClassName), new JProperty("ClassID", r.ClassID), new JProperty("MainUnitName", r.MainUnitName), new JProperty("AssistUnitName", r.AssistUnitName), new JProperty("AssistRate", r.AssistRate), new JProperty("IsFloat", r.IsFloat), new JProperty("ProName", r.ProName), new JProperty("Remark", r.Remark), new JProperty("SID", r.SID), new JProperty("Specs", r.Specs), new JProperty("Status", r.Status))))); return(json); }
public static void LaunchShopMenu(string user) { bool start = true; int option = (int)Options.Default; do { ShowMenu(user); try { option = int.Parse(Console.ReadLine()); } catch (Exception) { Alert.ShowAlert("Invalid Option", ConsoleColor.Red); } switch (option) { case (int)Options.Add: Banner.ShowBanner("Add to Shopping Cart"); ProductCtrl.ReadAllProducts(); ShopCtrl.GetProduct(Product.GetId().Id, user); Alert.Confirmation(); break; case (int)Options.Remove: Banner.ShowBanner("Remove from Shopping Cart"); ShopCtrl.ShowShoppingCart(); ShopCtrl.RemoveProduct(Product.GetId().Id); Alert.Confirmation(); break; case (int)Options.Cart: Banner.ShowBanner(" Your Shopping Cart "); ShopCtrl.ShowShoppingCart(); Alert.Confirmation(); break; case (int)Options.Finish: Banner.ShowBanner(" Your Order is Finished "); UtilityMenu.LaunchFinishMenu(user); Alert.Confirmation(); break; case (int)Options.Exit: start = false; break; } } while (start); }
public ActionResult DelProduct(string SID) { string acc = "AC003"; ProductCtrl productCtrl = new ProductCtrl(acc, SID); //删除前先判断商品是否有使用 productCtrl.Delete(); var resulst = new { productCtrl.Code, productCtrl.Msg }; return(Json(resulst, "text/html", JsonRequestBehavior.AllowGet)); }
public void UpdateDgvProducts() { dgvProducts.AutoGenerateColumns = false; try { dgvProducts.DataSource = ProductCtrl.GetAll(); } catch (AggregateException ex) { MessageBox.Show("Aplicação servidora não responde: " + ex.Message); } catch (Exception ex) { MessageBox.Show("Problema na solicitação: " + ex.Message); } }
public ActionResult EditProduct(ProductViewModel model) { string acc = "AC003"; ProductCtrl productCtrl = new ProductCtrl(acc, model.SID); productCtrl.Product.AssistCode = model.AssistCode; productCtrl.Product.BarCode = model.BarCode; productCtrl.Product.FactryName = model.FactryName; productCtrl.Product.Model = model.Model; productCtrl.Product.ProName = model.ProName; productCtrl.Product.Remark = model.Remark; productCtrl.Product.Specs = model.Specs; productCtrl.Product.ClassID = model.ClassID; productCtrl.Product.PinyinCode = model.PinyinCode; productCtrl.Product.OnlyUnit = int.Parse(model.OnlyUnit); productCtrl.Product.Spare1 = model.Spare1; productCtrl.Product.Spare2 = model.Spare2; productCtrl.Product.Spare3 = model.Spare3; productCtrl.Product.Spare4 = model.Spare4; productCtrl.Product.Spare5 = model.Spare5; productCtrl.Product.DIY1 = model.DIY1; productCtrl.Product.DIY2 = model.DIY2; productCtrl.Product.DIY3 = model.DIY3; productCtrl.Product.DIY4 = model.DIY4; productCtrl.Product.DIY5 = model.DIY5; productCtrl.Product.Year = model.Year; productCtrl.Product.PurchaseUnit = model.PurchaseUnit; productCtrl.Product.PurchaseRate = CommonTools.ToDecimal(model.PurchaseRate); productCtrl.Product.SaleUnit = model.SaleUnit; productCtrl.Product.SaleRate = CommonTools.ToDecimal(model.SaleRate); productCtrl.Product.InventoryUnit = model.InventoryUnit; productCtrl.Product.InventoryRate = CommonTools.ToDecimal(model.InventoryRate); productCtrl.Edit(); var resulst = new { productCtrl.Code, productCtrl.Msg }; return(Json(resulst, "text/html", JsonRequestBehavior.AllowGet)); }
public ActionResult AddProduct(ProductViewModel model) { string acc = "AC003"; ProductCtrl productCtrl = new ProductCtrl(acc); Products pro = new Products(); pro.AssistCode = model.AssistCode; pro.BarCode = model.BarCode; pro.CreatDate = DateTime.Now.ToString("yyyy-MM-dd"); pro.Creator = "admin"; pro.FactryName = model.FactryName; pro.PinyinCode = model.PinyinCode; pro.Model = model.Model; pro.ClassID = model.ClassID; pro.ProName = model.ProName; pro.Remark = model.Remark; pro.SID = CommonTools.GetNewID("SP", acc); pro.Specs = model.Specs; pro.Status = 0; pro.Colour = model.Colour; pro.Place = model.Place; pro.Size = model.Size; if (!string.IsNullOrWhiteSpace(model.OnlyUnit)) { pro.OnlyUnit = int.Parse(model.OnlyUnit); } else { pro.OnlyUnit = 1; } pro.Spare1 = model.Spare1; pro.Spare2 = model.Spare2; pro.Spare3 = model.Spare3; pro.Spare4 = model.Spare4; pro.Spare5 = model.Spare5; pro.DIY1 = model.DIY1; pro.DIY2 = model.DIY2; pro.DIY3 = model.DIY3; pro.DIY4 = model.DIY4; pro.DIY5 = model.DIY5; pro.Year = model.Year; pro.MainUnit = model.MainUnit; pro.PurchaseUnit = model.PurchaseUnit; pro.PurchaseRate = CommonTools.ToDecimal(model.PurchaseRate); pro.SaleUnit = model.SaleUnit; pro.SaleRate = CommonTools.ToDecimal(model.SaleRate); pro.InventoryUnit = model.InventoryUnit; pro.InventoryRate = CommonTools.ToDecimal(model.InventoryRate); if (pro.OnlyUnit == 0) { pro.IsFloat = 0; pro.AssistRate = 0; pro.AssistUnit = ""; } else { pro.IsFloat = CommonTools.ToInt(model.IsFloat); pro.AssistUnit = model.AssistUnit; pro.AssistRate = CommonTools.ToDecimal(model.AssistRate); } productCtrl.Product = pro; productCtrl.Save(); var resulst = new { productCtrl.Code, productCtrl.Msg }; return(Json(resulst, "text/html", JsonRequestBehavior.AllowGet)); }
public static void LaunchProductMenu() { bool start = true; do { int option = (int)Options.Default; Banner.ShowBigBanner("Products"); try { option = int.Parse(Console.ReadLine()); } catch (Exception) { Alert.ShowAlert("Please type a valid Option", ConsoleColor.Red); Alert.Confirmation(); } switch (option) { case (int)Options.Create: try { Banner.ShowBanner("Create Product"); ProductCtrl.CreateProduct(Product.GetAllInfo()); Alert.Confirmation(); } catch (ApplicationException error) { Alert.ShowAlert(error.Message, ConsoleColor.Red); Alert.Confirmation(); App.InitializeApp(); } break; case (int)Options.Search: try { Banner.ShowBanner("Search Product"); ProductCtrl.ReadProduct(Product.GetId().Id); Alert.Confirmation(); } catch (ApplicationException error) { Alert.ShowAlert(error.Message, ConsoleColor.Red); Alert.Confirmation(); App.InitializeApp(); } break; case (int)Options.Catalog: try { Banner.ShowBanner("Product Database"); ProductCtrl.ReadAllProducts(); Alert.Confirmation(); break; } catch (ApplicationException error) { Alert.ShowAlert(error.Message, ConsoleColor.Red); Alert.Confirmation(); App.InitializeApp(); } break; case (int)Options.Update: try { Banner.ShowBanner("Update Product"); ProductCtrl.UpdateProduct(Product.GetAllInfo()); Alert.Confirmation(); } catch (ApplicationException error) { Alert.ShowAlert(error.Message, ConsoleColor.Red); Alert.Confirmation(); App.InitializeApp(); } break; case (int)Options.Delete: try { Banner.ShowBanner("Delete Product"); ProductCtrl.DeleteProduct(Product.GetId().Id); Alert.Confirmation(); } catch (ApplicationException error) { Alert.ShowAlert(error.Message, ConsoleColor.Red); Alert.Confirmation(); App.InitializeApp(); } break; case (int)Options.Exit: start = false; break; } } while (start); }