public string UpdateEmpDetails(EmpDetails eDetails) //For Update Purpose { string Status; SqlCommand cmd = new SqlCommand("USP_Emp_Update", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", eDetails.Id); cmd.Parameters.AddWithValue("@Name", eDetails.Name); cmd.Parameters.AddWithValue("@Salary", eDetails.Salary); cmd.Parameters.AddWithValue("@DeptId", eDetails.DeptId); if (con.State == ConnectionState.Closed) { con.Open(); } int result = cmd.ExecuteNonQuery(); if (result == 1) { Status = "Record Is Updated successfully"; } else { Status = "Record could not be updated"; } con.Close(); return(Status); }
public string InsertEmpDetails(EmpDetails eDetails) //For Insert Purpose { string Status; SqlCommand cmd = new SqlCommand("USP_Emp_Insert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", eDetails.Name); cmd.Parameters.AddWithValue("@Salary", eDetails.Salary); cmd.Parameters.AddWithValue("@DeptId", eDetails.DeptId); if (con.State == ConnectionState.Closed) { con.Open(); } int result = cmd.ExecuteNonQuery(); if (result == 1) { Status = eDetails.Name + " " + eDetails.Salary + " Is Registered Successfully"; } else { Status = eDetails.Name + " " + eDetails.Salary + " could not be registered"; } con.Close(); return(Status); }
public bool DeleteEmpDetails(EmpDetails eDetails) //For Delete Purpose { SqlCommand cmd = new SqlCommand("USP_Emp_Delete", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", eDetails.Id); if (con.State == ConnectionState.Closed) { con.Open(); } cmd.ExecuteNonQuery(); con.Close(); return(true); }
public DataSet FetchUpdatedRecords(EmpDetails eDetails) //For update details Purpose { SqlCommand cmd = new SqlCommand("Get_AllEmployees", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", eDetails.Id); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); cmd.ExecuteNonQuery(); con.Close(); return(ds); }