Example #1
0
        private void ManageUsers_Load(object sender, EventArgs e)
        {
            dc = new DataCon();
            String defQuery = "SELECT * FROM users";

            fillGrid(defQuery);
        }
Example #2
0
        private void metroButton3_Click(object sender, EventArgs e)
        {
            if (!((DateTime.Compare(Convert.ToDateTime(metroDateTime1.Text), DateTime.Now) < 0) || (String.IsNullOrEmpty(metroTextBox2.Text) || (String.IsNullOrEmpty(metroTextBox13.Text) || (String.IsNullOrEmpty(metroTextBox3.Text))))))
            {
                String        fd  = metroDateTime1.Value.ToString("yyyy-MM-dd");
                DataCon       dc1 = new DataCon();
                SqlDataReader dr  = dc1.execSelect("SELECT staff_id from users where access_level like '" + metroTextBox13.Text + "'");
                List <String> rec = new List <string>();
                try
                {
                    while (dr.Read())
                    {
                        rec.Add((String)dr[0]);
                        //MessageBox.Show("Read :Line");
                    }
                }catch (Exception ex2) {
                    MessageBox.Show(ex2.Message);
                }

                dc1.closeCon();

                for (int i = 0; i < rec.Count; i++)
                {
                    String command = "INSERT INTO notification VALUES ('" + fd + "',GETDATE(), '" + metroTextBox2.Text + "','" + metroTextBox3.Text + "','" + rec[i] + "')";
                    new DataCon().execInsert(command);
                    MessageBox.Show("Added");
                    fillGrid("SELECT * FROM notification", 1, 1);
                }
            }
            else
            {
                MessageBox.Show("Empty or Invalid fields. Please Correct and try again!");
            }
        }
Example #3
0
 private void metroGrid1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (metroGrid1.Columns[e.ColumnIndex].Name == "deleteUsr")
     {
         String  username = metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString();
         DataCon d2       = new DataCon();
         String  query    = "delete from users where username like '" + username + "'";
         d2.execInsert(query);
     }
 }
Example #4
0
        private void Communication_Load(object sender, EventArgs e)
        {
            dc = new DataCon();
            metroTabControl2.SelectedTab = tabPage4;
            String query  = "SELECT * FROM notification";
            String query2 = "SELECT * FROM email";

            fillGrid(query, 1);
            fillGrid(query2, 2);
        }
Example #5
0
        void dispTableLog(String query)
        {
            DataCon dc = new DataCon();

            SqlDataAdapter da = dc.selectTable(query);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            metroGrid2.DataSource = dt;
        }
Example #6
0
        private void metroButton5_Click(object sender, EventArgs e)
        {
            String  command = "RESTORE DATABASE bisdb FROM DISK ='" + metroTextBox1.Text + "' WITH REPLACE";
            DataCon dc4     = new DataCon();

            dc4.openCon();
            SqlCommand cmd = new SqlCommand(command, dc4.getCon());

            dc4.closeCon();
            dc4.dispCon();
            MessageBox.Show("SuccessFully Restored");
        }
Example #7
0
 private void metroGrid2_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (metroGrid2.Columns[e.ColumnIndex].Name == "deleteUsr")
     {
         String  nid1  = metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString();
         int     id    = System.Convert.ToInt32(nid1);
         DataCon d2    = new DataCon();
         String  query = "delete from email where nid like '" + id + "'";
         d2.execInsert(query);
         String query2 = "SELECT * FROM email";
         fillGrid(query2, 2, 2);
     }
 }
Example #8
0
 private void metroButton4_Click(object sender, EventArgs e)
 {
     if (!((String.IsNullOrEmpty(metroTextBox2.Text)) || (String.IsNullOrEmpty(metroTextBox3.Text)) || (String.IsNullOrEmpty(metroTextBox4.Text)) || (String.IsNullOrEmpty(metroTextBox5.Text))))
     {
         DataCon d3      = new DataCon();
         String  command = "UPDATE users set password = '******', access_level = '" + metroTextBox5.Text + "', staff_id = '" + metroTextBox4.Text + "' where username like '" + metroTextBox2.Text + "'";
         d3.execInsert(command);
         fillGrid("SELECT * FROM users");
     }
     else
     {
         MessageBox.Show("One or More fields left empty. Please enter and try again!");
     }
 }
Example #9
0
 private void metroButton2_Click(object sender, EventArgs e)
 {
     if (!((String.IsNullOrEmpty(metroTextBox2.Text) || (String.IsNullOrEmpty(metroTextBox3.Text)) || (String.IsNullOrEmpty(metroTextBox4.Text) || (String.IsNullOrEmpty(metroTextBox5.Text))))))
     {
         DataCon dc2     = new DataCon();
         String  command = "INSERT INTO users VALUES('" + metroTextBox2.Text + "', '" + Security.Encript(metroTextBox3.Text) + "', '" + metroTextBox5.Text + "',NULL, '" + metroTextBox4.Text + "');";
         dc2.execInsert(command);
         fillGrid("SELECT * FROM users");
     }
     else
     {
         MessageBox.Show("One or more fields are left empty. Please enter and try again!");
     }
 }
Example #10
0
 private void metroGrid1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (metroGrid1.Columns[e.ColumnIndex].Name == "deleteUsr")
     {
         String nid1 = metroGrid1.Rows[e.RowIndex].Cells[0].Value.ToString();
         int    nid  = 0;
         try
         {
             nid = System.Convert.ToInt32(nid1);
         }catch (Exception e0) {
             MessageBox.Show(e0.Message);
         }
         DataCon d2    = new DataCon();
         String  query = "delete from notification where nid like '" + nid + "'";
         d2.execInsert(query);
         String query2 = "SELECT * FROM notification";
         fillGrid(query2, 1, 2);
     }
 }
Example #11
0
        private void metroButton12_Click(object sender, EventArgs e)
        {
            if (!((DateTime.Compare(Convert.ToDateTime(metroDateTime1.Text), DateTime.Now) < 0) || (String.IsNullOrEmpty(metroTextBox2.Text) || (String.IsNullOrEmpty(metroTextBox13.Text) || (String.IsNullOrEmpty(metroTextBox3.Text) || (String.IsNullOrEmpty(metroTextBox12.Text)))))))
            {
                String  fd = metroDateTime1.Value.ToString("yyyy-MM-dd");
                DataCon d3 = new DataCon();

                DataCon       dc1 = new DataCon();
                SqlDataReader dr  = dc1.execSelect("SELECT staff_id from users where access_level like '" + metroTextBox13.Text + "'");
                List <String> rec = new List <string>();
                try
                {
                    while (dr.Read())
                    {
                        rec.Add((String)dr[0]);
                        // MessageBox.Show("Read :Line");
                    }
                }
                catch (Exception ex2)
                {
                    MessageBox.Show(ex2.Message);
                }

                dc1.closeCon();

                for (int i = 0; i < rec.Count; i++)
                {
                    String command = "UPDATE notification set date = '" + fd + "', subject = '" + metroTextBox2.Text + "', message = '" + metroTextBox3.Text + "', staff_id = '" + rec[i] + "' WHERE nid = '" + System.Convert.ToInt32(metroTextBox12.Text) + "'";
                    new DataCon().execInsert(command);
                    MessageBox.Show("Updated");
                }
                fillGrid("SELECT * from notification", 1, 1);
            }
            else
            {
                MessageBox.Show("Invalid or incomplete fields. Please complete and try agian.");
            }
        }
Example #12
0
 private void Form1_Load(object sender, EventArgs e)
 {
     dc = new DataCon();
 }
Example #13
0
 public BackupRestore()
 {
     dc = new DataCon();
     InitializeComponent();
 }