private void Form1_Load(object sender, EventArgs e) { sql s = new sql(this); s.loademployees(); s.loadviolationtb(); s.loadviolators(); }
private void metroTextButton5_Click(object sender, EventArgs e) { sql s = new sql(this); if (points.Text == "") { points.Text = "0"; } s.addviolation(); s.loadviolationtb(); }
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(); }
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(); }
private void metroTextButton6_Click(object sender, EventArgs e) { sql s = new sql(this); s.loadviolationtb(); }