Exemple #1
0
        private void SearchQuotes_Load(object sender, EventArgs e)
        {
            AddQuote Test = new AddQuote();

            Test.comboBox1.Text = "";

            /*DataTable TableQuotes = new DataTable();
             * TableQuotes.Columns.Add("Name", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Width", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Depth", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Material", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Drawers", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Order Time", Type.GetType("System.String"));
             * TableQuotes.Columns.Add("Price", Type.GetType("System.String"));
             *
             * DisplayQuote Search = new DisplayQuote();
             * Search.gridViewList.DataSource = TableQuotes;
             *
             * switch (comboBox1.Text)
             * {
             *  case "Laminate":
             *      Search.titleSearch.Text = "LAMINATE";
             *
             *
             *      // Enter n rows
             *      for (int j = 0; j < contador + 1; j++)
             *      {
             *
             *          TableQuotes.Rows.Add(new Object[] {Program.Laminate[contador],
             *
             *       Program.Laminate[contador+1], Program.Laminate[contador+2], Program.Laminate[contador+3],
             *       Program.Laminate[contador+4], Program.Laminate[contador+5],
             *       Program.Laminate[contador+6]});
             *
             *
             *
             *      }
             *
             *
             *      break;
             *  case "Oak":
             *      Search.titleSearch.Text = "OAK";
             *      // Enter n rows
             *      for (int j = 0; j < contador + 1; j++)
             *      {
             *
             *          TableQuotes.Rows.Add(new Object[] {Program.Oak[contador],
             *
             *       Program.Oak[contador+1], Program.Oak[contador+2], Program.Oak[contador+3],
             *       Program.Oak[contador+4], Program.Oak[contador+5],
             *       Program.Oak[contador+6]});
             *
             *
             *
             *      }
             *
             *
             *      break;
             *  case "Rosewood":
             *      Search.titleSearch.Text = "ROSEWOOD";
             *      // Enter n rows
             *      for (int j = 0; j < contador + 1; j++)
             *      {
             *
             *          TableQuotes.Rows.Add(new Object[] {Program.Rosewood[contador],
             *
             *       Program.Rosewood[contador+1], Program.Rosewood[contador+2], Program.Rosewood[contador+3],
             *       Program.Rosewood[contador+4], Program.Rosewood[contador+5],
             *       Program.Rosewood[contador+6]});
             *
             *
             *
             *      }
             *      break;
             *  case "Venner":
             *      Search.titleSearch.Text = "VENNER";
             *      // Enter n rows
             *      for (int j = 0; j < contador + 1; j++)
             *      {
             *
             *          TableQuotes.Rows.Add(new Object[] {Program.Venner[contador],
             *
             *       Program.Venner[contador+1], Program.Venner[contador+2], Program.Venner[contador+3],
             *       Program.Venner[contador+4], Program.Venner[contador+5],
             *       Program.Venner[contador+6]});
             *
             *
             *
             *      }
             *      break;
             *  case "Pine":
             *      Search.titleSearch.Text = "PINE";
             *      // Enter n rows
             *      for (int j = 0; j < contador + 1; j++)
             *      {
             *
             *          TableQuotes.Rows.Add(new Object[] {Program.Pine[contador],
             *
             *       Program.Pine[contador+1], Program.Pine[contador+2], Program.Pine[contador+3],
             *       Program.Pine[contador+4], Program.Pine[contador+5],
             *       Program.Pine[contador+6]});
             *
             *
             *
             *      }
             *
             *      break;
             *  default:
             *      MessageBox.Show("Error");
             *      break;
             * }
             *
             */
        }
Exemple #2
0
        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);
        }