Beispiel #1
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
            }
        }
Beispiel #2
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
            }
        }
Beispiel #3
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
            }
        }
Beispiel #4
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();
     }
 }
Beispiel #5
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();
     }
 }
Beispiel #6
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();
     }
 }
Beispiel #7
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
            }
        }