public Boolean insertDepartment(enDepartment enDepartment) { try { str = "INSERT INTO department (name,status)VALUES(@name,@status);"; Dbcmd = db.GetSqlStringCommand(str); db.AddInParameter(Dbcmd, "@name", DbType.String, enDepartment.name); db.AddInParameter(Dbcmd, "@status", DbType.Int32, enDepartment.status); db.ExecuteNonQuery(Dbcmd); return true; } catch (Exception ex) { throw new Exception(ex.Message); } }
public Boolean updateDepartment(enDepartment enDepartment) { try { str = "UPDATE department SET name=@name, status=@status WHERE departmentID=@departmentID;"; Dbcmd = db.GetSqlStringCommand(str); db.AddInParameter(Dbcmd, "@name", DbType.String, enDepartment.name); db.AddInParameter(Dbcmd, "@status", DbType.Int32, enDepartment.status); db.AddInParameter(Dbcmd, "@departmentID", DbType.Int32, enDepartment.departmentID); db.ExecuteNonQuery(Dbcmd); return true; } catch (Exception ex) { throw new Exception(ex.Message); } }