Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            sql s = new sql(this);

            s.loademployees();
            s.loadviolationtb();
            s.loadviolators();
        }
Exemple #2
0
        private void metroTextButton5_Click(object sender, EventArgs e)
        {
            sql s = new sql(this);

            if (points.Text == "")
            {
                points.Text = "0";
            }
            s.addviolation();
            s.loadviolationtb();
        }
Exemple #3
0
        private void metroTextButton4_Click(object sender, EventArgs e)
        {
            if (points.Text == "")
            {
                points.Text = "0";
            }
            DataGridViewSelectedRowCollection selecteditems = violationGrid.SelectedRows;
            ArrayList list = new ArrayList(selecteditems.Count);

            foreach (DataGridViewRow selecteditem in selecteditems)
            {
                list.Add(selecteditem.Cells["id"].Value.ToString());
            }
            sql s = new sql(this);

            foreach (string x in list)
            {
                if (kryptonCheckBox3.Checked == true)
                {
                    sql.sqlcon.Open();
                    string     find   = "select * from violationtb where violation = '" + violation.Text + "'";
                    SqlCommand sqlcmd = new SqlCommand();
                    sqlcmd = new SqlCommand(find, sql.sqlcon);
                    SqlDataReader read = sqlcmd.ExecuteReader();
                    if (read.HasRows == true)
                    {
                        read.Close();
                        sql.sqlcon.Close();
                        MetroMessageBox.Show(this, "Violation already exist! Data not saved", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        read.Close();
                        sql.sqlcon.Close();
                        string str = "update violationtb set violation = '" + violation.Text + "' where id = '" + x + "'";
                        s.updateviolation(str);
                    }
                }
                else
                {
                }
                if (kryptonCheckBox4.Checked == true)
                {
                    string str = "update violationtb set points = '" + points.Text + "' where id = '" + x + "'";
                    s.updateviolation(str);
                }
                else
                {
                }
            }
            kryptonCheckBox3.Checked = false;
            kryptonCheckBox4.Checked = false;
            s.loadviolationtb();
        }
Exemple #4
0
        private void metroTextButton3_Click(object sender, EventArgs e)
        {
            if (MetroMessageBox.Show(this, "Do you want to delete selected rows?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            DataGridViewSelectedRowCollection selecteditems = violationGrid.SelectedRows;
            ArrayList list = new ArrayList(selecteditems.Count);

            foreach (DataGridViewRow selecteditem in selecteditems)
            {
                list.Add(selecteditem.Cells["id"].Value.ToString());
            }
            sql s = new sql(this);

            foreach (string x in list)
            {
                s.deleteviolation(x);
            }
            s.loadviolationtb();
        }
Exemple #5
0
        private void metroTextButton6_Click(object sender, EventArgs e)
        {
            sql s = new sql(this);

            s.loadviolationtb();
        }