private void AddDeskButton_Click(object sender, EventArgs e) { // Input try { CustomerName = customerNameTextBox.Text; DeskWidth = int.Parse(WidthTextBox.Text); DeskDepth = int.Parse(DepthTextBox.Text); Drawers = int.Parse(NumDrawersComboBox.SelectedItem.ToString()); Material = DesktopMaterialComboBox.SelectedItem.ToString(); // Get rush order selection if (RushThreeRadio.Checked) { RushOrderDays = 3; } if (RushFiveRadio.Checked) { RushOrderDays = 5; } if (RushSevenRadio.Checked) { RushOrderDays = 7; } // Create new DeskQuote object and calculate total DeskQuote NewOrder = new DeskQuote(DeskWidth, DeskDepth, Drawers, Material, RushOrderDays); DeskQuoteTotal = NewOrder.CalculateQuoteTotal(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Check input methods"); throw; } #region Display To Screen // Show confirmation page on new screen named DeskQuoteView var MainMenu = (MainMenu)Tag; // need to bring along a reference tag to the main menu form DeskQuoteView newOrderView = new DeskQuoteView(CustomerName, DateTime.Now.Date, DeskWidth, DeskDepth, Drawers, Material, RushOrderDays, DeskQuoteTotal) { Tag = MainMenu }; newOrderView.Show(); this.Close(); #endregion }
private void button1_Click(object sender, EventArgs e) { try { name = customerName.Text; deskWidth = int.Parse(width.Text); deskDepth = int.Parse(depth.Text); totalDrawers = int.Parse(drawers.Text); Materials = (Desk.Material)Material.SelectedValue; // Get rush order days base on radio box selections if (radioNone.Checked) { rushDays = 0; } if (radio3.Checked) { rushDays = 3; } if (radio5.Checked) { rushDays = 5; } if (radio7.Checked) { rushDays = 7; } // create new deskOrder and calcQuote DeskQuote NewQuote = new DeskQuote(name, DateTime.Now, deskWidth, deskDepth, totalDrawers, Materials, rushDays); QuoteTotal = NewQuote.CalcQuote(); //build string to quote save to file string DeskFileWrite = customerName + "," + DateTime.Now + "," + width + "," + depth + "," + drawers + "," + Material + "," + rushDays + "," + QuoteTotal; if (!File.Exists(QUOTEFILE)) { using (StreamWriter writer = File.CreateText(QUOTEFILE)) { writer.WriteLine(DeskFileWrite); } } else { using (StreamWriter writer = File.AppendText(QUOTEFILE)) { writer.WriteLine(DeskFileWrite); } MessageBox.Show("Quote Submitted"); } } catch (Exception) { MessageBox.Show("Saving Quote Failed"); } }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } //Calculation funciton callout to generate price and completion date DeskQuote = Calculate.PopulateQuote(DeskQuote, shipID, matieralID, _context); _context.DeskQuote.Add(DeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
//public DeskQuote Quote { get; } public DisplayQuote(DeskQuote quote) { InitializeComponent(); //Quote = quote; fullNameOutput.Text = quote.CustomerName; widthOutput.Text = $"{quote.Desk.Width}in"; depthOutput.Text = $"{quote.Desk.Depth}in"; numberOfDrawersOutput.Text = quote.Desk.NumberOfDrawers.ToString(); surfaceMaterialOutput.Text = quote.Desk.SurfaceMaterial.ToString(); rushOrderOutput.Text = (Attribute.GetCustomAttribute(quote.ProductionType.GetType().GetField(quote.ProductionType.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute)?.Description ?? quote.ProductionType.ToString(); dateOutput.Text = quote.Date.ToShortDateString(); quotePriceOutput.Text = $"${quote.QuotePrice}"; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote.FirstOrDefaultAsync(m => m.ID == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk).Include(d => d.DeliveryType).Include(d => d.Desk.DesktopMaterial).FirstOrDefaultAsync(m => m.DeskQuoteId == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public DisplayQuote(DeskQuote NewDeskQuote) { //getting all the data entered in to get a newQuote InitializeComponent(); _deskQuote = NewDeskQuote; widthupanddown.Value = NewDeskQuote.Desk.Width; depthupdown.Value = NewDeskQuote.Desk.Depth; Surface_Matrial.SelectedValue = NewDeskQuote.Desk.SurfaceMaterial; Num_Drawers.SelectedValue = NewDeskQuote.Desk.NumberOfDrawers; Delivery_Time.SelectedValue = NewDeskQuote.DeliveryType; CustomerName.Text = NewDeskQuote.CustomerName; TotalPrice.Text = NewDeskQuote.PriceAmount.ToString(); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuotes.Include(dq => dq.Desk) .Include(dq => dq.Desk.SurfaceMaterial).FirstOrDefaultAsync(m => m.DeskQuoteId == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Desk).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { // if (!DeskQuoteExists(DeskQuote.DeskQuoteId)) // { // return NotFound(); // } // else // { // throw; // } } _context.Attach(DeskQuote).State = EntityState.Modified; DeskQuote.QuotePrice = DeskQuote.getQuotePrice(_context); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DeskQuoteExists(DeskQuote.DeskQuoteId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
private void Get_NewQuote_Click(object sender, EventArgs e) { //This if statement is to check if the add quote form is complete. if (CustomerName.Text == "" || Delivery_Time.Text == "") { MessageBox.Show("Please fill all the values", "Form Imcomplete", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // gets the information of the desk Desk NameOfNewDesk = new Desk(); NameOfNewDesk.Width = widthupanddown.Value; NameOfNewDesk.Depth = depthupdown.Value; NameOfNewDesk.NumberOfDrawers = (int)Num_Drawers.Value; NameOfNewDesk.SurfaceMaterial = (Desk.Surface)Surface_Matrial.SelectedValue; //gets the information entered by the user. DeskQuote NewDeskQuote = new DeskQuote(); NewDeskQuote.CustomerName = CustomerName.Text; NewDeskQuote.DeliveryType = (DeskQuote.Delivery)Delivery_Time.SelectedValue; // get the quote amount and add amount to quote NewDeskQuote.Desk = NameOfNewDesk; DateTime today = DateTime.Today; NewDeskQuote.QuoteDate = today; NewDeskQuote.PriceAmount = NewDeskQuote.GetQuote(); try { // add quote to file AddQuoteToFile(NewDeskQuote); //show displayquote form DisplayQuote NewDeskForm = new DisplayQuote(NewDeskQuote); NewDeskForm.Show(); Hide(); } catch (Exception err) { MessageBox.Show("There was an error creating the quote. {0}", err.Message); } }
public async Task <IActionResult> OnGetAsync(int?id) { Materials = new SelectList(Enum.GetNames(typeof(CreateModel.surface))); if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote.FirstOrDefaultAsync(m => m.ID == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk) .Include(d => d.Rush).SingleOrDefaultAsync(m => m.ID == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote.FindAsync(id); if (DeskQuote != null) { _context.DeskQuote.Remove(DeskQuote); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
//gets the new quote and adds it to the new file public void AddQuoteToFile(DeskQuote NewDeskQuote) { string quotesFile = @"quotes.txt"; using (StreamWriter streamWriter = File.AppendText(quotesFile)) { // this will display it when we open the displayquote and leave it as long as the program is open. streamWriter.WriteLine( $"{NewDeskQuote.QuoteDate}," + $"{NewDeskQuote.CustomerName}," + $"{NewDeskQuote.Desk.Width}," + $"{NewDeskQuote.Desk.Depth}," + $"{NewDeskQuote.Desk.NumberOfDrawers}," + $"{NewDeskQuote.Desk.SurfaceMaterial}," + $"{NewDeskQuote.DeliveryType}," + $"{NewDeskQuote.PriceAmount}"); } }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } DeskQuote.setQuoteDate(); _context.DeskQuote.Add(DeskQuote); // Run functions to calculate other required fields DeskQuote.calcSurfaceArea(); DeskQuote.calcRushPricing(); DeskQuote.getMaterialPrice(); DeskQuote.calcTotalCost(); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk).FirstOrDefaultAsync(m => m.DeskQuoteId == id); if (DeskQuote == null) { return(NotFound()); } ViewData["DeliveryTypeId"] = new SelectList(_context.Set <Delivery>(), "DeliveryId", "DeliveryName"); ViewData["DesktopMaterialId"] = new SelectList(_context.Set <DesktopMaterial>(), "DesktopMaterialId", "DesktopMaterialName"); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .AsNoTracking() .Include(d => d.Desk) .FirstOrDefaultAsync(m => m.Id == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } List <SurfaceMaterial> rawSurfaceMaterials = await _context.SurfaceMaterials.ToListAsync(); DeskQuote.Desk.SurfaceMaterial = rawSurfaceMaterials.FirstOr(m => m.Name == SelectedMaterial, rawSurfaceMaterials[0]); DeskQuote.QuotePrice = DeskQuote.GetQuote(await _context.RushOrderTypes.ToListAsync()); DeskQuote.Date = DateTime.Now; _context.Desks.Add(DeskQuote.Desk); _context.DeskQuotes.Add(DeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk) .Include(d => d.RushShipping).FirstOrDefaultAsync(m => m.DeskQuoteID == id); if (DeskQuote == null) { return(NotFound()); } ViewData["DeskID"] = new SelectList(_context.Set <Desk>(), "DeskID", "DeskID"); ViewData["RushShippingID"] = new SelectList(_context.Set <RushShipping>(), "RushShippingID", "RushShippingID"); return(Page()); }
private void btnGetQuote_Click(object sender, EventArgs e) { //create a new desk var desk = new Desk(); //assign desk properties desk.width = nudWidth.Value; var deskQuote = new DeskQuote(); //set desk quote properties deskQuote.CustomerName = txtbxCustomerName.Text; //... //set quote price deskQuote.QuotePrice = deskQuote.GetQuotePrice(); // }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk) .Include(d => d.Rush).SingleOrDefaultAsync(m => m.ID == id); if (DeskQuote == null) { return(NotFound()); } ViewData["DeskID"] = new SelectList(_context.Desk, "ID", "ID"); ViewData["RushID"] = new SelectList(_context.Rush, "ID", "ID"); return(Page()); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Desk.Add(Desk); await _context.SaveChangesAsync(); DeskQuote.Desk = Desk.ID; DeskQuote.Date = DateTime.Now; DeskQuote.QuotePrice = DeskQuote.GetQuotePrice(_context); _context.DeskQuote.Add(DeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.desk) .Include(d => d.desk.material) .Include(d => d.RushShipping) .FirstOrDefaultAsync(m => m.ID == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuotes.Include(dq => dq.Desk) .Include(dq => dq.Desk.SurfaceMaterial).FirstOrDefaultAsync(m => m.DeskQuoteId == id); if (DeskQuote != null) { _context.DeskQuotes.Remove(DeskQuote); _context.Desks.Remove(DeskQuote.Desk); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void SubmitQuote_Click(object sender, EventArgs e) { DeskQuote newQuote = new DeskQuote(); newQuote.SetCustomerName($"{firstName.Text} {lastName.Text}"); try { newQuote.SetWidth(Int32.Parse(width.Text)); } catch { width.BackColor = Color.Red; return; } try { newQuote.SetDepth(Int32.Parse(depth.Text)); } catch { depth.BackColor = Color.Red; return; } newQuote.SetNumDrawers((int)numDrawers.Value); newQuote.SetSurfaceMaterial(surfaceMaterial.Text); newQuote.SetSurfacePrice(); if (rushOrder.Text == "Standard - 14 Day") { newQuote.SetRushOrder(false); newQuote.SetRushOrderTime(14); } else { newQuote.SetRushOrder(true); newQuote.SetRushOrderTime(Int32.Parse(rushOrder.Text[0].ToString())); } newQuote.CalcTotalPrice(); DisplayQuote.GetSubmittedQuote(newQuote); Form displayQuoteForm = new DisplayQuote(); displayQuoteForm.ShowDialog(); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Desk.Add(Desk); // DO LOGIC DeskQuote deskQuote = new DeskQuote(); _context.DeskQuote.Add(deskQuote); // FINISH LOGIC await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(d => d.Desk) .Include(d => d.RushOrderOption).FirstOrDefaultAsync(m => m.DeskQuoteId == id); if (DeskQuote == null) { return(NotFound()); } ViewData["RushOrderOptionId"] = new SelectList(_context.Set <RushOrderOption>(), "RushOrderOptionId", "Option"); ViewData["DesktopSurfaceMaterialId"] = new SelectList(_context.Set <DesktopSurfaceMaterial>(), "DesktopSurfaceMaterialId", "Name"); return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } //DeskQuote = await _context.DeskQuote.FirstOrDefaultAsync(m => m.Id == Id); //Pull in related tables DeskQuote = await _context.DeskQuote .Include(s => s.Desk) .AsNoTracking() .FirstOrDefaultAsync(m => m.Id == id); if (DeskQuote == null) { return(NotFound()); } return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Desk.DesktopMaterial = _context.DesktopMaterial.Where(m => m.DesktopMaterialId == Desk.DesktopMaterialId).FirstOrDefault(); _context.Desk.Add(Desk); await _context.SaveChangesAsync(); DeskQuote.DeskId = Desk.DeskId; DeskQuote.Desk = Desk; DeskQuote.QuoteDate = DateTime.Now; DeskQuote.QuotePrice = DeskQuote.GetDeskQuote(_context); _context.DeskQuote.Add(DeskQuote); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } DeskQuote = await _context.DeskQuote .Include(s => s.Desk) .AsNoTracking() .FirstOrDefaultAsync(m => m.Id == id); if (DeskQuote == null) { return(NotFound()); } UpdateMaterialName(_context, DeskQuote.Desk.SurfaceMaterialId); UpdateShippingName(_context, DeskQuote.RushId); return(Page()); }