Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        private void SubmitQuote_Click(object sender, EventArgs e)
        {
            DeskQuote newQuote = new DeskQuote();

            newQuote.Name = $"{firstName.Text}  {lastName.Text}";
            var date = DateTime.Now;

            newQuote.QuoteDate = date.Date;

            // Disallows submission if width is NaN
            try
            {
                newQuote.Width = Int32.Parse(width.Text);
            }
            catch
            {
                width.BackColor = Color.Red;
                return;
            }
            // Disallows submission if depth is NaN
            try
            {
                newQuote.Depth = Int32.Parse(depth.Text);
            }
            catch
            {
                depth.BackColor = Color.Red;
                return;
            }

            newQuote.SurfaceArea     = newQuote.CalcSurfaceArea();
            newQuote.NumDrawers      = (int)numDrawers.Value;
            newQuote.SurfaceMaterial = surfaceMaterial.Text;
            if (Enum.TryParse(newQuote.SurfaceMaterial, out SurfaceMaterials material))
            {
                newQuote.SurfacePrice = (int)material;
            }
            if (rushOrder.Text == "Standard - 14 Day")
            {
                newQuote.RushOrder      = false;
                newQuote.RushOrderTime  = 14;
                newQuote.RushOrderPrice = newQuote.CalcRushOrderPrice();
            }
            else
            {
                newQuote.RushOrder      = true;
                newQuote.RushOrderTime  = Int32.Parse(rushOrder.Text.Split(' ')[0]);
                newQuote.RushOrderPrice = newQuote.CalcRushOrderPrice();
            }
            newQuote.TotalPrice = newQuote.CalcTotalPrice();

            // Writes Quote to JSON file
            StreamWriter sw = new StreamWriter("../../Data/quotes.json", true);
            var          serializedQuote = JsonConvert.SerializeObject(newQuote);

            sw.WriteLine(serializedQuote);
            sw.Close();

            // Opens up submitted quote in DisplayQuote form
            DisplayQuote.GetSubmittedQuote(newQuote);
            Form displayQuoteForm = new DisplayQuote();

            displayQuoteForm.ShowDialog();
        }