There is no error in the code but no data is inserted in the database
follwing is the code of each layer
User Layer :
private void btnSave_Click(object sender, EventArgs e)
{
EmpProps p = new EmpProps();
p.Code1 = Convert.ToInt32(tfId.Text);
p.Name1 = tfName.Text;
p.Cell1 = tfCell.Text;
p.Adrs1 = tfAdrs.Text;
p.Dept1 = cmbDept.Text;
EmpBll eb = new EmpBll();
bool b =eb.InsertEmpBll(p);
if(b)
{ MessageBox.Show("Saved successfully");
}
else
{ MessageBox.Show("Error Ocurred");
}
}
Logic Layer :
public class EmpBll
{
public bool InsertEmpBll(EmpProps p)
{
EmpDal empdal = new EmpDal();
bool b =empdal.InsrtEmpDal(p);
if (b)
return true;
else
return false;
}
}
Data Access layer :
public class EmpDal
{
public bool InsrtEmpDal(EmpProps p)
{
SqlConnection conn = new SqlConnection("Data Source=DASTGIRKHAN\\SQLEXPRESS;Initial Catalog=MultilayerManagementSystem;Integrated Security=True;Pooling=False");
SqlCommand cmd = new SqlCommand("Insert INTO EmployeeRecord Values(" + p.Code1.GetType() + ",'" +p.Name1 + "','" + p.Cell1 + "','" +p.Adrs1 + "','" + p.Dept1 + "')", conn);
conn.Open();
int c= cmd.ExecuteNonQuery();
conn.Close();
if (c > 0)
return true;
else
return false;
}
}