//Add employee private void dataGridView4_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dataGridView4.Rows[0].Cells[0].Value == null || dataGridView4.Rows[0].Cells[1].Value == null || dataGridView4.Rows[0].Cells[2].Value == null || dataGridView4.Rows[0].Cells[3].Value == null || dataGridView4.Rows[0].Cells[4].Value == null || dataGridView4.Rows[0].Cells[5].Value == null || dataGridView4.Rows[0].Cells[6].Value == null || dataGridView4.Rows[0].Cells[7].Value == null) { MessageBox.Show("Each field mandatory!"); } else { if (dataGridView4.Rows[0].Cells[0].Value.ToString() == "delivery boy") { context con = new context(new check_boy()); if (con.my_function(dataGridView4.Rows[0].Cells[1].Value.ToString())) { MessageBox.Show("This employee is exisit !"); } else { dliveryboy d = new dliveryboy(); d.add(dataGridView4.Rows[0].Cells[2].Value.ToString(), int.Parse(dataGridView4.Rows[0].Cells[6].Value.ToString()), dataGridView4.Rows[0].Cells[4].Value.ToString(), dataGridView4.Rows[0].Cells[5].Value.ToString(), dataGridView4.Rows[0].Cells[1].Value.ToString(), double.Parse(dataGridView4.Rows[0].Cells[7].Value.ToString()), dataGridView4.Rows[0].Cells[3].Value.ToString()); MessageBox.Show("added"); dataGridView4.Rows.Clear(); } } } } catch { MessageBox.Show("invalid enter !!"); } }