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
| DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
dt.Columns.Add("AgentMatricule", typeof(string));
dt.Columns.Add("Photo", typeof(string));
dt.Columns.Add("nom", typeof(string));
dt.Columns.Add("Prenom", typeof(string));
dt.Columns.Add("DateNaissanceAgent", typeof(DateTime));
dt.Columns.Add("LieuNaissanceAgent", typeof(string));
dt.Columns.Add("DateEmbauche", typeof(DateTime));
dt.Columns.Add("SexeAgent", typeof(string));
dt.Columns.Add("AncienneteAgent", typeof(int));
dt.Columns.Add("AgentEquipe", typeof(string));
dt.Columns.Add("TelephoneAgent", typeof(string));
dt.Columns.Add("EmailAgent", typeof(string));
foreach (var item in result)
{
dr["AgentMatricule"] = string.IsNullOrEmpty(item.AgentMatricule) ? default(string) : item.AgentMatricule;
dr["Photo"] = string.IsNullOrEmpty(item.Photo)? default(string):item.Photo;
dr["nom"] = string.IsNullOrEmpty(item.Nom) ? default(string):item.Nom;
dr["prenom"] = string.IsNullOrEmpty(item.Prenom) ? default(string) :item.Prenom;
dr["DateNaissanceAgent"] = string.IsNullOrEmpty(item.DateNaissanceAgent.ToString()) ? default(DateTime):item.DateNaissanceAgent;
dr["LieuNaissanceAgent"] = string.IsNullOrEmpty(item.Prenom) ? default(string): item.LieuNaissanceAgent;
dr["DateEmbauche"] = string.IsNullOrEmpty(item.DateEmbauche.ToString()) ? default(DateTime) : item.DateEmbauche;
dr["SexeAgent"] = string.IsNullOrEmpty(item.SexeAgent) ? default(string) : item.SexeAgent;
dr["AncienneteAgent"] = string.IsNullOrEmpty(item.AncienneteAgent.ToString()) ? default(Int32) :item.AncienneteAgent ;
dr["AgentEquipe"] = string.IsNullOrEmpty(item.AgentEquipe) ? default(string) : item.AgentEquipe ;
dr["TelephoneAgent"] = string.IsNullOrEmpty(item.TelephoneAgent) ? default(string) : item.TelephoneAgent;
dr["EmailAgent"] = string.IsNullOrEmpty(item.EmailAgent) ? default(string) : item.EmailAgent;
dt.Rows.Add(dr);
}
reportDocument = new ReportDocument();
reportDocument.Load(Server.MapPath("~/App_Data/EtatFicheAgs.rpt"));
reportDocument.SetDataSource(dt);
CrViewer.ReportSource = reportDocument;
CrViewer.RefreshReport();
CrViewer.Zoom(85); |
Partager