Ejemplo n.º 1
0
        private void customerChartUpdate(cSBool c, Button b, string key)
        {
            string k;

            chart1.Series.Clear();
            chart1.Series.Add("Series1");

            //Just resets all look ups for car transactions to none-existent
            for (int i = 1; i < 21; i++)
            {
                k = "b" + i.ToString();
                if (buts[k].b && k != key)
                {
                    buts[k].button.BackColor = Color.Red;
                    cSBool bb = buts[k];
                    bb.b    = false;
                    buts[k] = bb;
                }
            }
            if (buts[key].b)
            {
                c.button.BackColor = Color.Red;
                c.b       = false;
                buts[key] = c;
            }
            else
            {
                c.button.BackColor = Color.Green;
                c.b       = true;
                buts[key] = c;
            }
        }
Ejemplo n.º 2
0
        private void carChartUpdate(cSBool c, Button b, string key)
        {
            string k;

            for (int i = 17; i < 21; i++)
            {
                k = "b" + i.ToString();
                if (buts[k].b)
                {
                    buts[k].button.BackColor = Color.Red;
                    cSBool cb = buts[k];
                    cb.b    = false;
                    buts[k] = cb;
                }
            }

            if (buts[key].b)
            {
                b.BackColor = Color.Red;
                c.b         = false;
                buts[key]   = c;
            }
            else
            {
                b.BackColor = Color.Green;
                c.b         = true;
                buts[key]   = c;
            }
            this.updateChartCars();
        }
Ejemplo n.º 3
0
        public ChartsForm()
        {
            InitializeComponent();

            // Define path and DataDirectory to access the database later
            string executable = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string path       = (System.IO.Path.GetDirectoryName(executable));

            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            label1.Text = "Start Date";
            label2.Text = "End Date";

            chart1.ChartAreas[0].AxisX.Minimum = 0;
            chart1.ChartAreas[0].AxisY.Minimum = 0;
            chart1.ChartAreas[0].AxisX.Maximum = 4;
            chart1.ChartAreas[0].AxisY.Maximum = 50;

            cSBool b1 = new cSBool(false, "colors", button1), b2 = new cSBool(false, "doors", button2), b3 = new cSBool(false, "style", button3),
                   b4 = new cSBool(false, "age", button4), b5 = new cSBool(false, "sun_roof", button5), b6 = new cSBool(false, "fuelType", button6),
                   b7 = new cSBool(false, "daily_price", button7), b8 = new cSBool(false, "weekly_price", button8), b9 = new cSBool(false, "monthly_price", button9),
                   b10 = new cSBool(false, "heatedSeat", button10), b11 = new cSBool(false, "stereoQual", button11), b12 = new cSBool(false, "manual", button12), b13 = new cSBool(false, "cylinders", button13),
                   b14 = new cSBool(false, "power_seats", button14), b15 = new cSBool(false, "bluetooth", button15), b16 = new cSBool(false, "model", button16),
                   b17 = new cSBool(false, "pickup_branch_id", button17), b18 = new cSBool(false, "customer_id", button18), b19 = new cSBool(false, "car_id", button19), b20 = new cSBool(false, "employee_id", button20);


            b1.button.BackColor  = Color.Red; b1.button.ForeColor = Color.White; b1.button.Text = "Colors"; b1.button.TabIndex = 1; buts.Add("b1", b1);
            b2.button.BackColor  = Color.Red; b2.button.ForeColor = Color.White; b2.button.Text = "Doors"; b2.button.TabIndex = 2; buts.Add("b2", b2);
            b3.button.BackColor  = Color.Red; b3.button.ForeColor = Color.White; b3.button.Text = "Style"; b3.button.TabIndex = 3; buts.Add("b3", b3);
            b4.button.BackColor  = Color.Red; b4.button.ForeColor = Color.White; b4.button.Text = "Age"; b4.button.TabIndex = 4; buts.Add("b4", b4);
            b5.button.BackColor  = Color.Red; b5.button.ForeColor = Color.White; b5.button.Text = "Sun Roof"; b5.button.TabIndex = 5; buts.Add("b5", b5);
            b6.button.BackColor  = Color.Red; b6.button.ForeColor = Color.White; b6.button.Text = "Fuel type"; b6.button.TabIndex = 6; buts.Add("b6", b6);
            b7.button.BackColor  = Color.Red; b7.button.ForeColor = Color.White; b7.button.Text = "Daily Prices"; b7.button.TabIndex = 7; buts.Add("b7", b7);
            b8.button.BackColor  = Color.Red; b8.button.ForeColor = Color.White; b8.button.Text = "Weekly Prices"; b8.button.TabIndex = 8; buts.Add("b8", b8);
            b9.button.BackColor  = Color.Red; b9.button.ForeColor = Color.White; b9.button.Text = "Monthly Prices"; b9.button.TabIndex = 9; buts.Add("b9", b9);
            b10.button.BackColor = Color.Red; b10.button.ForeColor = Color.White; b10.button.Text = "Heated Seats"; b10.button.TabIndex = 10; buts.Add("b10", b10);
            b11.button.BackColor = Color.Red; b11.button.ForeColor = Color.White; b11.button.Text = "Stereo Quality"; b11.button.TabIndex = 11; buts.Add("b11", b11);
            b12.button.BackColor = Color.Red; b12.button.ForeColor = Color.White; b12.button.Text = "Manual/Automatic"; b12.button.TabIndex = 12; buts.Add("b12", b12);
            b13.button.BackColor = Color.Red; b13.button.ForeColor = Color.White; b13.button.Text = "Cylinders in Engine"; b13.button.TabIndex = 13; buts.Add("b13", b13);
            b14.button.BackColor = Color.Red; b14.button.ForeColor = Color.White; b14.button.Text = "Power Seats"; b14.button.TabIndex = 14; buts.Add("b14", b14);
            b15.button.BackColor = Color.Red; b15.button.ForeColor = Color.White; b15.button.Text = "Blue Tooth"; b15.button.TabIndex = 15; buts.Add("b15", b15);
            b16.button.BackColor = Color.Red; b16.button.ForeColor = Color.White; b16.button.Text = "Models"; b16.button.TabIndex = 16; buts.Add("b16", b16);
            b17.button.BackColor = Color.Red; b17.button.ForeColor = Color.White; b17.button.Text = "Sales/Branch"; b17.button.TabIndex = 17; buts.Add("b17", b17);     //Here we do groupby branch_id, count (*) with a select for both
            b18.button.BackColor = Color.Red; b18.button.ForeColor = Color.White; b18.button.Text = "Customers/Branch"; b18.button.TabIndex = 18; buts.Add("b18", b18); //Here we do group by branch_id, customer_id and then another groupby branch_id, count(*) for the number of unique customers
            b19.button.BackColor = Color.Red; b19.button.ForeColor = Color.White; b19.button.Text = "Cars/Branch"; b19.button.TabIndex = 19; buts.Add("b19", b19);      //Here we do a simple if branch.branch_id = car.branch_id with select branch.name, count (*)
            b20.button.BackColor = Color.Red; b20.button.ForeColor = Color.White; b20.button.Text = "Employees/branch"; b20.button.TabIndex = 20; buts.Add("b20", b20); //Here we do branch.branch_id = employee.branch_id, SELECT branch.name, count(*)

            startDate = DateTime.Now; endDate = DateTime.Now;

            //This is to initialize the graph as reading everything.
            using (SqlConnection conn = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;" +
                                                          "AttachDbFilename=|DataDirectory|Database1.mdf;" +
                                                          "Integrated Security=True"))
            {
                conn.Open();
                SqlCommand comm   = new SqlCommand("SELECT count (*) from car_type", conn);
                int        carInv = Convert.ToInt32(comm.ExecuteScalar());
                comm = new SqlCommand("SELECT count (*) from rental", conn);
                int carRent = Convert.ToInt32(comm.ExecuteScalar());
                chart1.Titles.Add("Total Cars");
                chart1.Series["Series1"].Points.AddXY("Total Cars in Inventory", carInv.ToString()); //This is how you add both X and Y values simultaneously
                chart1.Series["Series1"].Points.AddXY("Total Cars rented", carRent.ToString());
                chart1.AlignDataPointsByAxisLabel();
                conn.Close();
            }
            // Set the ComboBox to the first option by default
            tablesComboBox.SelectedIndex = 0;
        }