public bool Delete(employeeBll b) { bool isSuccess = false; try { Connection.Open(); Query = "DELETE FROM Employee WHERE EmpId=@EmpId"; Command = new SqlCommand(Query, Connection); Command.Parameters.AddWithValue("@EmpId", b.EmpId); int rows = Command.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Connection.Close(); } return(isSuccess); }
public bool Update(employeeBll b) { bool isSuccess = false; try { Connection.Open(); Query = "UPDATE Employee SET EmpName=@EmpName, EmpMobile=@EmpMobile, EmpAddress=@EmpAddress, EmpNid=@EmpNid, EmpDesignation=@EmpDesignation, EmpSalary=@EmpSalary WHERE EmpNo=@EmpNo"; Command = new SqlCommand(Query, Connection); Command.Parameters.AddWithValue("@EmpNo", b.EmpNo); Command.Parameters.AddWithValue("@EmpName", b.EmpName); Command.Parameters.AddWithValue("@EmpMobile", b.EmpMobile); Command.Parameters.AddWithValue("@EmpAddress", b.EmpAddress); Command.Parameters.AddWithValue("@EmpNid", b.EmpNid); Command.Parameters.AddWithValue("@EmpDesignation", b.EmpDesignation); Command.Parameters.AddWithValue("@EmpSalary", b.EmpSalary); int rows = Command.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Connection.Close(); } return(isSuccess); }
public bool Insert(employeeBll b) { bool isSuccess = false; try { Connection.Open(); Query = "INSERT INTO Employee(EmpNo,EmpName, EmpMobile, EmpAddress, EmpNid, EmpDesignation, EmpSalary) VALUES (@EmpNo,@EmpName, @EmpMobile, @EmpAddress, @EmpNid, @EmpDesignation, @EmpSalary)"; Command = new SqlCommand(Query, Connection); Command.Parameters.AddWithValue("@EmpNo", b.EmpNo); Command.Parameters.AddWithValue("@EmpName", b.EmpName); Command.Parameters.AddWithValue("@EmpMobile", b.EmpMobile); Command.Parameters.AddWithValue("@EmpAddress", b.EmpAddress); Command.Parameters.AddWithValue("@EmpNid", b.EmpNid); Command.Parameters.AddWithValue("@EmpDesignation", b.EmpDesignation); Command.Parameters.AddWithValue("@EmpSalary", b.EmpSalary); int rows = Command.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { Connection.Close(); } return(isSuccess); }