コード例 #1
0
        private void CalcQuote_Click(object sender, EventArgs e)
        {
            try
            {
                CustomerName    = textBoxCustomerName.Text;
                DeskWidth       = int.Parse(WidthTextBox.Text);
                DeskDepth       = int.Parse(DepthTextBox.Text);
                Drawers         = int.Parse(NumDrawersComboBox.SelectedItem.ToString());;
                DesktopMaterial = (DesktopMaterial)comboBoxSurfaceMaterial.SelectedValue;

                //rush order selection
                if (radioRush3.Checked)
                {
                    RushOrderDays = 3;
                }
                if (radioRush5.Checked)
                {
                    RushOrderDays = 3;
                }
                if (radioRush5.Checked)
                {
                    RushOrderDays = 3;
                }
                if (noRush.Checked)
                {
                    RushOrderDays = 0;
                }


                //Create New quote
                DeskQuote NewQuote = new DeskQuote(CustomerName, DateTime.Now, DeskWidth, DeskDepth, Drawers, DesktopMaterial, RushOrderDays);
                DeskQuoteTotal = NewQuote.CalculateQuoteTotal();

                //build CSV output
                var    DeskRecord = CustomerName + ", " + DateTime.Now + ", " + DeskWidth + ", " + DeskDepth + ", " + Drawers + ", " + DesktopMaterial + ", " + RushOrderDays + ", $" + DeskQuoteTotal;
                string cFile      = @"quotes.txt";
                if (!File.Exists(cFile))
                {
                    using (StreamWriter sw = File.CreateText("quotes.txt")) { }
                }
                using (StreamWriter swa = File.AppendText("quotes.txt")) { swa.WriteLine(DeskRecord); }

                ThankYouMessage.Text  = "Thank you for Submitting a quote!";
                DisplayDeskQuote.Text = "Your quote is: " + DeskRecord;
                cancelQuote.Text      = "Main Menu";
            }
            catch (Exception ex)
            {
                MessageBox.Text = ex.Message;
            }
        }