private void ANQbtn_Click(object sender, EventArgs e) { AddQuote AQFORM = new AddQuote(); AQFORM.Show(); this.Hide(); }
private void AddBtn_Click(object sender, EventArgs e) { bool EmptyFields; if (textBox1.Text == "") { MessageBox.Show("Please insert the Name of the Customer", "MegaDesk App"); textBox1.Focus(); EmptyFields = false; } else if (widthInput.Text == "") { MessageBox.Show("Please insert the Width", "MegaDesk App"); widthInput.Focus(); EmptyFields = false; } else if (DepthInput.Text == "") { MessageBox.Show("Please insert the Depth", "MegaDesk App"); DepthInput.Focus(); EmptyFields = false; } else if (comboBox2.Text == "") { buttonAlert++; MessageBox.Show("Please select the Number of Drawers", "MegaDesk App"); comboBox2.Focus(); EmptyFields = false; } else if (comboBox1.Text == "") { buttonAlert++; MessageBox.Show("Please select the Surface Material", "MegaDesk App"); comboBox1.Focus(); EmptyFields = false; } else if (comboBox3.Text == "") { buttonAlert++; MessageBox.Show("Please select the Processing Time", "MegaDesk App"); comboBox3.Focus(); EmptyFields = false; } else { Program.flag++; Program.cont++; EmptyFields = true; } if (EmptyFields == true) { // Calculate widthNumber = Int32.Parse(widthInput.Text); depthNumber = Int32.Parse(DepthInput.Text); area = widthNumber * depthNumber; // $1 per in2 drawersNumber = Int32.Parse(comboBox2.Text); drawers = drawersNumber * 50; if (comboBox1.Text == "Laminate") { materials = 100; } else if (comboBox1.Text == "Oak") { materials = 200; } else if (comboBox1.Text == "Pine") { materials = 50; } else if (comboBox1.Text == "Rosewood") { materials = 300; } else if (comboBox1.Text == "Venner") { materials = 125; } if (comboBox3.Text == "3" && area < 1000) { orderRush = Program.RushOrderPrices[0, 0]; } else if (comboBox3.Text == "5" && area < 1000) { orderRush = Program.RushOrderPrices[1, 0]; } else if (comboBox3.Text == "7" && area < 1000) { orderRush = Program.RushOrderPrices[2, 0]; } if (comboBox3.Text == "3" && (area >= 1000 && area <= 2000)) { orderRush = Program.RushOrderPrices[0, 1]; } else if (comboBox3.Text == "5" && (area >= 1000 && area <= 2000)) { orderRush = Program.RushOrderPrices[1, 1]; } else if (comboBox3.Text == "7" && (area >= 1000 && area <= 2000)) { orderRush = Program.RushOrderPrices[2, 1]; } if (comboBox3.Text == "3" && area > 2000) { orderRush = Program.RushOrderPrices[0, 2]; } else if (comboBox3.Text == "5" && area > 2000) { orderRush = Program.RushOrderPrices[1, 2]; } else if (comboBox3.Text == "7" && area > 2000) { orderRush = Program.RushOrderPrices[2, 2]; } results = basePrice + area + drawers + materials + orderRush; switch (comboBox1.Text) { case "Laminate": Program.laminateFlag++; Program.AllQuotes.Add(dateLabel.Text); Program.Laminate.Add(dateLabel.Text); Program.Laminate.Add(textBox1.Text); Program.AllQuotes.Add(textBox1.Text); Program.Laminate.Add(widthInput.Text); Program.AllQuotes.Add(widthInput.Text); Program.Laminate.Add(DepthInput.Text); Program.AllQuotes.Add(DepthInput.Text); Program.Laminate.Add(comboBox2.Text); Program.Laminate.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox2.Text); Program.Laminate.Add(comboBox3.Text); Program.AllQuotes.Add(comboBox3.Text); Program.Laminate.Add(results.ToString()); Program.AllQuotes.Add(results.ToString()); break; case "Oak": Program.oakFlag++; Program.AllQuotes.Add(dateLabel.Text); Program.Oak.Add(dateLabel.Text); Program.Oak.Add(textBox1.Text); Program.AllQuotes.Add(textBox1.Text); Program.Oak.Add(widthInput.Text); Program.AllQuotes.Add(widthInput.Text); Program.Oak.Add(DepthInput.Text); Program.AllQuotes.Add(DepthInput.Text); Program.Oak.Add(comboBox2.Text); Program.Oak.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox2.Text); Program.Oak.Add(comboBox3.Text); Program.AllQuotes.Add(comboBox3.Text); Program.Oak.Add(results.ToString()); Program.AllQuotes.Add(results.ToString()); break; case "Rosewood": Program.AllQuotes.Add(dateLabel.Text); Program.Rosewood.Add(dateLabel.Text); Program.rosewoodFlag++; Program.Rosewood.Add(textBox1.Text); Program.AllQuotes.Add(textBox1.Text); Program.Rosewood.Add(widthInput.Text); Program.AllQuotes.Add(widthInput.Text); Program.Rosewood.Add(DepthInput.Text); Program.AllQuotes.Add(DepthInput.Text); Program.Rosewood.Add(comboBox2.Text); Program.Rosewood.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox2.Text); Program.Rosewood.Add(comboBox3.Text); Program.AllQuotes.Add(comboBox3.Text); Program.Rosewood.Add(results.ToString()); Program.AllQuotes.Add(results.ToString()); break; case "Venner": Program.vennerFlag++; Program.AllQuotes.Add(dateLabel.Text); Program.Venner.Add(dateLabel.Text); Program.Venner.Add(textBox1.Text); Program.AllQuotes.Add(textBox1.Text); Program.Venner.Add(widthInput.Text); Program.AllQuotes.Add(widthInput.Text); Program.Venner.Add(DepthInput.Text); Program.AllQuotes.Add(DepthInput.Text); Program.Venner.Add(comboBox2.Text); Program.Venner.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox2.Text); Program.Venner.Add(comboBox3.Text); Program.AllQuotes.Add(comboBox3.Text); Program.Venner.Add(results.ToString()); Program.AllQuotes.Add(results.ToString()); break; case "Pine": Program.pineFlag++; Program.AllQuotes.Add(dateLabel.Text); Program.Pine.Add(dateLabel.Text); Program.Pine.Add(textBox1.Text); Program.AllQuotes.Add(textBox1.Text); Program.Pine.Add(widthInput.Text); Program.AllQuotes.Add(widthInput.Text); Program.Pine.Add(DepthInput.Text); Program.AllQuotes.Add(DepthInput.Text); Program.Pine.Add(comboBox2.Text); Program.Pine.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox1.Text); Program.AllQuotes.Add(comboBox2.Text); Program.Pine.Add(comboBox3.Text); Program.AllQuotes.Add(comboBox3.Text); Program.Pine.Add(results.ToString()); Program.AllQuotes.Add(results.ToString()); break; default: MessageBox.Show("Error"); break; } AddQuote Adding = new AddQuote(); textBox1.Text = ""; widthInput.Text = ""; DepthInput.Text = ""; comboBox2.Text = ""; comboBox3.Text = ""; if (buttonAlert == 0) { AddBtn.Enabled = true; Adding.Show(); Adding.Hide(); } } JavaScriptSerializer ser = new JavaScriptSerializer(); // Serialize string outputJSON = ser.Serialize(Program.AllQuotes); File.WriteAllText("quotes.json", outputJSON); // File.AppendText("quotes.json", outputJSON); //Deserialize List <string> outputString = ser.Deserialize <List <string> >(outputJSON); }