I DEVELOP A SOFTWARE ON VISUAL STUDIO (C #) "EMPLOYEE INFROMATION SYSTEM",
WHEN I ENTERED A RECORD IN SOFTWARE, IT ADDED,
BUT WHEN I ADDED A RECORD HAVING EMPTY FIELDS
IT SHOWS RECORD DOES NOT ADDED BECAUSE FIELDS ARE EMPTY,
BUT IN DATA BASE RECORD WILL SAVE HAVING EMPTY FIELDS, WHY?
ANY BUDY HELP ME...!
THE CODE IS THAT:
==>
private void button1_Click(object sender, EventArgs e)
{
try
{
Department obj = new Department();
obj.DeptName = textBox1.Text;
obj.Description = textBox2.Text;
DepartmentDAL obj2 = new DepartmentDAL();
obj2.addDepartment(obj);
if (textBox1.Text != "" && textBox2.Text != "")
{
MessageBox.Show("Record Saved Successfully !", "Employee Information System");
clear();
}
else { MessageBox.Show("Error : Field's Empty \n\nEnter The Record To Save !", "Employee Information System"); }
}
catch { MessageBox.Show("Error : Field's Empty \n\nEnter The Record To Save !", "Employee Information System"); }
}

Rahul PrajapatRank #1,209 · 1.5K reputationPosted Jun 27, 2015, 4:20 PM EDT
Narasimha Reddy ChennupalliRank #1,163 · 1.6K reputationPosted Jun 27, 2015, 10:33 AM EDT
First you need to check empty fields, if fields are not empty then you need to add data in to database. As like below
if (textBox1.Text != "" && textBox2.Text != "")
{
Department obj = new Department();
obj.DeptName = textBox1.Text;
obj.Description = textBox2.Text;
DepartmentDAL obj2 = new DepartmentDAL();
obj2.addDepartment(obj);
MessageBox.Show("Record Saved Successfully !", "Employee Information System");
clear();
}
Munesh SharmaRank #174 · 13.9K reputationPosted Jun 27, 2015, 11:46 PM EDT
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 28, 2015, 1:23 AM EDT