1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
public ActionResult DetailEquipe()
{
string id_equipe="";
string path = HttpContext.Request.Url.AbsolutePath;
//string id = path.Substring(path.LastIndexOf("/"));
string id = System.IO.Path.GetFileName(path);
ViewBag.ID = id;
List<EquipePersonnel> EquipePersonnel = new List<EquipePersonnel>();
try
{
using (var connection = new QC.SqlConnection(
"Server =connection serv"
))
{
connection.Open();
Console.WriteLine("Connected successfully.");
using (var command = new QC.SqlCommand())
{
command.Connection = connection;
command.CommandType = DT.CommandType.Text;
command.CommandText = @"Select * from Equipe where Id='" + id + "'";
QC.SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
EquipePersonnel c = new EquipePersonnel();
c.equipe_nom_equipe = reader["equipe_nom_equipe"] as String;
c.equipe_id = reader["equipe_id"] as int? ?? 0;
//id_equipe=c.idEquipe = reader["Id"] as String;
c.Id_chantier = reader["Id_chantier"] as String;
c.equipe_id_chef_chantier = reader["equipe_id_chef_chantier"] as int? ?? 0;
c.equipe_statut = reader["equipe_statut"] as String;
c.equipe_date_ouverture = reader["equipe_date_ouverture"] as String;
c.equipe_date_fermeture = reader["equipe_date_fermeture"] as String;
using (var command2 = new QC.SqlCommand())
{
command.Connection = connection;
command.CommandType = DT.CommandType.Text;
command.CommandText = @"Select * from Personnel where Pers_ID_equipe ='" + id_equipe + "'";
QC.SqlDataReader reader2 = command.ExecuteReader();
while (reader2.Read())
{
c.Idpersonnel = reader2["Id"] as String;
c.Pers_Nom = reader2["Pers_Nom"] as String;
c.Pers_Prenom = reader2["Pers_Prenom"] as String;
c.Pers_Conducteur = reader2["Pers_Conducteur"] as bool? ?? false;
c.Pers_Chef_chantier = reader2["Chef_chantier"] as bool? ?? false;
c.Pers_Chef_equipe = reader2["Pers_chef_equipe"] as bool? ?? false;
c.Pers_ID_equipe = reader2["Pers_ID_equipe"] as String;
c.Pers_Interimaire = reader2["Pers_Interimaire"] as bool? ?? false;
c.Pers_Matricule = reader2["Pers_Matricule"] as String;
c.Pers_Date_Entree = reader2["Pers_Date_Entree"] as String;
c.Pers_statut = reader2["Pers_statut"] as bool? ?? false;
c.Pers_Equipier = reader2["Pers_Equipier"] as String;
// chantier.Add(new Chantier() { name = reader.GetString(0) });
EquipePersonnel.Add(c);
}
}
}
connection.Close();
return View(EquipePersonnel);
}
}
}
catch (Exception ex)
{
ViewBag.Message = "problème connection";
Debug.WriteLine(ex.Message);
return View(EquipePersonnel);
}
} |
Partager