private void btnPost_Click(object sender, EventArgs e)
        {
            String query;

            //MessageBox.Show(redBody.Text);
            string heading = txtHeading.Text.Replace("'", "`");

            heading = heading.Replace('"', '`');
            string body = redBody.Text.Replace("'", "`");

            body = body.Replace('"', '`');

            query = "INSERT INTO announcement(USER_ID,DATE_POSTED,HEADING,MESSAGE) VALUES(" + UserID + ",'" + DateTime.Now.ToString() + "','" + txtHeading.Text.Replace("'", "`") + "','" + redBody.Text.Replace("'", "`") + "')";
            //MessageBox.Show(UserID.ToString());
            if (myLogHangle.doQuery(query))
            {
                myLogHangle.insertChange(UserID, "Added announcement: " + heading);
                MessageBox.Show("Post Added", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                parentForm.updatePosts();
                this.Close();
            }
            else
            {
                MessageBox.Show("Could not add post", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validateForm())
            {
                int imgID = -1;
                if (txtFilename.TextLength > 0)
                {
                    imgID = myLogHangle.insertImage(@txtFilename.Text, txtCaption.Text);
                }

                string sIMIE   = txtIMIE.Text,
                       sName   = txtName.Text,
                       sSerial = txtSerial.Text,
                       sPin    = txtPin.Text,
                       sEmail  = txtEmail.Text,
                       sPass   = txtPassword.Text,
                       sModel  = txtModel.Text,
                       sTel    = txtTel.Text;

                String querytString = "";
                if (imgID == -1)
                {
                    querytString = "INSERT INTO device (CATEGORY,IMIE_NUMBER,DEVICE_TEL,DEVICE_NAME,SERIAL,DEVICE_PIN,DEVICE_EMAIL,DEVICE_PASSWORD,MODEL_NUMBER,DATE_ADDED) VALUES " +
                                   "(" + iCat + ",'" + sIMIE + "','" + sTel + "','" + sName + "','" + sSerial + "','" + sPin + "','" + sEmail + "','" + sPass + "','" + sModel + ",'" + DateTime.Now.ToString() + "')";
                }
                else
                {
                    querytString = "INSERT INTO device (CATEGORY,IMIE_NUMBER,DEVICE_TEL,DEVICE_NAME,SERIAL,DEVICE_PIN,DEVICE_EMAIL,DEVICE_PASSWORD,MODEL_NUMBER,BLOBID,DATE_ADDED) VALUES " +
                                   "(" + iCat + ",'" + sIMIE + "','" + sTel + "','" + sName + "','" + sSerial + "','" + sPin + "','" + sEmail + "','" + sPass + "','" + sModel + "'," + imgID + ",'" + DateTime.Now.ToString() + "')";
                }

                if (myLogHangle.doQuery(querytString))
                {
                    myLogHangle.insertChange(UserID, "Added device " + sName, sIMIE);
                    MessageBox.Show("Device added", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    parentForm.updateDevices();
                    //this.Close();
                }
                else
                {
                    MessageBox.Show("Could not add Device", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void btnAddNew_Click(object sender, EventArgs e)
 {
     if (txtLockerName.TextLength > 0)
     {
         string querytString = "INSERT INTO locker (LOCKER_NAME,LOCKER_STATUS) VALUES " +
                               "('" + txtLockerName.Text + "',1)";
         logHandle myLogHandle = new logHandle();
         if (myLogHandle.doQuery(querytString))
         {
             myLogHandle.insertChange(AdminID, "Added new locker " + txtLockerName.Text);
             lockerTableAdapter2.Fill(bblabsDataSet1.locker);
         }
     }
 }
        public bool update(int AdminID, string sLockName)
        {
            sLockerName = sLockName;
            logHandle myLog = new logHandle();

            if (myLog.doQuery("UPDATE locker SET LOCKER_NAME = '" + sLockerName + "' WHERE LOCKER_ID = " + recordID))
            {
                myLog.insertChange(AdminID, "Changed locker name to: " + sLockName);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                String eventName = txtEventName.Text, dateCreated = DateTime.Now.ToString(), eventDate = dateEvent.Value.ToString(), creator = lblCreator.Text, participants, summary = redSummary.Text, venue = txtVenue.Text;
                int    RespPerson = (int)cmbResponsible.SelectedValue, eventStatus;

                if (chkOpen.Checked == true)
                {
                    eventStatus = 0;
                }
                else
                {
                    eventStatus = 1;
                }

                participants = "";
                for (int i = 0; i < chkParticipants.Items.Count; i++)
                {
                    participants += chkParticipants.Items[i].ToString() + ",";
                }

                String querytString = "INSERT INTO event(CREATOR,LAB_USER,EVENT_NAME,COMMENTS,CREATION_DATE,EVENT_DATE,VENUE,PARTICIPANTS,EVENT_STATUS) " +
                                      "VALUES(" + UserID + "," + RespPerson + ",'" + eventName + "','" + summary + "','" + dateCreated + "','" + eventDate + "','" + venue + "','" + participants + "'," + eventStatus + ")";
                if (myLogHangle.doQuery(querytString))
                {
                    myLogHangle.insertChange(UserID, "Created new event: " + eventName);
                    parentForm.updateEvents();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Fail");
                }
            }
        }
Example #6
0
 private void btnDeleteEvent_Click(object sender, EventArgs e)
 {
     System.Data.DataRowView myRow = (System.Data.DataRowView)lstEvents.SelectedItem;
     if (lstEvents.SelectedIndex > -1)
     {
         if (lstEvents.Items.Count > 0)
         {
             String querytString = "DELETE FROM event WHERE EVENT_ID =" + (int)lstEvents.SelectedValue;
             if (myLogHangle.doQuery(querytString))
             {
                 myLogHangle.insertChange(UserID, "Removed event: " + myRow[8].ToString());
                 eventTableAdapter.Fill(bBLABSDataSet._event);
             }
             else
             {
                 MessageBox.Show("Could not remove event", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
        public bool checkout()
        {
            String sQuery = "BEGIN TRANSACTION ";

            for (int i = 0; i < dStoredDevice.Count; i++)
            {
                sQuery += "INSERT INTO lockerItem(LOCKER_ID,DEVICE_ID,LOCK_ITEM_STATUS) VALUES(" + recordID + "," + dStoredDevice[i].recordID + "," + 1 + ") ";
                sQuery += "UPDATE device SET DEVICE_STATUS = 2 WHERE DEVICE_ID = " + dStoredDevice[i].recordID + " ";
            }
            sQuery += "UPDATE locker SET KEY_ONE_USER="******", KEY_TWO_USER="******", LOCKER_STATUS = 2, DATE_FROM = '" + dFrom.ToString() + "', DATE_TO='" + dTo.ToString() + "' " +
                      "WHERE LOCKER_ID=" + recordID;
            sQuery += " COMMIT";

            logHandle myLog = new logHandle();

            if (myLog.doQuery(sQuery))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int iType, iAccess;

            iType   = cmbType.SelectedIndex;
            iAccess = cmbAccess.SelectedIndex;

            bool result = true;

            if (iType == 0)
            {
                if ((edtCellPhone.TextLength != 10) && (edtEmail.TextLength < 3))
                {
                    MessageBox.Show("System user requires a valid cellphone number or email address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
            }
            else if (iType == 1)
            {
                if ((edtStudentNmr.TextLength < 7) && (edtPersonalNumber.TextLength < 7) && (edtIDNumber.TextLength != 13))
                {
                    MessageBox.Show("Lab user requires either a valid student number, personal number or ID number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
            }
            else if (iType == 2)
            {
                if (((edtStudentNmr.TextLength < 7) && (edtPersonalNumber.TextLength < 7) && (edtIDNumber.TextLength != 13)) && ((edtCellPhone.TextLength != 10) && (edtEmail.TextLength < 3)))
                {
                    MessageBox.Show("System user requires a valid cellphone number or email address\nLab user requires either a valid student number, personal number or ID number\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result = false;
                }
            }

            if (result == true && validateForm() == true)
            {
                //CHECK IF USERNAME EXISTS
                bb_userTableAdapter1.FillByUserName(bblabsDataSet1.bb_user, edtUsername.Text);
                if (bblabsDataSet1.bb_user.Rows.Count < 1)
                {
                    //DO THIS
                    String querytString = "INSERT INTO contact (STUDENT_NUMBER,PERSONAL_NUMBER,ID_NUMBER,CELL_PHONE,EMAIL,TEL_NUMBER,ADDRESS) VALUES " +
                                          "('" + edtStudentNmr.Text + "', '" + edtPersonalNumber.Text + "','" + edtIDNumber.Text + "','" + edtCellPhone.Text + "','" + edtEmail.Text + "','" + edtTel.Text + "','" + edtAddress.Text + "')";
                    if (myLogHangle.doQuery(querytString))
                    {
                        querytString = "INSERT INTO bb_user (USERNAME, PASSWORD, ACCESS_LEVEL, TYPE, NAME, SURNAME, STATUS) VALUES " +
                                       "('" + edtUsername.Text + "', '" + edtPassword.Text + "', " + (iAccess + 1) + ", " + (iType + 1) + ", '" + edtName.Text + "', '" + edtSurname.Text + "', 1)";
                        if (myLogHangle.doQuery(querytString))
                        {
                            MessageBox.Show("Successfully added user", "Added User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            myLogHangle.insertChange(AdminID, "Added user: "******"Fatal error please check XXXX", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Could not add user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    lbl0.Visible = true;
                    MessageBox.Show("That username exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public void backupDatabase()
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Title            = "Backup Database";
            dlg.Filter           = "Backup File (*.bak)|*.bak";
            dlg.InitialDirectory = Application.StartupPath;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string s   = dlg.FileName;
                string qry = "BACKUP DATABASE BBLABS " +
                             @"TO DISK = '" + s + "'" +
                             " WITH FORMAT, " +
                             "MEDIANAME = 'BBLABS', " +
                             "NAME = 'Full Backup of AdventureWorks2008R2' ";
                Cursor.Current = Cursors.Default;
                if (myLogHangle.doQuery(qry))
                {
                    MessageBox.Show("Backup is complete");
                }
            }
        }