Esempio n. 1
0
 private void LoadPresence(DateTime d, Employe e)
 {
     object_statut.SetValueBar(0);
     Constantes.PBAR_WAIT = pbar_statut;
     position             = 0;
     try
     {
         string query      = "select p.* from yvs_grh_presence p inner join yvs_grh_employes e on p.employe = e.id inner join yvs_agences a on e.agence = a.id where a.societe = " + Constantes.SOCIETE.Id + " and p.date_debut = '" + d.ToShortDateString() + "' order by e.nom, e.prenom, p.heure_debut";
         string queryCount = "select count(p.id) from yvs_grh_presence p inner join yvs_grh_employes e on p.employe = e.id inner join yvs_agences a on e.agence = a.id where a.societe = " + Constantes.SOCIETE.Id + " and p.date_debut = '" + d.ToShortDateString() + "'";
         if (e != null ? e.Id > 0 : false)
         {
             query      = "select p.* from yvs_grh_presence p where p.employe = " + e.Id + " and p.date_debut = '" + d.ToShortDateString() + "' order by heure_debut";
             queryCount = "select count(p.id) from yvs_grh_presence p where p.employe = " + e.Id + " and p.date_debut = '" + d.ToShortDateString() + "'";
         }
         presences = PresenceBLL.List(query, true, queryCount, Constantes.SOCIETE.AdresseIp);
         if (presences != null ? presences.Count > 0 : false)
         {
             LoadOnView(presences[0]);
         }
         else
         {
             ResetFiche();
             if (e != null ? e.Id > 0 : false)
             {
                 Utils.WriteLog(e.NomPrenom + " n'a pas de fiche de présence pour la date du " + dtp_date.Value.ToShortDateString());
             }
         }
     }
     catch (Exception ex)
     {
         Messages.Exception("Form_Presence (LoadPresence)", ex);
     }
 }
Esempio n. 2
0
 private void fusionnerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (position > -1)
     {
         Presence presence = presences[position];
         presence.Pointages = pointages;
         if (presence != null ? presence.Id > 0 : false)
         {
             string          adresse = Constantes.SOCIETE.AdresseIp;
             List <Presence> list    = PresenceBLL.List("select p.* from yvs_grh_presence p where p.employe = " + presence.Employe.Id + " and p.date_debut = '" + dtp_date.Value + "' order by heure_debut", true, adresse);
             if (list != null ? list.Count > 1 : false)
             {
                 foreach (Presence p in list)
                 {
                     if (p.Id != presence.Id)
                     {
                         presence.Pointages.AddRange(PointageBLL.List("select * from yvs_grh_pointage where presence = " + p.Id, true, adresse));
                         Bll.RequeteLibre("delete from yvs_grh_presence where id = " + p.Id, adresse);
                         presences.Remove(p);
                         lb_pagination.Text = (position + 1) + "/" + presences.Count;
                         txt_index_of.Text  = (position + 1).ToString();
                     }
                 }
             }
             ReorganiserFiche(presence);
         }
     }
 }
        private void Dial_View_No_Insert_Load(object sender, EventArgs e)
        {
            if (current.iCorrect)
            {
                this.Dispose();
                return;
            }
            string adresse = Constantes.SOCIETE.AdresseIp;
            //Recherche des fiches dont l'heure definie à deja été inserée
            DateTime time  = new DateTime(current.idwYear, current.idwMonth, current.idwDay, current.idwHour, current.idwMinute, 0);
            string   query = "select r.* from yvs_grh_pointage p inner join yvs_grh_presence r on p.presence = r.id where r.employe = " + employe.Id + " and ((heure_entree is not null and heure_entree = '" + time + "') or (heure_sortie is not null and heure_sortie = '" + time + "'))";

            presences = PresenceBLL.List(query, true, adresse);
            if (presences != null ? presences.Count > 0 : false)
            {
                foreach (Presence p in presences)
                {
                    object[] value = new object[] { p.Id, p.Employe.NomPrenom, p.DateDebut.ToShortDateString() + " à " + p.HeureDebut.ToShortTimeString(), p.DateFin.ToShortDateString() + " à " + p.HeureFin.ToShortTimeString(), p.DateFinPrevu.ToShortDateString(), p.HeureFinPrevu.ToShortTimeString(), p.Valider };
                    object_presence.WriteDataGridView(value);
                }
                lb_statut.Text = "Ce pointage à deja été inseré";
            }
            else
            {
                //Recherche des fiches dont l'heure definie se trouve dans une fiche validée
                query     = "select * from yvs_grh_presence where employe = " + employe.Id + " and '" + current.CurrentDateTime + "' between date_debut and date_fin and valider is true";
                presences = PresenceBLL.List(query, true, adresse);
                if (presences != null ? presences.Count > 0 : false)
                {
                    foreach (Presence p in presences)
                    {
                        object[] value = new object[] { p.Id, p.Employe.NomPrenom, p.DateDebut.ToShortDateString() + " à " + p.HeureDebut.ToShortTimeString(), p.DateFin.ToShortDateString() + " à " + p.HeureFin.ToShortTimeString(), p.DateFinPrevu.ToShortDateString(), p.HeureFinPrevu.ToShortTimeString(), p.Valider };
                        object_presence.WriteDataGridView(value);
                    }
                    lb_statut.Text = "Ce pointage se trouve dans une fiche validée";
                }
                else
                {
                    //Recherche des fiches dont l'heure definie se trouve entre la date debut et la date de fin prevu
                    query     = "select * from yvs_grh_presence where employe = " + employe.Id + " and '" + current.CurrentDateTime + "' between date_debut and date_fin_prevu";
                    presences = PresenceBLL.List(query, true, adresse);
                    if (presences != null ? presences.Count > 0 : false)
                    {
                        foreach (Presence p in presences)
                        {
                            object[] value = new object[] { p.Id, p.Employe.NomPrenom, p.DateDebut.ToShortDateString() + " à " + p.HeureDebut.ToShortTimeString(), p.DateFin.ToShortDateString() + " à " + p.HeureFin.ToShortTimeString(), p.DateFinPrevu.ToShortDateString(), p.HeureFinPrevu.ToShortTimeString(), p.Valider };
                            object_presence.WriteDataGridView(value);
                        }
                        lb_statut.Text = "Ce pointage se trouve entre la date debut et la date de fin prevu d'une fiche déjà validée";
                    }
                }
            }
            if (presences != null ? presences.Count > 0 && presences.Count < 2 : false)
            {
                loadPointage(presences[0], adresse);
            }
        }