Пример #1
0
        private void addNewQoute_Button_Click(object sender, EventArgs e)
        {
            var desk = new Desk();

            desk.Width           = widthNumeric.Value;
            desk.Depth           = depthNumeric.Value;
            desk.Drawers         = (int)drawersNumeric.Value;
            desk.SurfaceMaterial = (Desk.Surface)surfaceMaterialComboBox.SelectedIndex;
            //desk.DeliveryChoice = (Desk.Delivery)deliveryComboBox.SelectedIndex;


            var deskQoute = new DeskQuote();

            deskQoute.CustomerName   = customerNameTextBox.Text;
            deskQoute.DeliveryChoice = (DeskQuote.Delivery)deliveryComboBox.SelectedIndex;
            deskQoute.TimeStamp      = DateTime.Now;
            deskQoute.Desk           = desk;
            var quote = deskQoute.GetQuoteTotal();

            deskQoute.QuoteTotal = quote;

            //AddQuoteToFile(deskQoute);

            try {
                String quoteFile = @"quoteFile.txt";
                using (StreamWriter writer = File.AppendText(quoteFile))
                    writer.WriteLine
                    (
                        deskQoute.TimeStamp + "," +
                        deskQoute.CustomerName + "," +
                        desk.Width + "," +
                        desk.Depth + "," +
                        desk.Drawers + "," +
                        desk.SurfaceMaterial + "," +
                        deskQoute.DeliveryChoice + "," +
                        quote
                    );
            }
            catch (Exception err)
            {
                MessageBox.Show("There was an error creating your quote. " +
                                "Please try again later. {0}", err.Message);
            }
            DisplayQuote displayForm = new DisplayQuote(deskQoute);

            displayForm.Tag = (MainMenu)Tag;
            displayForm.Show();
            this.Close();
        }