Example #1
0
        public static void UpdateTerritory(Territory territory)
        {
            string sqlQuery = "UPDATE Territory SET ParentTerritoryID=@ParentTerritoryID, FullDescription=@FullDescription, Name=@Name WHERE TerritoryID=" + territory.TerritoryID;

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "ParentTerritoryID", DbType.Int32, territory.ParentTerritoryID);
            db.AddInParameter(dbCommand, "FullDescription", DbType.String, territory.FullDescription);
            db.AddInParameter(dbCommand, "Name", DbType.String, territory.Name);

            db.ExecuteNonQuery(dbCommand);
        }
Example #2
0
        public static Territory InsertTerritory(Territory territory)
        {
            string sqlQuery = "INSERT INTO Territory(ParentTerritoryID,FullDescription,Name) " +
                " VALUES(@ParentTerritoryID,@FullDescription,@Name);SELECT @@Identity";

            Database db = new SqlDatabase(DBHelper.GetConnectionString());
            DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery);
            db.AddInParameter(dbCommand, "ParentTerritoryID", DbType.Int32, territory.ParentTerritoryID);
            db.AddInParameter(dbCommand, "FullDescription", DbType.String, territory.FullDescription);
            db.AddInParameter(dbCommand, "Name", DbType.String, territory.Name);

            territory.TerritoryID = Convert.ToInt32(db.ExecuteScalar(dbCommand));

            return territory;
        }
Example #3
0
 public static void UpdateTerritory(Territory territory)
 {
     TerritoryDB.UpdateTerritory(territory);
 }
Example #4
0
 public static Territory InsertTerritory(Territory territory)
 {
     return TerritoryDB.InsertTerritory(territory);
 }
Example #5
0
 private static Territory GetTerritoryFromReader(IDataReader dataReader)
 {
     Territory territory = new Territory();
     territory.TerritoryID = DBHelper.GetInt(dataReader, "TerritoryID");
     territory.ParentTerritoryID = DBHelper.GetInt(dataReader, "ParentTerritoryID");
     territory.Name = DBHelper.GetString(dataReader, "Name");
     territory.FullDescription = DBHelper.GetString(dataReader, "FullDescription");
     return territory;
 }