Esempio n. 1
0
        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();

                if (customerNameBox.Text == "")
                {
                    MessageBox.Show("Please Enter the Customer's name");
                    return;
                }

                deskQuote.Name = customerNameBox.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.Width = float.Parse(WidthBox.Text);

                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
                {
                    desk.calcualateSurfaceArea();
                    desk.calculateQuote();


                    String        width;
                    String        depth;
                    String        material;
                    String        shippingDay;
                    String        finalCost;
                    String        name;
                    String        date;
                    StringBuilder sb = new StringBuilder();



                    name        = deskQuote.Name;
                    shippingDay = desk.ShippingDays.ToString();
                    width       = desk.Width.ToString();
                    depth       = desk.Depth.ToString();
                    material    = desk.SurfaceMaterial;
                    finalCost   = "$" + desk.FinalDeskCost.ToString();
                    date        = deskQuote.Date;
                    sb.AppendLine(name + " ," + width + " ," + depth + " ," + material + " ," + shippingDay + ", " + finalCost + "," + date);
                    String filePath = "quotes.txt";
                    File.AppendAllText(filePath, sb.ToString());

                    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);
            }
        }
Esempio n. 2
0
        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);
            }
        }