private void empaddBTN_Click(object sender, EventArgs e) { sql s = new sql(this); s.addemp(); s.loademployees(); }
private void Form1_Load(object sender, EventArgs e) { sql s = new sql(this); s.loademployees(); s.loadviolationtb(); s.loadviolators(); }
private void metroTextButton1_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection selecteditems = empGRID.SelectedRows; ArrayList x = new ArrayList(selecteditems.Count); foreach (DataGridViewRow selecteditem in selecteditems) { x.Add(selecteditem.Cells["id"].Value.ToString()); } sql s = new sql(this); foreach (string i in x) { string id = i; string query = ""; if (kryptonCheckBox1.Checked == true) { sql.sqlcon.Open(); string find = "select * from employeetb where employee = '" + empname.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, "Employee already exist! Data not saved", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { read.Close(); sql.sqlcon.Close(); query = "update employeetb set employee = '" + empname.Text + "' where id = '" + id + "'"; s.updateemp(query); } } else { } if (kryptonCheckBox2.Checked == true) { query = "update employeetb set department = '" + department.Text + "' where id = '" + id + "'"; s.updateemp(query); } else { } } s.loademployees(); kryptonCheckBox1.Checked = false; kryptonCheckBox2.Checked = false; }
private void metroTextButton2_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, "Do you want to delete this record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } DataGridViewSelectedRowCollection selecteditems = empGRID.SelectedRows; ArrayList list = new ArrayList(selecteditems.Count); foreach (DataGridViewRow x in selecteditems) { list.Add(x.Cells["id"].Value.ToString()); } sql s = new sql(this); foreach (string x in list) { string query = "delete from employeetb where id = '" + x + "'"; s.deleteemp(query); } s.loademployees(); }
private void refreshBTN_Click(object sender, EventArgs e) { sql s = new sql(this); s.loademployees(); }