private void button2_Click(object sender, EventArgs e) { DisplayQuote addNewViewQuoteForm = new DisplayQuote(); addNewViewQuoteForm.Tag = this; addNewViewQuoteForm.Show(this); Hide(); }
private void CreateQuote_Click(object sender, EventArgs e) { try { DeskQuote deskQuote = new DeskQuote(); Desk desk = new Desk(); List <DeskQuote> deskQuotes = Program.DeskQuotes; deskQuote.SurfaceMaterial = MaterialCombo.SelectedItem.ToString(); desk.Depth = float.Parse(DepthBox.Text); desk.Width = float.Parse(WidthBox.Text); deskQuote.Desk = desk; if (customerNameBox.Text == "") { MessageBox.Show("Please Enter the Customer's name"); return; } deskQuote.Name = customerNameBox.Text; if (threeDayRadio.Checked) { deskQuote.ShippingDays = 3; } else if (fiveDayRadio.Checked) { deskQuote.ShippingDays = 5; } else if (sevenDayRadio.Checked) { deskQuote.ShippingDays = 7; } else if (normalRadio.Checked) { deskQuote.ShippingDays = 14; } if ((int.Parse(drawerNumberBox.Text) > 0 && int.Parse(drawerNumberBox.Text) < 8)) { deskQuote.DrawerNumber = int.Parse(drawerNumberBox.Text); } else { MessageBox.Show("Please Enter a Drawer Number Between 1 & 7"); return; } if (desk.Width < 24 || desk.Width > 96 || desk.Depth < 12 || desk.Depth > 48) { MessageBox.Show("Please enter a width between 24 and 96 inches and a depth between 12 and 48 inches."); } else { deskQuote.calcualateSurfaceArea(); deskQuote.calculateQuote(); String width; String depth; String material; String shippingDay; String finalCost; String name; String date; StringBuilder sb = new StringBuilder(); name = deskQuote.Name; shippingDay = deskQuote.ShippingDays.ToString(); width = desk.Width.ToString(); depth = desk.Depth.ToString(); material = deskQuote.SurfaceMaterial; finalCost = "$" + deskQuote.FinalDeskCost.ToString(); date = deskQuote.Date; sb.AppendLine(name + " ," + width + " ," + depth + " ," + material + " ," + shippingDay + ", " + finalCost + "," + date); String filePath = "quotes.txt"; File.AppendAllText(filePath, sb.ToString()); deskQuotes.Add(deskQuote); Program.DeskQuotes = deskQuotes; DisplayQuote addNewViewQuoteForm = new DisplayQuote(); addNewViewQuoteForm.Tag = this; addNewViewQuoteForm.Show(this); Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void CreateQuote_Click(object sender, EventArgs e) { try { DeskQuote deskQuote = new DeskQuote(); Desk desk = new Desk(); List <DeskQuote> deskQuotes = Program.DeskQuotes; desk.SurfaceMaterial = MaterialCombo.SelectedItem.ToString(); desk.Width = float.Parse(WidthBox.Text); if (threeDayRadio.Checked) { desk.ShippingDays = 3; } else if (fiveDayRadio.Checked) { desk.ShippingDays = 5; } else if (sevenDayRadio.Checked) { desk.ShippingDays = 7; } else if (normalRadio.Checked) { desk.ShippingDays = 14; } if ((int.Parse(drawerNumberBox.Text) > 0 && int.Parse(drawerNumberBox.Text) < 8)) { desk.DrawerNumber = int.Parse(drawerNumberBox.Text); } else { MessageBox.Show("Please Enter a Drawer Number Between 1 & 7"); return; } desk.Depth = float.Parse(DepthBox.Text); desk.calcualateSurfaceArea(); Console.WriteLine("Width: " + desk.Width + "\n" + "Depth: " + desk.Depth + "\n" + "Surface Type : " + desk.SurfaceMaterial + "\n" + "Surface Area: " + desk.SurfaceArea + "\n" + "Shipping Days " + desk.ShippingDays + "\n" + "# of Drawers " + desk.DrawerNumber ); deskQuote.Desk = desk; deskQuotes.Add(deskQuote); Program.DeskQuotes = deskQuotes; DisplayQuote addNewViewQuoteForm = new DisplayQuote(); addNewViewQuoteForm.Tag = this; addNewViewQuoteForm.Show(this); Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }