Commit d51be7df authored by Clément's avatar Clément
Browse files

Few Details

parent 0aa81d7d
......@@ -12,9 +12,9 @@ namespace DataAccessLayer
{
class SqlServer : DataBaseBridge
{
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=H:\\ServiceWeb\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=H:\\ServiceWeb\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\NEBOIT\\Documents\\GitHub\\ServiceWeb\\Database\\db.mdf;Integrated Security=True;Connect Timeout=30";
private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\JULES\\DOCUMENTS\\ISIMA\\2ÈME ANNÉE\\SERVICEWEB\\DATABASE\\DB.MDF;Integrated Security=True;Connect Timeout=30";
//private string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\JULES\\DOCUMENTS\\ISIMA\\2ÈME ANNÉE\\SERVICEWEB\\DATABASE\\DB.MDF;Integrated Security=True;Connect Timeout=30";
private void LogException(Exception e)
{
......@@ -264,7 +264,7 @@ namespace DataAccessLayer
DataRow territoryRow = territoryData.Rows[0];
int id_house = Convert.ToInt32(territoryRow["id_house"]);
House house = getHouseById(id_house);
res = new Territory(Convert.ToInt32(territoryRow["Id"]), (TerritoryType)territoryRow["type"], house);
res = new Territory(Convert.ToInt32(territoryRow["Id"]), (TerritoryType)territoryRow["type"], house, territoryRow["name"].ToString());
}
catch (Exception e)
{
......@@ -308,7 +308,7 @@ namespace DataAccessLayer
{
int id_house = Convert.ToInt32(row["id_house"]);
House owner = getHouseById(id_house);
Territory territory = new Territory(Convert.ToInt32(row["Id"]), (TerritoryType)Convert.ToInt32(row["type"]), owner);
Territory territory = new Territory(Convert.ToInt32(row["Id"]), (TerritoryType)Convert.ToInt32(row["type"]), owner, row["name"].ToString());
res.Add(territory);
}
}
......@@ -398,7 +398,7 @@ namespace DataAccessLayer
}
public int addTerritory(Territory territory)
{
DataTable territoryData = SelectByDataAdapter("INSERT INTO Territory VALUES(" + (int)territory.Type + "," + territory.Owner.ID + "); SELECT SCOPE_IDENTITY() AS ID");
DataTable territoryData = SelectByDataAdapter("INSERT INTO Territory VALUES(" + (int)territory.Type + "," + territory.Owner.ID + ",'" + territory.Name + "'); SELECT SCOPE_IDENTITY() AS ID");
return (territoryData.Rows.Count == 1) ? Convert.ToInt32(territoryData.Rows[0]["ID"]) : -1;
}
......@@ -415,6 +415,7 @@ namespace DataAccessLayer
{
dataTable.Rows[0]["type"] = territory.Type;
dataTable.Rows[0]["id_house"] = territory.Owner.ID;
dataTable.Rows[0]["name"] = territory.Name;
UpdateByCommandBuilder(request, dataTable);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment