private void removeMatchListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     TextBox[]       idBoxesAway       = { PlayerID1Away, PlayerID2Away, PlayerID3Away, PlayerID4Away, PlayerID5Away, PlayerID6Away, PlayerID7Away, PlayerID8Away, PlayerID9Away, PlayerID10Away, PlayerID11Away };
     TextBox[]       noBoxesAway       = { PlayerNo1Away, PlayerNo2Away, PlayerNo3Away, PlayerNo4Away, PlayerNo5Away, PlayerNo6Away, PlayerNo7Away, PlayerNo8Away, PlayerNo9Away, PlayerNo10Away, PlayerNo11Away };
     ComboBox[]      positionBoxesAway = { PlayerPosition1Away, PlayerPosition2Away, PlayerPosition3Away, PlayerPosition4Away, PlayerPosition5Away, PlayerPosition6Away, PlayerPosition7Away, PlayerPosition8Away, PlayerPosition9Away, PlayerPosition10Away, PlayerPosition11Away };
     MaskedTextBox[] goalBoxesAway     = { Goals1Away, Goals2Away, Goals3Away, Goals4Away, Goals5Away, Goals6Away, Goals7Away, Goals8Away, Goals9Away, Goals10Away, Goals11Away };
     TextBox[]       idBoxesHome       = { PlayerID1Home, PlayerID2Home, PlayerID3Home, PlayerID4Home, PlayerID5Home, PlayerID6Home, PlayerID7Home, PlayerID8Home, PlayerID9Home, PlayerID10Home, PlayerID11Home };
     TextBox[]       noBoxesHome       = { PlayerNo1Home, PlayerNo2Home, PlayerNo3Home, PlayerNo4Home, PlayerNo5Home, PlayerNo6Home, PlayerNo7Home, PlayerNo8Home, PlayerNo9Home, PlayerNo10Home, PlayerNo11Home };
     ComboBox[]      positionBoxesHome = { PlayerPosition1Home, PlayerPosition2Home, PlayerPosition3Home, PlayerPosition4Home, PlayerPosition5Home, PlayerPosition6Home, PlayerPosition7Home, PlayerPosition8Home, PlayerPosition9Home, PlayerPosition10Home, PlayerPosition11Home };
     MaskedTextBox[] goalBoxesHome     = { Goals1Home, Goals2Home, Goals3Home, Goals4Home, Goals5Home, Goals6Home, Goals7Home, Goals8Home, Goals9Home, Goals10Home, Goals11Home };
     try
     {
         if (!connectionWithDatabase.isConnected())
         {
             connectionWithDatabase.OpenConnection();
         }
         object[] tab = new object[2];
         tab = connectionWithDatabase.returnIdOfTeams(removeMatchListBox);
         connectionWithDatabase.loadMatch(matchDateBox, matchTimeBox, competitionID, removeMatchListBox);
         connectionWithDatabase.loadPlayersToBoxes(tab[0], idBoxesHome, noBoxesHome, positionBoxesHome, goalBoxesHome, removeMatchListBox);
         connectionWithDatabase.loadPlayersToBoxes(tab[1], idBoxesAway, noBoxesAway, positionBoxesAway, goalBoxesAway, removeMatchListBox);
         totalHome.Text = sumOfGoals(goalBoxesHome).ToString();
         totalAway.Text = sumOfGoals(goalBoxesAway).ToString();
     }
     catch (Exception es)
     {
         MessageBox.Show("Error 404 in adding Team. Check DataBaseConnection \r\n" + es.Message + "\r\n" + es.InnerException.Message);
     }
     finally
     {
         connectionWithDatabase.CloseConnection();
     }
 }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBConnect con = new DBConnect();

            con.OpenConnection();
            string         query = "insert into bcpark354.Customer(CustomerID, Name, Address, AccountBalance)";
            SqlDataAdapter Da    = new SqlDataAdapter();

            try
            {
                Da.InsertCommand = new SqlCommand(query + "values (@CustomerID, @Name, @Address, @AccountBalance)", con.connection);
                Da.InsertCommand.Parameters.Add("@CustomerID", SqlDbType.Char).Value        = textBox1.Text;
                Da.InsertCommand.Parameters.Add("@Name", SqlDbType.Char).Value              = textBox2.Text;
                Da.InsertCommand.Parameters.Add("@Address", SqlDbType.VarChar).Value        = textBox3.Text;
                Da.InsertCommand.Parameters.Add("@AccountBalance", SqlDbType.Decimal).Value = decimal.Parse(textBox4.Text);
                Da.InsertCommand.ExecuteNonQuery();

                MessageBox.Show("The customer has been entered into the system");
            }
            catch (Exception q)
            {
                MessageBox.Show(q.Message, "Could not create customer", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            con.CloseConnection();
        }
Beispiel #3
0
 private void homeTeamComboBox_Click(object sender, EventArgs e)
 {
     try
     {
         if (!connectionWithDatabase.isConnected())
         {
             connectionWithDatabase.OpenConnection();
         }
         connectionWithDatabase.loadTeams(homeTeamComboBox);
     }
     catch (Exception es)
     {
         MessageBox.Show("Error 404 in adding Team. Check DataBaseConnection \r\n" + es.Message + "\r\n" + es.InnerException.Message);
     }
     finally
     {
         connectionWithDatabase.CloseConnection();
     }
 }
Beispiel #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!connectionWithDatabase.isConnected())
         {
             connectionWithDatabase.OpenConnection();
         }
         if (searchForMatchByTeams.Checked)
         {
             connectionWithDatabase.searchForMatchByTeamNames(dataGridView1, textBox1, textBox2);
         }
         else if (SearchForMatchByDate.Checked)
         {
             connectionWithDatabase.searchForMatchByDate(dataGridView1, matchDateBox);
         }
         else if (searchForMatchByCompetition.Checked)
         {
             connectionWithDatabase.searchForMatchByCompetition(dataGridView1, competitionID);
         }
         else if (searchForBestScorers.Checked)
         {
             connectionWithDatabase.searchForBestScorers(dataGridView1, comboBox3, comboBox4);
         }
         else if (SearchForTeamsMostGoals.Checked)
         {
             connectionWithDatabase.searchForTeamsMostGoals(dataGridView1, comboBox2);
         }
         else if (SearchForTeamsWithMostWins.Checked)
         {
             connectionWithDatabase.searchForTeamsMostWins(dataGridView1, comboBox6);
         }
         else if (SearchForTeamsWithMostDraws.Checked)
         {
             connectionWithDatabase.searchForTeamsMostDraws(dataGridView1, comboBox1);
         }
         else if (SearchForTeamsWithMostLoses.Checked)
         {
             connectionWithDatabase.searchForTeamsMostLoses(dataGridView1, comboBox5);
         }
     }
     catch (Exception es)
     {
         MessageBox.Show("Error 404 in adding Team. Check DataBaseConnection \r\n" + es.Message + "\r\n" + es.InnerException.Message);
     }
     finally
     {
         connectionWithDatabase.CloseConnection();
     }
 }
Beispiel #5
0
        public CustPastPurchaseReport(string choice)
        {
            InitializeComponent();
            string query;

            if (choice.Equals("item"))
            {
                query = "SELECT bcpark354.OrderDetail.ItemID, bcpark354.PurchaseOrder.CustomerID, bcpark354.PurchaseOrder.OrderID, bcpark354.PurchaseOrder.OrderDate, bcpark354.OrderDetail.Qty FROM bcpark354.PurchaseOrder INNER JOIN bcpark354.OrderDetail ON bcpark354.PurchaseOrder.OrderID=bcpark354.OrderDetail.OrderID WHERE bcpark354.PurchaseOrder.CustomerID = " + Program.custID + " ORDER BY bcpark354.OrderDetail.ItemID";
                DBConnect con = new DBConnect();
                con.OpenConnection();
                SqlDataReader Data      = con.getData(query);
                List <string> purchases = new List <string>();
                try
                {
                    while (Data.Read())
                    {
                        purchases.Add("ItemID: " + Data["ItemID"] + " -OrderID: " + Data["OrderID"] + " -CustomerID: " + Data["CustomerID"] + " -OrderDate: " + Data["OrderDate"] + " -Quantity: " + Data["Qty"]);
                    }

                    listBox1.DataSource = purchases;
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message, "Failed to Produce Report", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else if (choice.Equals("dates"))
            {
                query = "SELECT bcpark354.PurchaseOrder.OrderDate, bcpark354.OrderDetail.ItemID, bcpark354.PurchaseOrder.CustomerID, bcpark354.PurchaseOrder.OrderID, bcpark354.OrderDetail.Qty FROM bcpark354.PurchaseOrder INNER JOIN bcpark354.OrderDetail ON bcpark354.PurchaseOrder.OrderID=bcpark354.OrderDetail.OrderID  WHERE bcpark354.PurchaseOrder.CustomerID = " + Program.custID + " ORDER BY bcpark354.PurchaseOrder.DeliveryDate";
                DBConnect con = new DBConnect();
                con.OpenConnection();
                SqlDataReader Data      = con.getData(query);
                List <string> purchases = new List <string>();
                try
                {
                    while (Data.Read())
                    {
                        purchases.Add("OrderDate: " + Data["OrderDate"] + " -ItemID: " + Data["ItemID"] + " -CustomerID: " + Data["CustomerID"] + " -OrderID: " + Data["OrderID"] + " -Quantity: " + Data["Qty"]);
                    }

                    listBox1.DataSource = purchases;
                }
                catch (Exception a)
                {
                    MessageBox.Show(a.Message, "Failed to Produce Report", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals("9999"))
     {
         Admin next = new Admin();
         MessageBox.Show("Welcome Admin");
         next.Show();
         this.Hide();
     }
     else if (textBox1.TextLength > 4)
     {
         MessageBox.Show(textBox1.Text, "Incorrect Input", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     else
     {
         DBConnect con = new DBConnect();
         con.OpenConnection();
         try
         {
             string        query = "SELECT * FROM bcpark354.Customer";
             SqlDataReader Data  = con.getData(query);
             while (Data.Read())
             {
                 if (textBox1.Text.Equals(Data["CustomerID"].ToString()))
                 {
                     Program.custID = textBox1.Text;
                     Cust next = new Cust();
                     MessageBox.Show("Welcome Customer");
                     next.Show();
                     this.Hide();
                 }
             }
             Data.Close();
             con.CloseConnection();
         }
         catch (Exception x)
         {
             MessageBox.Show(x.Message, "Customer Retrival Failed", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
     }
 }
Beispiel #7
0
        public CreatePurchaseOrder()
        {
            InitializeComponent();

            try
            {
                DBConnect con = new DBConnect();
                con.OpenConnection();
                string        query = "SELECT * FROM bcpark354.Merchandise ";
                SqlDataReader Data  = con.getData(query);
                List <string> items = new List <string>();
                while (Data.Read())
                {
                    items.Add("ItemID: " + Data["ItemID"] + " - Name: " + Data["Name"] + " - Description: " + Data["Description"] + " - ListPrice: " + Data["ListPrice"].ToString());
                }
                listBox1.DataSource = items;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Failed to Populate Merchandise", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
Beispiel #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     TextBox[]  idBoxes       = { PlayerID1, PlayerID2, PlayerID3, PlayerID4, PlayerID5, PlayerID6, PlayerID7, PlayerID8, PlayerID9, PlayerID10, PlayerID11 };
     TextBox[]  noBoxes       = { PlayerNo1, PlayerNo2, PlayerNo3, PlayerNo4, PlayerNo5, PlayerNo6, PlayerNo7, PlayerNo8, PlayerNo9, PlayerNo10, PlayerNo11 };
     ComboBox[] positionBoxes = { PlayerPosition1, PlayerPosition2, PlayerPosition3, PlayerPosition4, PlayerPosition5, PlayerPosition6, PlayerPosition7, PlayerPosition8, PlayerPosition9, PlayerPosition10, PlayerPosition11 };
     try
     {
         if (!connectionWithDatabase.isConnected())
         {
             connectionWithDatabase.OpenConnection();
         }
         for (int i = 0; i < 11; i++)
         {
             if (idBoxes[i].Text == "" || noBoxes[i].Text == "" || addTeamBox.Text == "" || positionBoxes[i].SelectedItem == null || !maskedTextBox1.MaskCompleted)
             {
                 MessageBox.Show("Error. Boxes cant be empty");
                 return;
             }
         }
         connectionWithDatabase.addPlayersToDatabase(addTeamBox, maskedTextBox1, idBoxes, noBoxes, positionBoxes);
         MessageBox.Show("Team " + addTeamBox.Text + " has been added.");
     }
     catch (Exception es)
     {
         MessageBox.Show("Error 404 in adding Team. Check DataBaseConnection \r\n" + es.Message + "\r\n" + es.InnerException.Message);
     }
     finally
     {
         connectionWithDatabase.CloseConnection();
     }
     addTeamBox.Text = "";
     for (int i = 0; i < 11; i++)
     {
         idBoxes[i].Text = "";
         noBoxes[i].Text = "";
         positionBoxes[i].SelectedIndex = -1;
     }
 }
        public TotalPurchaseOrders()
        {
            InitializeComponent();
            DBConnect con = new DBConnect();

            con.OpenConnection();
            string        query     = "SELECT bcpark354.PurchaseOrder.OrderDate, count(bcpark354.PurchaseOrder.OrderDate) as NumberOrders, SUM(bcpark354.OrderDetail.UnitPrice) as TotalSales FROM bcpark354.PurchaseOrder INNER JOIN bcpark354.OrderDetail ON bcpark354.PurchaseOrder.OrderID=bcpark354.OrderDetail.OrderID GROUP BY bcpark354.PurchaseOrder.OrderDate ORDER BY bcpark354.PurchaseOrder.OrderDate DESC";
            SqlDataReader Data      = con.getData(query);
            List <string> purchases = new List <string>();

            try
            {
                while (Data.Read())
                {
                    purchases.Add("OrderDate: " + Data["OrderDate"] + " -NumberOfOrders: " + Data["NumberOrders"] + " -TotalSales: " + Data["TotalSales"]);
                }

                listBox1.DataSource = purchases;
            }
            catch (Exception a)
            {
                MessageBox.Show(a.Message, "Failed to Produce Report", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DBConnect con = new DBConnect();

            con.OpenConnection();
            string         query = "update bcpark354.Customer set Name = @Name, Address = @Address, AccountBalance = @AccountBalance where CustomerID = @CustomerID";
            SqlDataAdapter Da    = new SqlDataAdapter();

            try
            {
                Da.UpdateCommand = new SqlCommand(query, con.connection);
                Da.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Char).Value        = textBox1.Text;
                Da.UpdateCommand.Parameters.Add("@Name", SqlDbType.Char).Value              = textBox2.Text;
                Da.UpdateCommand.Parameters.Add("@Address", SqlDbType.VarChar).Value        = textBox3.Text;
                Da.UpdateCommand.Parameters.Add("@AccountBalance", SqlDbType.Decimal).Value = decimal.Parse(textBox4.Text);
                Da.UpdateCommand.ExecuteNonQuery();
                MessageBox.Show("The customer has been updated");
            }
            catch (Exception i)
            {
                MessageBox.Show(i.Message, "Could not update customer", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            con.CloseConnection();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int       count = 0;
            DBConnect con   = new DBConnect();

            con.OpenConnection();
            string itemIDvar = pItem.Substring(8, 4);
            string Mquery    = "select ListPrice from bcpark354.Merchandise where ItemID =" + itemIDvar;
            string Cquery    = "select * from bcpark354.PurchaseOrder";
            string Xquery    = "select AccountBalance from bcpark354.Customer where CustomerID =" + Program.custID;
            string Pquery    = "Insert into bcpark354.PurchaseOrder(OrderID, CustomerID, DeliveryDate, OrderDate)";
            string Oquery    = "Insert into bcpark354.OrderDetail(OrderID, ItemID, UnitPrice, Qty)";
            string Tquery    = "update bcpark354.Customer set AccountBalance = @AccountBalance where CustomerID =" + Program.custID;

            MessageBox.Show(itemIDvar);

            SqlDataReader Data = con.getData(Cquery);

            try
            {
                while (Data.Read())
                {
                    count++;
                }
                Data.Close();
                count++;
            }

            catch (Exception w)
            {
                MessageBox.Show(w.Message, "Could not produce orderID", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }

            SqlDataReader Data2 = con.getData(Mquery);

            try
            {
                while (Data2.Read())
                {
                    UnitPriceVar = Data2.GetDecimal(0);
                }
                Data2.Close();
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message, "Could not produce orderID", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }

            SqlDataReader Data3 = con.getData(Xquery);

            try
            {
                while (Data3.Read())
                {
                    funds = Data3.GetDecimal(0);
                }
                Data3.Close();
            }
            catch (Exception r)
            {
                MessageBox.Show(r.Message, "Could not produce orderID", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }

            total = UnitPriceVar * decimal.Parse(pQuantity);

            if (funds >= total)
            {
                SqlDataAdapter Da = new SqlDataAdapter();
                SqlDataAdapter Ha = new SqlDataAdapter();
                SqlDataAdapter Ca = new SqlDataAdapter();

                try
                {
                    Da.InsertCommand = new SqlCommand(Pquery + "values (@OrderID, @CustomerID, @DeliveryDate, @OrderDate)", con.connection);
                    Da.InsertCommand.Parameters.Add("@OrderID", SqlDbType.Char).Value          = count.ToString();
                    Da.InsertCommand.Parameters.Add("@CustomerID", SqlDbType.Char).Value       = Program.custID;
                    Da.InsertCommand.Parameters.Add("@DeliveryDate", SqlDbType.DateTime).Value = pDate.Date;
                    Da.InsertCommand.Parameters.Add("@OrderDate", SqlDbType.DateTime).Value    = nDate.Date;
                    Da.InsertCommand.ExecuteNonQuery();

                    Ha.InsertCommand = new SqlCommand(Oquery + "values (@OrderID, @ItemID, @UnitPrice, @Qty)", con.connection);
                    Ha.InsertCommand.Parameters.Add("@OrderID", SqlDbType.Char).Value      = count.ToString();
                    Ha.InsertCommand.Parameters.Add("@ItemID", SqlDbType.Char).Value       = itemIDvar;
                    Ha.InsertCommand.Parameters.Add("@UnitPrice", SqlDbType.Decimal).Value = total;
                    Ha.InsertCommand.Parameters.Add("@Qty", SqlDbType.Int).Value           = int.Parse(pQuantity);
                    Ha.InsertCommand.ExecuteNonQuery();

                    Ca.UpdateCommand = new SqlCommand(Tquery, con.connection);
                    Ca.UpdateCommand.Parameters.Add("@AccountBalance", SqlDbType.Decimal).Value = (funds - total);
                    Ca.UpdateCommand.ExecuteNonQuery();

                    MessageBox.Show("Your order as been entered into the system. Thank You");
                }
                catch (Exception x)
                {
                    MessageBox.Show(x.Message, "Could not confirm order", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            else
            {
                MessageBox.Show("Sorry, you do not have enough funds for that purchase");
            }
        }