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 static object[] RechercherAgentsAbcence(string aAgentMatricule, string aNomPrenom,string aEquipe,string aIdentifiantAbcence, string aTypeAbcence, DateTime aDebutPeriode,
DateTime aFinPeriode)
{
var q = (from oAgsAbcent in ContexteDAO.ContexteDonnees.AgentsAbscences
join oAgent in ContexteDAO.ContexteDonnees.Agents on
oAgsAbcent.Agents_Matricule equals oAgent.AgentMatricule
join oAbcence in ContexteDAO.ContexteDonnees.Abscences
on oAgsAbcent.IdentifiantAbscence equals oAbcence.IdentifiantAbscence
select new
{
oAgent.AgentMatricule,
oAgent.Nom,
oAgent.Prenom,
oAgent.Photo,
oAgent.AgentEquipe,
oAbcence.IdentifiantAbscence,
oAbcence.TypeAbscence,
oAbcence.MotifsAbscence,
oAbcence.DebutAbscence,
oAbcence.DureeAbscence
});
if (!string.IsNullOrEmpty(aAgentMatricule))
{
q = q.Where(a => a.AgentMatricule.Contains(aAgentMatricule));
}
if (!string.IsNullOrEmpty(aNomPrenom))
{
q = q.Where(a => a.Nom.Contains(aNomPrenom));
}
if (string.IsNullOrWhiteSpace(aEquipe))
{
q = q.Where(a => a.AgentEquipe.Contains(aEquipe));
}
if (!string.IsNullOrEmpty(aEquipe))
{
q = q.Where(a => a.AgentEquipe.Contains(aEquipe));
}
if (!string.IsNullOrEmpty(aIdentifiantAbcence))
{
q = q.Where(a => a.IdentifiantAbscence.Contains(aIdentifiantAbcence));
}
if (!string.IsNullOrEmpty(aTypeAbcence))
{
q = q.Where(a => a.TypeAbscence.Contains(aTypeAbcence));
}
if (aDebutPeriode < DateTime.MaxValue)
{
q = q.Where(a => a.DebutAbscence <= aDebutPeriode);
}
if (DateTime.MaxValue > aFinPeriode)
{
if (aTypeAbcence == "AHI")
{
q = q.Where(a => (a.DebutAbscence.AddHours(Convert.ToDouble(a.DureeAbscence))) <= aFinPeriode);
}
else if (aTypeAbcence == "")
{
//nothing to do
}
else
{
q = q.Where(a => (a.DebutAbscence.AddDays(Convert.ToDouble(a.DureeAbscence))) <= aFinPeriode);
}
}
return q.ToArray();
} |
Partager