public DisplayQuote(Form mainMenu, DeskQuote deskquote)
        {
            InitializeComponent();

            _mainMenu = mainMenu;

            TxtCustomerName.Text    = deskquote.CustomerName;
            NumWidth.Value          = deskquote.Desk.Width;
            NumDepth.Value          = deskquote.Desk.Depth;
            NumDrawers.Value        = deskquote.Desk.Drawers;
            TxtSurfaceMaterial.Text = deskquote.Desk.DesktopMaterial.ToString();
            TxtDelivery.Text        = deskquote.Shipping.ToString();
            TxtTotal.Text           = deskquote.Total.ToString("c");
        }
Exemple #2
0
        public void BtnGetQuote_Click(object sender, EventArgs e)
        {
            String DeliveryTest = CmbDelivery.Text;
            String NameTest     = TxtCustomerName.Text;

            if (DeliveryTest == "")
            {
                MessageBox.Show("Please select a shipping option");
            }

            else if (NameTest == "")
            {
                MessageBox.Show("Please enter something in the Customer Name field");
            }

            else
            {
                var desk = new Desk
                {
                    Depth           = NumDepth.Value,
                    Width           = NumWidth.Value,
                    Drawers         = (int)NumDrawers.Value,
                    DesktopMaterial = (DesktopMaterial)CmbSurfaceMaterial.SelectedValue
                };

                DeskQuote deskQuote = new DeskQuote
                {
                    Desk         = desk,
                    CustomerName = TxtCustomerName.Text,
                    QuoteDate    = DateTime.Now,
                    Shipping     = (Delivery)CmbDelivery.SelectedValue
                };

                deskQuote.Total = deskQuote.GetQuote();


                AddQuoteToFile(deskQuote);

                //Serialize deskQuote into a string

                //Write deskQuote to JSON file

                var displayQuote = new DisplayQuote(_mainMenu, deskQuote);


                displayQuote.Show();


                this.Close();
            }


            try
            {
                String nameTest = TxtCustomerName.ToString();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.Message);
            }
        }