Exemplo n.º 1
0
        private void setUpPage()
        {
            int             i           = 0; //defines all required variables
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT masterMACAddress " +
                     "FROM tblGarmentBirthCertificate " +
                     "WHERE userEmail = '" + email + "'"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);

            while (dr.Read())
            {
                Button btn = new Button(); //creates a button for each company
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Text      = dr[0].ToString();;
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpExistingGarments.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 2
0
        private void setUpPage()
        {
            int             i           = 0; //sets all the required variables
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT email, firstName, surname " +
                     "FROM tblUser " +
                     "WHERE  (userTypeID = 1)"; //writes out the SQL string

            dr = dbConnector.DoSQL(sqlStr);     //executes the SQL string

            while (dr.Read())
            {
                Button btn = new Button();     //creates buttons for each superuser
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Tag       = dr[0].ToString();
                btn.Text      = dr[1].ToString() + " " + dr[2].ToString();
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpEmployees.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 3
0
        private void setUpPage()
        {
            int             i           = 0; //defines all required variables
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT companyID, companyName " +
                     "FROM tblCompany "; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);

            while (dr.Read())
            {
                Button btn = new Button(); //creates a button for each company
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Tag       = dr[0].ToString();
                btn.Text      = dr[1].ToString();;
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpCompanies.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 4
0
        private int getEvents(DateTime dateTime, string eventType) //finds the number of critical events
        {
            int noOfEvents = 0;

            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT COUNT(tblTypeOfEvent.eventName) AS Expr1 " +
                     "FROM (((tblGarmentStatus INNER JOIN " +
                     "tblGarmentBirthCertificate ON tblGarmentStatus.masterMACAddress = tblGarmentBirthCertificate.masterMACAddress) INNER JOIN " +
                     "tblEvents ON tblGarmentStatus.garmentStatusID = tblEvents.garmentStatusID) INNER JOIN " +
                     "tblTypeOfEvent ON tblEvents.typeOfEventID = tblTypeOfEvent.typeOfEventID) " +
                     "HAVING (tblGarmentBirthCertificate.masterMACAddress = '" + MACAddress + "') AND (tblTypeOfEvent.eventName = '" + eventType + "') AND (tblGarmentBirthCertificate.userEmail = '" + email + "') AND (tblGarmentStatus.[dateTime] >= #" + dateTime.ToString("MM/dd/yyyy 00:00:00") + "#) AND (tblGarmentStatus.[dateTime] < #" + (dateTime.AddDays(1).ToString("MM/dd/yyyy 00:00:00")) + "#)";

            dr = dbConnector.DoSQL(sqlStr);

            while (dr.Read())
            {
                noOfEvents = Convert.ToInt32(dr[0]);
            }

            dr.Close();
            dbConnector.close();

            return(noOfEvents);
        }
Exemplo n.º 5
0
        private void btnSaveChanges_Click(object sender, EventArgs e) //when the 'Save Changes' button is clicked, it updates the database for any information that's been changed
        {
            clsDBConnector  dbConnector = new clsDBConnector();       //defines any variables needed
            OleDbDataReader dr;
            string          sqlStr;
            string          newCompanyName, newPostcode, newDefaultPassword, newCompanyEmail, newPassword;

            newCompanyName     = txtCompanyName.Text; //sets the variables as required
            newPostcode        = txtPostcode.Text;
            newDefaultPassword = txtDefaultPassword.Text;
            newCompanyEmail    = txtCompanyEmail.Text;
            newPassword        = txtPassword.Text;

            dbConnector.Connect();

            sqlStr = "UPDATE tblCompany " +
                     "SET companyName = '" + newCompanyName + "', hqPostcode = '" + newPostcode + "', defaultPassword = '******', companyEmail = '" + newCompanyEmail + "', companyPassword = '******'" +
                     " WHERE (tblCompany.CompanyID = " + companyID + ")"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                               //executes the SQL string

            dr.Close();
            dbConnector.close();

            MessageBox.Show("Changes made."); //alerts the user of any changes made
            this.Close();                     //closes the form so no accidental changes can be made
        }
Exemplo n.º 6
0
        private int getLowestAngle(DateTime dateTime) //finds the lowest angle
        {
            int lowestAngle = 0;

            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT MIN(tblGarmentStatus.angle) AS Expr1 " +
                     "FROM (((tblCompany INNER JOIN " +
                     "tblUser ON tblCompany.companyID = tblUser.companyID) INNER JOIN " +
                     "tblGarmentBirthCertificate ON tblUser.email = tblGarmentBirthCertificate.userEmail) INNER JOIN " +
                     "tblGarmentStatus ON tblGarmentBirthCertificate.masterMACAddress = tblGarmentStatus.masterMACAddress) " +
                     "HAVING (tblCompany.companyID = " + companyID + ") AND (tblGarmentStatus.[dateTime] >= #" + dateTime.ToString("MM/dd/yyyy 00:00:00") + "#) AND (tblGarmentStatus.[dateTime] < #" + (dateTime.AddDays(1).ToString("MM/dd/yyyy 00:00:00")) + "#)";

            dr = dbConnector.DoSQL(sqlStr);

            while (dr.Read())
            {
                lowestAngle = Convert.ToInt32(dr[0]);
            }

            dr.Close();
            dbConnector.close();

            return(lowestAngle);
        }
Exemplo n.º 7
0
        private void setUpPage()
        {
            clsDBConnector  dbConnector = new clsDBConnector(); //sets the text boxes to what the company's current details are
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT companyName, hqPostcode, defaultPassword, companyEmail, companyPassword " +
                     "FROM tblCompany " +
                     "WHERE (companyID = " + companyID + ")"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                   //executes the SQL string

            while (dr.Read())
            {
                txtCompanyName.Text     = dr[0].ToString(); //sets the variables to what they need to be
                txtPostcode.Text        = dr[1].ToString();
                txtDefaultPassword.Text = dr[2].ToString();
                txtCompanyEmail.Text    = dr[3].ToString();
                txtPassword.Text        = dr[4].ToString();
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 8
0
        private void setUpPage()
        {
            clsDBConnector  dbConnector = new clsDBConnector(); //finds all they relevant information needed about the company
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT companyID, companyName, defaultPassword " +
                     "FROM tblCompany " +
                     "WHERE (companyEmail = '" + company_email + "')"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                            //executes the SQL string

            while (dr.Read())
            {
                company_ID       = Convert.ToInt32(dr[0]); //sets the required variables
                company_name     = dr[1].ToString();
                default_password = dr[2].ToString();
            }

            dr.Close();
            dbConnector.close();

            lblCompanyName.Text  = company_name; //sets the page up
            lblLoggedInTime.Text = "Logged in at " + Convert.ToString(DateTime.Now);
            lblOnlineTime.Text   = "0";
        }
Exemplo n.º 9
0
        private void btnAddCompany_Click(object sender, EventArgs e)                                 //when the add company button is clicked
        {
            string         companyName, postcode, default_password, company_email, company_password; //sets all the variables needed
            clsDBConnector dbConnector = new clsDBConnector();

            if (txtCompanyName.Text != "" && txtPostcode.Text != "" && txtDefaultPassword.Text != "" && txtPassword.Text != "" && txtCompanyEmail.Text != "") //makes sure nothing is null
            {
                companyName      = txtCompanyName.Text;                                                                                                       //sets all the variables to the chosen values
                postcode         = txtPostcode.Text;
                default_password = txtDefaultPassword.Text;
                company_email    = txtCompanyEmail.Text;
                company_password = txtPassword.Text;

                string sqlStr = "INSERT INTO tblCompany (hqPostcode, companyName, [defaultPassword], companyEmail, companyPassword) " +
                                "VALUES ('" + postcode + "' , '" + companyName + "', '" + default_password + "', '" + company_email + "', '" + company_password + "')"; //this is the SQL code required
                dbConnector.Connect();
                dbConnector.DoDML(sqlStr);                                                                                                                              //completes the SQL statement
                dbConnector.close();

                MessageBox.Show("New company added."); //alerts the user that it has been successful
                this.Close();                          //closes at the end to avoid adding the same company twice
            }

            else
            {
                MessageBox.Show("Please fill in all fields."); //throws an error message if not all sections are completed
            }
        }
Exemplo n.º 10
0
        private void btnSaveChanges_Click(object sender, EventArgs e) //when the 'Save Changes' button is clicked, this updates the database for any information that's been changed
        {
            clsDBConnector  dbConnector = new clsDBConnector();       //defines required variables
            OleDbDataReader dr;
            string          sqlStr;
            string          newFirstName, newSurname, newHouseNameNo, newPostcode, newPassword;
            int             newNestNo;
            DateTime        newDOB;

            newFirstName   = txtFirstName.Text; //sets required variables
            newSurname     = txtSurname.Text;
            newHouseNameNo = txtHouseNo.Text;
            newPostcode    = txtPostcode.Text;
            newPassword    = txtPassword.Text;
            newNestNo      = Convert.ToInt32(nudNestID.Value);
            newDOB         = dtpDOB.Value;

            dbConnector.Connect();
            sqlStr = "UPDATE tblUser " +
                     "SET [password] = '" + newPassword + "', firstName = '" + newFirstName + "', surname = '" + newSurname + "', dateOfBirth = '" + newDOB +
                     "', nestID = " + newNestNo + ", postcode = '" + newPostcode + "', houseName = '" + newHouseNameNo + "'" +
                     " WHERE (tblUser.email = '" + email + "')"; //writes the SQL string
            dr = dbConnector.DoSQL(sqlStr);                      //executes the SQL
            dr.Close();
            dbConnector.close();

            MessageBox.Show("Changes made."); //alerts the user that the changes have been made
            this.Close();                     //closes the form to avoid trying to make the same changes twice
        }
Exemplo n.º 11
0
        private void btnAddNest_Click(object sender, EventArgs e) //happens when the 'Add Nest' button is clicked
        {
            DateTime       dateAdded;                             //defines the required variables
            string         postcode, whatThreeWords;
            clsDBConnector dbConnector = new clsDBConnector();

            if (txtNestPostcode.Text != "" && txtWhatThreeWords.Text != "") //makes sure nothing is null
            {
                postcode       = txtNestPostcode.Text;                      //sets the variables to the selected values
                whatThreeWords = txtWhatThreeWords.Text;
                dateAdded      = DateTime.Now;

                string sqlStr = "INSERT INTO tblNestBirthCertificate (postcode, dateAdded, companyID, whatThreeWords) " +
                                "VALUES ('" + postcode + "', '" + dateAdded + "', " + companyID + ", '" + whatThreeWords + "')"; //the SQL statement is written

                dbConnector.Connect();
                dbConnector.DoDML(sqlStr); //the SQL statement is executed
                dbConnector.close();

                MessageBox.Show("New nest added."); //alerts the user that it has been successful
                this.Close();                       //closes at the end to avoide adding the same nest twice
            }
            else
            {
                MessageBox.Show("Please fill in all the sections."); //throws an error message if not all sections are completed
            }
        }
Exemplo n.º 12
0
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            clsDBConnector  dbConnector = new clsDBConnector(); //defines any variables that are needed
            OleDbDataReader dr;
            string          sqlStr;
            string          newEmail, newFirstName, newSurname, newHouseNameNo, newPostcode, newPassword;
            int             newNestNo;
            DateTime        newDOB;

            newEmail       = txtEmail.Text; //sets the varibales to the required values
            newFirstName   = txtFirstName.Text;
            newSurname     = txtSurname.Text;
            newHouseNameNo = txtHouseNo.Text;
            newPostcode    = txtPostcode.Text;
            newPassword    = txtPassword.Text;
            newNestNo      = Convert.ToInt32(nudNestID.Value);
            newDOB         = dtpDOB.Value;

            dbConnector.Connect();

            sqlStr = "UPDATE tblUser " +
                     "SET email = '" + newEmail + "', [password] = '" + newPassword + "', firstName = '" + newFirstName + "', surname = '" + newSurname + "', dateOfBirth = '" + newDOB + "', nestID = " + newNestNo + ", postcode = '" + newPostcode + "', houseName = '" + newHouseNameNo + "'" +
                     " WHERE (tblUser.email = '" + email + "')"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                      //executes the SQL string

            dr.Close();
            dbConnector.close();

            MessageBox.Show("Changes made."); //alerts the user that the changes have been made
            this.Close();                     //closes the form once changes are made
        }
Exemplo n.º 13
0
        private void btnAddUSer_Click(object sender, EventArgs e)            //when the 'Add User' button is clicked
        {
            string         email, firstName, surname, houseNameNo, postcode; //defines the required variables
            int            nestID, companyID;
            clsDBConnector dbConnector = new clsDBConnector();
            DateTime       dateOfBirth, dateJoined;

            if (txtEmail.Text != "" && txtFirstName.Text != "" && txtSurname.Text != "" && txtHouseNo.Text != "" && txtPostcode.Text != "" && nudNestID.Value != 0) //makes sure nothing is null
            {
                email       = txtEmail.Text;                                                                                                                        //sets all the variables to the required values
                firstName   = txtFirstName.Text;
                surname     = txtSurname.Text;
                houseNameNo = txtHouseNo.Text;
                postcode    = txtPostcode.Text;
                nestID      = Convert.ToInt32(nudNestID.Value);
                dateOfBirth = dtpDOB.Value;
                companyID   = company_ID;
                dateJoined  = DateTime.Now;

                string sqlStr = "INSERT INTO tblUser (email, [password], firstName, surname, companyID, dateOfBirth, nestID, postcode, houseName, dateJoined, userTypeID) " +
                                "VALUES ('" + email + "' , '" + password + "', '" + firstName + "', '" + surname + "', " +
                                companyID + ", '" + dateOfBirth + "', " + nestID + ", '" + postcode + "', '" + houseNameNo + "', '" + dateJoined + "', " + user_type_ID + ")"; //this writes the SQL string
                dbConnector.Connect();
                dbConnector.DoDML(sqlStr);                                                                                                                                     //this executes the SQL string
                dbConnector.close();

                MessageBox.Show("New user added."); //alters the user that it has been successful
                this.Close();                       //closes at the end to avoide adding the same person twice.
            }

            else
            {
                MessageBox.Show("Please fill in all the sections."); //throws an error message if not all sections are completed
            }
        }
Exemplo n.º 14
0
        private void setUpListBox(DateTime selectedDate)
        {
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();
            sqlStr = "SELECT tblUser.email, tblUser.firstName, tblUser.surname, tblGarmentStatus.angle, tblEvents.eventID, tblTypeOfEvent.eventName " +
                     "FROM (((tblGarmentBirthCertificate INNER JOIN " +
                     "tblUser ON tblGarmentBirthCertificate.userEmail = tblUser.email) INNER JOIN " +
                     "tblGarmentStatus ON tblGarmentBirthCertificate.masterMACAddress = tblGarmentStatus.masterMACAddress) INNER JOIN " +
                     "(tblEvents INNER JOIN " +
                     "tblTypeOfEvent ON tblEvents.typeOfEventID = tblTypeOfEvent.typeOfEventID) ON tblGarmentStatus.garmentStatusID = tblEvents.garmentStatusID) " +
                     "WHERE (tblUser.companyID = " + companyID + ") AND (tblGarmentStatus.[dateTime] >= #" + selectedDate.ToString("MM/dd/yyyy 00:00:00") + "#) AND (tblGarmentStatus.[dateTime] < #" + (selectedDate.AddDays(1).ToString("MM/dd/yyyy 00:00:00")) + "#)";
            dr = dbConnector.DoSQL(sqlStr);
            lstEvents.Items.Clear();
            while (dr.Read())
            {
                lstEvents.Items.Add(dr[0].ToString());
                lstEvents.Items[lstEvents.Items.Count - 1].SubItems.Add(dr[1].ToString());
                lstEvents.Items[lstEvents.Items.Count - 1].SubItems.Add(dr[2].ToString());
                lstEvents.Items[lstEvents.Items.Count - 1].SubItems.Add(dr[3].ToString());
                lstEvents.Items[lstEvents.Items.Count - 1].SubItems.Add(dr[4].ToString());
                lstEvents.Items[lstEvents.Items.Count - 1].SubItems.Add(dr[5].ToString());
            }
            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 15
0
        private int getHighestAngle(DateTime dateTime) //finds the highest angle
        {
            int highestAngle = 0;

            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT MAX(tblGarmentStatus.angle) AS Expr1 " +
                     "FROM (tblGarmentStatus INNER JOIN " +
                     "tblGarmentBirthCertificate ON tblGarmentStatus.masterMACAddress = tblGarmentBirthCertificate.masterMACAddress) " +
                     "HAVING (tblGarmentBirthCertificate.masterMACAddress = '" + MACAddress + "') AND (tblGarmentBirthCertificate.userEmail = '" + email + "') AND (tblGarmentStatus.[dateTime] >= #" + dateTime.ToString("MM/dd/yyyy 00:00:00") + "#) AND (tblGarmentStatus.[dateTime] < #" + (dateTime.AddDays(1).ToString("MM/dd/yyyy 00:00:00")) + "#)";


            dr = dbConnector.DoSQL(sqlStr);

            while (dr.Read())
            {
                highestAngle = Convert.ToInt32(dr[0]);
            }

            dr.Close();
            dbConnector.close();

            return(highestAngle);
        }
Exemplo n.º 16
0
        private void setUpPage()
        {
            clsDBConnector  dbConnector = new clsDBConnector(); //sets any variables needed
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT [password], firstName, surname, dateOfBirth, nestID, postcode, houseName " +
                     "FROM tblUser " +
                     "WHERE (email = '" + email + "')"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);             //executes the SQL

            while (dr.Read())
            {
                txtEmail.Text     = email; //sets the text box values as required
                txtPassword.Text  = dr[0].ToString();
                txtFirstName.Text = dr[1].ToString();
                txtSurname.Text   = dr[2].ToString();
                dtpDOB.Value      = Convert.ToDateTime(dr[3]);
                nudNestID.Value   = Convert.ToInt32(dr[4]);
                txtPostcode.Text  = dr[5].ToString();
                txtHouseNo.Text   = dr[6].ToString();
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 17
0
 private void deleteUser(object sender) //deletes the selected user from the database
 {
     if (MessageBox.Show("Do you want to delete this employee?", "Delete Options", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         clsDBConnector dbConnector = new clsDBConnector();
         string         cmdStr      = "DELETE FROM tblUser " +
                                      "WHERE (email = '" + ((sender as Button).Tag).ToString() + "')";
         dbConnector.Connect();
         dbConnector.DoDML(cmdStr);
         dbConnector.close();
         this.Close();
     }
 }
Exemplo n.º 18
0
 private void deleteGarment(object sender)
 {
     if (MessageBox.Show("Do you want to delete this garment?", "Delete Options", MessageBoxButtons.YesNo) == DialogResult.Yes) //lets the user delete the selected garment
     {
         clsDBConnector dbConnector = new clsDBConnector();
         string         cmdStr      = "DELETE FROM tblGarmentBirthCertificate " +
                                      "WHERE (masterMACAddress = '" + (sender as Button).Text + "')";
         dbConnector.Connect();
         dbConnector.DoDML(cmdStr);
         dbConnector.close();
         this.Close();
     }
 }
Exemplo n.º 19
0
        private void btnAddGarment_Click(object sender, EventArgs e)
        {
            string         masterMAC, LLMAC, LUMAC, RLMAC, RUMAC, garmentType; //defines the required variables
            int            garmentTypeID = 0;
            clsDBConnector dbConnector   = new clsDBConnector();
            DateTime       dateAdded;

            if (txtMasterMAC.Text != "" && txtLLMAC.Text != "" && txtLUMAC.Text != "" && txtRUMAC.Text != "" && txtRLMAC.Text != "" && dudGarmentType.Text != "") //makes sure nothing is null
            {
                masterMAC   = txtMasterMAC.Text;                                                                                                                  //sets all the variables to the required values
                LLMAC       = txtLLMAC.Text;
                LUMAC       = txtLUMAC.Text;
                RLMAC       = txtRLMAC.Text;
                RUMAC       = txtRUMAC.Text;
                garmentType = dudGarmentType.Text;
                dateAdded   = DateTime.Now;

                if (garmentType == "Trousers") //works out the garmentTypeID
                {
                    garmentTypeID = 1;
                }
                else if (garmentType == "Shirt")
                {
                    garmentTypeID = 2;
                }
                else if (garmentType == "Jacket")
                {
                    garmentTypeID = 3;
                }

                string sqlStr = "INSERT INTO tblGarmentBirthCertificate (garmentID, masterMACAddress, macAddressLU, macAddressLL, macAddressRU, macAddressRL, dateAdded, userEmail) " +
                                "VALUES (" + garmentTypeID + ", '" + masterMAC + "' , '" + LUMAC + "', '" + LLMAC + "', '" + RUMAC + "', '" +
                                RLMAC + "', '" + dateAdded + "', '" + email + "')"; //this writes the SQL string
                dbConnector.Connect();
                dbConnector.DoDML(sqlStr);                                          //this executes the SQL string
                dbConnector.close();

                MessageBox.Show("New garment added."); //alters the user that it has been successful
                this.Close();                          //closes at the end to avoide adding the same garment twice.
            }

            else
            {
                MessageBox.Show("Please fill in all the sections."); //throws an error message if not all sections are completed
            }
        }
Exemplo n.º 20
0
 private void deleteCompany(object sender)
 {
     if (Convert.ToInt32((sender as Button).Tag) == 1) //cannot delete Vision270 as it is the owner company
     {
         MessageBox.Show("You cannot delete this company.");
     }
     else if (MessageBox.Show("Do you want to delete this company?", "Delete Options", MessageBoxButtons.YesNo) == DialogResult.Yes) //lets the user delete the selected company
     {
         clsDBConnector dbConnector = new clsDBConnector();
         string         cmdStr      = "DELETE FROM tblCompany " +
                                      "WHERE (companyID = " + Convert.ToInt32((sender as Button).Tag) + ")";
         dbConnector.Connect();
         dbConnector.DoDML(cmdStr);
         dbConnector.close();
         this.Close();
     }
 }
Exemplo n.º 21
0
        private void getName()
        {
            clsDBConnector  dbConnector = new clsDBConnector(); //finds all they relevant information needed about the company
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT firstName, surname " +
                     "FROM tblUser " +
                     "WHERE (email = '" + email + "')"; //writes SQL code

            dr = dbConnector.DoSQL(sqlStr);             //executes the SQL string

            while (dr.Read())
            {
                name = dr[0].ToString() + " " + dr[1].ToString(); //sets the name
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 22
0
        private void setUpPage()
        {
            lblCompanyName.Text = company_name + " Employees"; //sets the title
            int i = 0;

            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;

            string sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT tblUser.email, tblUser.firstName, tblUser.surname " +
                     "FROM (tblCompany INNER JOIN " +
                     "tblUser ON tblCompany.companyID = tblUser.companyID) " +
                     "WHERE (tblCompany.companyID = " + company_ID + ")"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                               //executes the SQL string

            while (dr.Read())
            {
                Button btn = new Button(); //creates a Flow Layout Pannel with a button for each employee
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Tag       = dr[0].ToString();
                btn.Text      = dr[1].ToString() + " " + dr[2].ToString();
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpEmployees.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 23
0
        private string GetData(DateTime selectedDate)
        {
            string          dataToPrint = "";
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();
            sqlStr = "SELECT tblUser.email, tblGarmentStatus.angle, tblEvents.eventID, tblTypeOfEvent.eventName " +
                     "FROM (((tblGarmentBirthCertificate INNER JOIN " +
                     "tblUser ON tblGarmentBirthCertificate.userEmail = tblUser.email) INNER JOIN " +
                     "tblGarmentStatus ON tblGarmentBirthCertificate.masterMACAddress = tblGarmentStatus.masterMACAddress) INNER JOIN " +
                     "(tblEvents INNER JOIN " +
                     "tblTypeOfEvent ON tblEvents.typeOfEventID = tblTypeOfEvent.typeOfEventID) ON tblGarmentStatus.garmentStatusID = tblEvents.garmentStatusID) " +
                     "WHERE (tblUser.companyID = " + companyID + ") AND (tblGarmentStatus.[dateTime] >= #" + selectedDate.ToString("MM/dd/yyyy 00:00:00") + "#) AND (tblGarmentStatus.[dateTime] < #" + (selectedDate.AddDays(1).ToString("MM/dd/yyyy 00:00:00")) + "#)";
            dr = dbConnector.DoSQL(sqlStr);
            lstEvents.Items.Clear();
            dataToPrint = header;
            while (dr.Read())
            {
                dataToPrint = dataToPrint + string.Format("{0,-50}{1,-10}{2,-25}{3,-25}", dr[0].ToString(), dr[1].ToString(), dr[2].ToString(), dr[3].ToString()) + "\n";
            }
            return(dataToPrint);
        }
Exemplo n.º 24
0
        private void setUpPage()                          //click on a nest ID to see its details & most recent status
        {
            lblCompanyName.Text = companyName + " Nests"; //sets the page title

            int             i           = 0;              //defines all required variables
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT tblNestBirthCertificate.NestID " +
                     "FROM (tblCompany INNER JOIN " +
                     "tblNestBirthCertificate ON tblCompany.companyID = tblNestBirthCertificate.companyID) " +
                     "WHERE (tblCompany.companyID = " + companyID + ")"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                              //executes the sql string

            while (dr.Read())
            {
                Button btn = new Button(); //sets up buttons to show each nest
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Tag       = dr[0].ToString();
                btn.Text      = dr[0].ToString();
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpEmployees.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 25
0
        private void setUpPage()                               //uses dynamic controls to view the names and ID's of all employees
        {
            lblCompanyName.Text = company_name + " Employees"; //sets the title of the page

            int             i           = 0;                   //defines all the required variables
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr;
            string          sqlStr;

            dbConnector.Connect();

            sqlStr = "SELECT tblUser.email, tblUser.firstName, tblUser.surname " +
                     "FROM (tblCompany INNER JOIN " +
                     "tblUser ON tblCompany.companyID = tblUser.companyID) " +
                     "WHERE (tblCompany.companyID = " + company_ID + ")"; //writes the SQL string

            dr = dbConnector.DoSQL(sqlStr);                               //executes the SQL string

            while (dr.Read())
            {
                Button btn = new Button(); //sets up a button for each user
                btn.BackColor = Color.DarkOrange;
                btn.ForeColor = Color.White;
                btn.Size      = new Size(100, 90);
                btn.Visible   = true;
                btn.Tag       = dr[0].ToString();
                btn.Text      = dr[1].ToString() + " " + dr[2].ToString();
                btn.Name      = "btn_ " + i;
                i++;
                btn.Click += btn_Click;
                flpEmployees.Controls.Add(btn);
            }

            dr.Close();
            dbConnector.close();
        }
Exemplo n.º 26
0
        private void btnLogin_Click(object sender, EventArgs e) //when the 'Login' button is clicked
        {
            string          input_email, input_password;        //declares all variables needed
            clsDBConnector  dbConnector = new clsDBConnector();
            OleDbDataReader dr, drCompany;
            string          sqlStr;

            bool loggedin = false;          //this is to decide whether the user has or hasn't logged in so it knows whether to display an error message or not

            input_email    = txtEmail.Text; //takes the user inputs
            input_password = txtPassword.Text;

            dbConnector.Connect();

            if (rbSuperuser.Checked == true || rbUser.Checked == true)        //works out the type of user logging in
            {
                sqlStr = "SELECT email, [password], userTypeID FROM tblUser"; //states the sql statement

                dr = dbConnector.DoSQL(sqlStr);                               //executes the SQL statement

                while (dr.Read())
                {
                    if (input_email == dr[0].ToString() && input_password == dr[1].ToString()) //checks to see if the login credentials are correct
                    {
                        loggedin = true;
                        int userType = Convert.ToInt32(dr[2].ToString());

                        if (userType == 1) //opens the superuser homepage
                        {
                            frmSuperuserHomepage superuserHomepageForm = new frmSuperuserHomepage(input_email);
                            superuserHomepageForm.Show();
                        }

                        else if (userType == 2) //opens the ordinary user homepage
                        {
                            frmUserHomepage userHomepageForm = new frmUserHomepage(input_email);
                            userHomepageForm.Show();
                        }

                        this.Close();
                    }
                }

                dr.Close();
                dbConnector.close();
            }

            else if (rbCompany.Checked == true)
            {
                sqlStr = "SELECT companyEmail, companyPassword FROM tblCompany"; //states the sql statement

                drCompany = dbConnector.DoSQL(sqlStr);                           //executes the SQL statement

                while (drCompany.Read())
                {
                    if (input_email == drCompany[0].ToString() && input_password == drCompany[1].ToString()) //checks to see if the login credentials are correct
                    {
                        loggedin = true;

                        frmCompaniesHomepage companyHomepageForm = new frmCompaniesHomepage(input_email); //opens the companies homepage
                        companyHomepageForm.Show();

                        this.Close();
                    }
                }
            }

            if (!loggedin) //if they have not been logged in, an error message will show in the form of a message box
            {
                MessageBox.Show("Email, password or user type is incorrect. Please try again.");
                txtEmail.Clear();
                txtPassword.Clear();
            }

            dbConnector.close();
        }