private void MoveToSuppliers() { var suppliers = new SuppliersView(); suppliers.Show(); CloseAction(); }
public void AddNewSupplier(SuppliersView model, string userId) { using (var supplier = new SuppliersRepository()) { var supp = new Suppliers { SupplierId = model.SupplierId, EmailAddress = model.EmailAddress, PhysicalAddress = model.PhysicalAddress, Status = "Waiting For Approval", SupplierCellNo = model.SupplierCellNo, SupplierLastName = model.SupplierLastName, SupplierName = model.SupplierName, SupplierTelNo = model.SupplierTelNo, UserId = userId, ShortCode = "" }; supplier.Insert(supp); //update supp.ShortCode = (Guid.NewGuid().ToString().Substring(0, 4) + "-" + supp.SupplierId + "-" + model.SupplierName.Substring(0, 1) + model.SupplierLastName.Substring(0, 1)).ToUpper(); supplier.Update(supp); } }
private async void suppliersToolStripMenuItem_Click(object sender, EventArgs e) { var view = new SuppliersView(manager, await manager.List <Supplier>("Suppliers")); view.Anchor = Constants.FullScreenStyles; this.mainPanel.Controls.Clear(); this.mainPanel.Controls.Add(view); }
private void Delete() { var supplier = SuppliersView.CurrentItem as Supplier; ConfirmationRequest.Raise( new Confirmation { Content = "删除供应商" + supplier.Name + "?", Title = "确认", }, r => { if (r.Confirmed) { using (var context = new MasterDataContext()) { var existingSupplier = context.Suppliers.Where(s => s.Id == supplier.Id) .Include(s => s.Contacts).FirstOrDefault(); if (existingSupplier == null) { NotificationRequest.Raise( new Notification { Content = "供应商" + supplier.Name + "不存在。\n可能已删除,请重新查询。", Title = "提示" } ); return; } context.Remove(existingSupplier); context.SaveChanges(); } NotificationRequest.Raise( new Notification { Content = "已删除。", Title = "提示" } ); Suppliers.Remove(supplier); SuppliersView.Refresh(); TotalRecords -= 1; TotalPages = (int)Math.Ceiling(1.0 * TotalRecords / PageSize); if (TotalPages == 0) { PageIndex = 0; } else if (PageIndex > TotalPages) { PageIndex = TotalPages; SuppliersView = CollectionViewSource.GetDefaultView(Suppliers.Skip((PageIndex - 1) * PageSize).Take(PageSize)); } } } ); }
public ActionResult A_DSupplier(SuppliersView model) { if (ModelState.IsValid) { _suppliers.Approve(model); return(RedirectToAction("GetAllSupplierManage")); } return(View()); }
public ActionResult AddSupplier(SuppliersView model) { if (ModelState.IsValid) { _suppliers.AddNewSupplier(model, User.Identity.GetUserId()); return(RedirectToAction("GetAllSupplier")); } return(View()); }
public IHttpActionResult Update([FromBody] SuppliersView supplierView) { var supplier = mapper.Map <SuppliersDTM>(supplierView); try { service.UpdateAsync(supplier); return(Ok()); } catch { return(NotFound()); } }
public HttpResponseMessage Add([FromBody] SuppliersView supplierView) { var supplier = mapper.Map <SuppliersDTM>(supplierView); HttpResponseMessage responseMessage; try { service.AddAsync(supplier); responseMessage = new HttpResponseMessage(HttpStatusCode.OK); } catch { responseMessage = new HttpResponseMessage(HttpStatusCode.BadRequest); responseMessage.Content = new StringContent("Name can`t be empty!"); } return(responseMessage); }
public SuppliersView GetSupplierById(int id) { using (var supplier = new SuppliersRepository()) { Suppliers supp = supplier.GetById(id); var suppView = new SuppliersView(); if (supp != null) { suppView.SupplierId = supp.SupplierId; suppView.EmailAddress = supp.EmailAddress; suppView.Status = supp.Status; suppView.PhysicalAddress = supp.PhysicalAddress; suppView.ShortCode = supp.ShortCode; suppView.SupplierCellNo = supp.SupplierCellNo; suppView.SupplierLastName = supp.SupplierLastName; suppView.SupplierName = supp.SupplierName; suppView.UserId = supp.UserId; suppView.SupplierTelNo = supp.SupplierTelNo; } return(suppView); } }
//owner approval public void Approve(SuppliersView model) { using (var supplier = new SuppliersRepository()) { var supp = supplier.GetById(model.SupplierId); if (supp != null) { supp.SupplierId = model.SupplierId; supp.Status = model.Status; supp.SupplierId = supp.SupplierId; supp.EmailAddress = supp.EmailAddress; supp.PhysicalAddress = supp.PhysicalAddress; supp.ShortCode = supp.ShortCode; supp.SupplierCellNo = supp.SupplierCellNo; supp.SupplierLastName = supp.SupplierLastName; supp.SupplierName = supp.SupplierName; supp.UserId = supp.UserId; supp.SupplierTelNo = model.SupplierTelNo; supplier.Update(supp); } } }
/// <summary> /// Updates a Supplier /// Level: Data /// </summary> /// <param name="mySupplier">The Supplier to Be Updated</param> public void UpdateSupplier(SuppliersView mySupplier) { try { Supplier myOriginalSupplier = RetrieveSupplierByID(mySupplier.Id); myOriginalSupplier.Supplier1 = mySupplier.Supplier; myOriginalSupplier.Email = mySupplier.Email; myOriginalSupplier.StreetAddress = mySupplier.StreetAddress; myOriginalSupplier.Postcode = mySupplier.Postcode; Town myTown = RetrieveTown(mySupplier.Town, mySupplier.Country); //If Town Exists if (myTown != null) { //Assigning Existent Town to Supplier myOriginalSupplier.Town = myTown; } else { //Instanciating New Town myTown = new Town(); myTown.Town1 = mySupplier.Town; myTown.Country = RetrieveCountry(mySupplier.Country); //Assigning New Town to Supplier myOriginalSupplier.Town = myTown; } Entities.SaveChanges(); } catch (Exception Exception) { throw Exception; } }
/// <summary> /// Updates a Supplier /// Level: Logic /// </summary> /// <param name="ID">The Supplier ID</param> /// <param name="Supplier">The Supplier Name</param> /// <param name="Email">The Email</param> /// <param name="Postcode">The Postcode</param> /// <param name="StreetAddress">The Street Address</param> /// <param name="Town">The Town</param> /// <param name="Country">The Country</param> public void UpdateSupplier(int ID, string Supplier, string Email, string Postcode, string StreetAddress, string Town, string Country) { try { SuppliersRepository myRepository = new SuppliersRepository(); SuppliersView mySupplier = new SuppliersView(); mySupplier.Id = ID; mySupplier.Supplier = Supplier; mySupplier.Email = Email; mySupplier.Postcode = Postcode; mySupplier.StreetAddress = StreetAddress; mySupplier.Town = Town; mySupplier.Country = Country; myRepository.UpdateSupplier(mySupplier); } catch (Exception Exception) { throw Exception; } }
public Module() { View = new SuppliersView(); }