Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["fonction"] == null)
        {
            Response.Redirect("index.aspx");
        }

        idEmp = Request.QueryString["id"];
        emp   = BD_CoEco.GetEmpByID(int.Parse(idEmp));

        if (emp.congesFeries != null)
        {
            tb_congesFeries.Text = emp.congesFeries.ToString();
        }
        if (emp.congesMaladie != null)
        {
            tb_congesMaladie.Text = emp.congesMaladie.ToString();
        }
        if (emp.congesPersonnels != null)
        {
            tb_congesPersonnels.Text = emp.congesPersonnels.ToString();
        }
        if (emp.heuresAccumuleesOuSansSolde != null)
        {
            tb_heuresAccumuleesOuSansSolde.Text = emp.heuresAccumuleesOuSansSolde.ToString();
        }
        if (emp.vacances != null)
        {
            tb_vacances.Text = emp.vacances.ToString();
        }
    }
Exemplo n.º 2
0
    private void loadEmploye()
    {
        ddl_employe.Items.Clear();
        List <T_Employe> listEmp = BD_CoEco.GetListeEmploye(true);
        List <T_Employe> list    = new List <T_Employe>();

        for (int i = 0; i < lst_employeAjouter2.Items.Count; i++)
        {
            list.Add(BD_CoEco.GetEmpByID(int.Parse(lst_employeAjouter2.Items[i].Value)));
        }

        for (int i = 0; i < listEmp.Count; i++)
        {
            for (int e = 0; e < list.Count; e++)
            {
                if (i != listEmp.Count)
                {
                    if (listEmp[i].idEmploye == list[e].idEmploye)
                    {
                        listEmp.RemoveAt(i);
                    }
                }
            }
        }

        listEmp = listEmp.OrderBy(o => o.prenom).ThenBy(o => o.prenom).ToList();
        foreach (T_Employe emp in listEmp)
        {
            ddl_employe.Items.Add(new ListItem(emp.prenom + " " + emp.nom, emp.idEmploye.ToString()));
        }
    }
Exemplo n.º 3
0
    private void loadDllProjet()
    {
        ddl_projet.Items.Clear();
        List <T_Projet> listeProjet = BD_CoEco.GetProjectByEmp(BD_CoEco.GetEmpByID(int.Parse(Session["idEmp"].ToString())));

        listeProjet = listeProjet.OrderBy(o => o.nom).ToList();
        ddl_projet.Items.Add(new ListItem("Choisir un projet", "-1"));
        foreach (T_Projet projet in listeProjet)
        {
            ddl_projet.Items.Add(new ListItem(projet.nom, projet.idProjet.ToString()));
        }
    }
Exemplo n.º 4
0
    private void loadDllProjet()
    {
        ddl_Projet.Items.Clear();
        List <T_Projet> listeProjet = BD_CoEco.GetProjectByEmp(BD_CoEco.GetEmpByID(BD_CoEco.GetFeuilleDeTempsById(idFdt).idEmp));

        listeProjet = listeProjet.OrderBy(o => o.nom).ToList();
        //ddl_Projet.Items.Add(new ListItem("Choisir un projet", "-1"));
        foreach (T_Projet projet in listeProjet)
        {
            ddl_Projet.Items.Add(new ListItem(projet.nom, projet.idProjet.ToString()));
        }
    }
Exemplo n.º 5
0
    protected void btn_lieEmp_Click(object sender, EventArgs e)
    {
        btn_lieEmp.Enabled = true;
        btn_apply.Enabled  = true;
        int empId    = int.Parse(ddl_employe.SelectedValue);
        int indexEmp = ddl_employe.SelectedIndex;

        T_Employe emp = BD_CoEco.GetEmpByID(empId);

        ddl_employe.Items.RemoveAt(indexEmp);
        lst_employeAjouter2.Items.Add(new ListItem(emp.prenom + " " + emp.nom, emp.idEmploye.ToString()));
        btn_modifier.Enabled = false;
    }
Exemplo n.º 6
0
    protected void btn_retirer_Click(object sender, EventArgs e)
    {
        T_Employe employeSelected = new T_Employe();
        int       empId           = int.Parse(lst_employeAjouter.SelectedValue);
        int       indexEmp        = lst_employeAjouter.SelectedIndex;

        lst_employeAjouter.Items.RemoveAt(indexEmp);

        T_Employe empP = BD_CoEco.GetEmpByID(empId);

        retirerEmp(empId);
        btn_modifier.Enabled = false;
    }
Exemplo n.º 7
0
    private void afficherProject()
    {
        listEmp = new List <T_Employe>();

        List <T_Projet>  tousLesProjet = BD_CoEco.GetListeProjet();
        List <T_Employe> tousLesEmp    = new List <T_Employe>();

        foreach (T_Projet projet in tousLesProjet)
        {
            if (projet.idProjet == int.Parse(urlParam))
            {
                tbx_nom.Text    = projet.nom;
                tbx_projet.Text = projet.descript;
                if (projet.responsable != null)
                {
                    if (projet.responsable != -1)
                    {
                        ddl_responsable.SelectedValue = BD_CoEco.GetEmpByID((int)projet.responsable).idEmploye.ToString();
                    }
                    else
                    {
                        ddl_responsable.SelectedValue = "1";
                    }
                }
                tbx_heure.Text = projet.heureAlloue.ToString();
                dateDebut.Text = String.Format("{0:yyyy-MM-dd}", projet.dateDebut);
                dateFin.Text   = String.Format("{0:yyyy-MM-dd}", projet.dateFin);

                ddl_statut.SelectedValue = projet.idStatus.ToString();

                List <T_EmployeProjet> tousLesEmpInPro = BD_CoEco.GetListeEmpPro();

                foreach (T_EmployeProjet empPro in tousLesEmpInPro)
                {
                    if (empPro.idPro == projet.idProjet)
                    {
                        lst_employeAjouter2.Items.Add(new ListItem(BD_CoEco.GetEmpByID(empPro.idEmp).prenom + " " + BD_CoEco.GetEmpByID(empPro.idEmp).nom, BD_CoEco.GetEmpByID(empPro.idEmp).idEmploye.ToString()));

                        T_Employe newEmp = new T_Employe();
                        newEmp.idEmploye = BD_CoEco.GetEmpByID(empPro.idEmp).idEmploye;
                        listEmp.Add(newEmp);
                    }
                }
            }
        }
    }
Exemplo n.º 8
0
    protected void btn_addProject_Click(object sender, EventArgs e)
    {
        T_Projet         monProjet        = new T_Projet();
        List <T_Employe> listeEmpAuProjet = new List <T_Employe>();

        monProjet.nom = tbx_nom.Text;
        if (tbx_projet.Text != "")
        {
            monProjet.descript = tbx_projet.Text;
        }
        monProjet.responsable = int.Parse(ddl_responsable.SelectedValue);
        if (tbx_heure.Text != "")
        {
            monProjet.heureAlloue = int.Parse(tbx_heure.Text);
        }
        if (dateDebut.Text != "")
        {
            monProjet.dateDebut = DateTime.Parse(dateDebut.Text.ToString());
        }
        if (dateFin.Text != "")
        {
            monProjet.dateFin = DateTime.Parse(dateFin.Text.ToString());
        }
        monProjet.idStatus = int.Parse(ddl_statut.SelectedValue);

        BD_CoEco.CreateNewProjet(monProjet);

        for (int i = 0; i < lst_employeAjouter.Items.Count; i++)
        {
            T_Employe emp = BD_CoEco.GetEmpByID(int.Parse(lst_employeAjouter.Items[i].Value));
            listeEmpAuProjet.Add(emp);
        }

        for (int i = 0; i < listeEmpAuProjet.Count; i++)
        {
            T_EmployeProjet empPro = new T_EmployeProjet();
            empPro.idEmp = listeEmpAuProjet[i].idEmploye;
            empPro.idPro = (int)BD_CoEco.getNewIdProject() - 1;
            BD_CoEco.CreateNewEmpAtProject(empPro);
        }

        Response.Redirect("Projet.aspx");
    }
Exemplo n.º 9
0
    private void showResult(int id_Pro)
    {
        T_Projet projet = BD_CoEco.GetProByID(id_Pro);

        TableRow tr = new TableRow();

        TableCell cNom = new TableCell();
        //cNom.Text = projet.nom;
        HyperLink hl = new HyperLink();

        hl.Text        = projet.nom;
        hl.NavigateUrl = "AjouterProjet.aspx?id=" + projet.idProjet.ToString();
        cNom.Controls.Add(hl);

        TableCell cChef = new TableCell();

        if (projet.responsable == null || projet.responsable == 0)
        {
            cChef.Text = " - ";
        }
        else
        {
            if (projet.responsable != -1)
            {
                T_Employe responsable = BD_CoEco.GetEmpByID((int)projet.responsable);
                cChef.Text = responsable.prenom + " " + responsable.nom;
            }
            else
            {
                cChef.Text = "-";
            }
        }
        //tc4.Text = listeStatProjet[p_projet.idStatus - 1].descript;
        TableCell cStatut = new TableCell();

        cStatut.Text = BD_CoEco.GetListeStatusProjet()[projet.idStatus - 1].descript;

        tr.Cells.Add(cNom);
        tr.Cells.Add(cChef);
        tr.Cells.Add(cStatut);
        Tableau_Projets.Rows.Add(tr);
    }
Exemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["fonction"] == null)
        {
            Response.Redirect("index.aspx");
        }

        //Si un usager normal rentre dans l'URL cette page, on le "kick"
        if (Session["fonction"].ToString() != "3")
        {
            Response.Redirect("Menu.aspx");
        }

        string idFDT = Request.QueryString["idFTD"];

        if (idFDT == null || idFDT == "")
        {
            Response.Redirect("FeuilleDeTempsADM.aspx");
        }
        loadTable();

        T_FeuilleDeTemps fdt = BD_CoEco.GetFeuilleDeTempsById(int.Parse(idFDT));

        if (fdt.approbation == true)
        {
            btn_app.Text = "Désapprouver";
        }
        else
        {
            btn_app.Text = "Approuver";
        }

        T_Employe emp = BD_CoEco.GetEmpByID(BD_CoEco.GetFeuilleDeTempsById(int.Parse(idFDT)).idEmp);

        lbl_nomEmp.Text = emp.prenom + " " + emp.nom;

        DateTime ddate = (DateTime)BD_CoEco.GetFeuilleDeTempsById(int.Parse(idFDT)).semaine;

        lbl_idSem.Text = "Semaine #" + Utilitaires.GetWeek(ddate).ToString() + " de l'année " + ddate.Year.ToString();
    }
Exemplo n.º 11
0
    private void ajouterEmpLie()
    {
        List <T_Employe> listeEmpAuProjet = new List <T_Employe>();
        T_Projet         monProjet        = new T_Projet();

        monProjet.idProjet = int.Parse(Request.QueryString["id"]);

        List <T_Employe> listEmpPro = BD_CoEco.GetEmpByProject(monProjet);
        List <int>       listId     = new List <int>();

        foreach (T_Employe EmpPro in listEmpPro)
        {
            listId.Add(EmpPro.idEmploye);
        }
        for (int i = 0; i < lst_employeAjouter2.Items.Count; i++)
        {
            if (listId.Count > i)
            {
                if (listId[i] != int.Parse(lst_employeAjouter2.Items[i].Value))
                {
                    T_Employe emp = BD_CoEco.GetEmpByID(int.Parse(lst_employeAjouter2.Items[i].Value));
                    listeEmpAuProjet.Add(emp);
                }
            }
            else
            {
                T_Employe emp = BD_CoEco.GetEmpByID(int.Parse(lst_employeAjouter2.Items[i].Value));
                listeEmpAuProjet.Add(emp);
            }
        }

        for (int i = 0; i < listeEmpAuProjet.Count; i++)
        {
            T_EmployeProjet empPro = new T_EmployeProjet();
            empPro.idEmp = listeEmpAuProjet[i].idEmploye;
            empPro.idPro = monProjet.idProjet;
            BD_CoEco.CreateNewEmpAtProject(empPro);
        }
    }
Exemplo n.º 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["fonction"] == null)
        {
            Response.Redirect("index.aspx");
        }

        HeaderTableau();
        idEmp = int.Parse(Session["idEmp"].ToString());
        T_Employe emp      = BD_CoEco.GetEmpByID(idEmp);
        float     nbHeures = 0;

        float maladie   = 0;
        float feries    = 0;
        float vacances  = 0;
        float hrsAcc    = 0;
        float personnel = 0;

        List <T_FeuilleDeTemps> hrs = BD_CoEco.GetListeFeuilleDeTemps();

        foreach (T_FeuilleDeTemps fdt in hrs)
        {
            if (fdt.idEmp == idEmp)
            {
                if (fdt.idCategorie == 6)
                {
                    maladie += Utilitaires.GetHeureFDT(fdt.idFeuilleDeTemps);
                }
                else if (fdt.idCategorie == 5)
                {
                    feries += Utilitaires.GetHeureFDT(fdt.idFeuilleDeTemps);
                }
                else if (fdt.idCategorie == 9)
                {
                    vacances += Utilitaires.GetHeureFDT(fdt.idFeuilleDeTemps);
                }
                else if (fdt.idCategorie == 8)
                {
                    hrsAcc += Utilitaires.GetHeureFDT(fdt.idFeuilleDeTemps);
                }
                else if (fdt.idCategorie == 7)
                {
                    personnel += Utilitaires.GetHeureFDT(fdt.idFeuilleDeTemps);
                }
            }
        }

        if (emp.congesFeries != null)
        {
            ShowEmp(feries, (float)emp.congesFeries, "Heures congées fériés");
            nbHeures += (float)emp.congesFeries;
        }
        else
        {
            ShowEmp(feries, 0, "Heures congées fériés");
        }
        if (emp.congesMaladie != null)
        {
            ShowEmp(maladie, (float)emp.congesMaladie, "Heures congées maladie");
            nbHeures += (float)emp.congesMaladie;
        }
        else
        {
            ShowEmp(maladie, 0, "Heures congées maladie");
        }
        if (emp.congesPersonnels != null)
        {
            ShowEmp(personnel, (float)emp.congesPersonnels, "Heures congées Personnels");
            nbHeures += (float)emp.congesPersonnels;
        }
        else
        {
            ShowEmp(personnel, 0, "Heures congées Personnels");
        }
        if (emp.heuresAccumuleesOuSansSolde != null)
        {
            ShowEmp(hrsAcc, (float)emp.heuresAccumuleesOuSansSolde, "Heures accumulées ou sans solde");
            nbHeures += (float)emp.heuresAccumuleesOuSansSolde;
        }
        else
        {
            ShowEmp(hrsAcc, 0, "Heures accumulées ou sans solde");
        }
        if (emp.vacances != null)
        {
            ShowEmp(vacances, (float)emp.vacances, "Heures vacances");
            nbHeures += (float)emp.vacances;
        }
        else
        {
            ShowEmp(vacances, 0, "Heures vacances");
        }

        TableRow  tr          = new TableRow();
        TableCell tc_nomConge = new TableCell();

        tc_nomConge.Text = "<strong>Total</strong>";

        TableCell tc_HrsPrises = new TableCell();
        float     HrsAuTotal   = (maladie + feries + vacances + hrsAcc + personnel);

        tc_HrsPrises.Text = "<strong>" + HrsAuTotal.ToString() + "</strong>";


        TableCell tc_HrsTotal = new TableCell();

        tc_HrsTotal.Text = "<strong>" + nbHeures.ToString() + "</strong>";

        TableCell tc_HrsRestantes = new TableCell();

        tc_HrsRestantes.Text = "<strong>" + (nbHeures - HrsAuTotal).ToString() + "</strong>";

        tr.Cells.Add(tc_nomConge);
        tr.Cells.Add(tc_HrsPrises);
        tr.Cells.Add(tc_HrsTotal);
        tr.Cells.Add(tc_HrsRestantes);
        Tableau_BanqueDheures.Rows.Add(tr);
    }
Exemplo n.º 13
0
    protected void Connexion_click(object sender, EventArgs e)
    {
        List <T_Employe> listeEmp = BD_CoEco.GetListeEmploye(true);

        List <T_Employe> admList = BD_CoEco.GetListeEmploye();
        T_Employe        lstAdm  = new T_Employe();

        foreach (T_Employe emp in admList)
        {
            if (emp.idFonction == 3)
            {
                lstAdm = emp;
            }
        }
        listeEmp.Add(lstAdm);



        if (tbx_username.Text != null && tbx_username.Text != "")
        {
            int  i      = 0;
            bool trouve = false;
            while (!trouve && i < listeEmp.Count)
            {
                if (listeEmp[i].loginName == tbx_username.Text)
                {
                    trouve = true;
                }
                if (!trouve)
                {
                    i++;
                }
            }
            if (trouve)
            {
                if (listeEmp[i].mdp == null)
                {
                    if (tbx_mdp.Text == "")
                    {
                        //Alors on co
                        Connect(BD_CoEco.GetEmpByID(listeEmp[i].idEmploye));
                    }
                    else
                    {
                        tbx_mdp.Text      = "";
                        tbx_username.Text = "";
                    }
                }
                else
                {
                    //Il y a un mot de passe
                    if (listeEmp[i].mdp == tbx_mdp.Text)
                    {
                        //Alors on co
                        Connect(BD_CoEco.GetEmpByID(listeEmp[i].idEmploye));
                    }
                    else
                    {
                        tbx_mdp.Text      = "";
                        tbx_username.Text = "";
                    }
                }
            }
            else //si l'usager n'est pas trouvé
            {
                tbx_mdp.Text           = "";
                tbx_username.Text      = "";
                message_erreur.Visible = true;
            }
        }
    }
Exemplo n.º 14
0
    private void LoadTousProjets()
    {
        pnl_Main.Controls.Clear();
        List <T_Projet> listProjet = BD_CoEco.GetListeProjet();

        listProjet = listProjet.OrderBy(o => o.nom).ToList();

        foreach (T_Projet projet in listProjet)
        {
            Panel pnl_Projet = new Panel();
            pnl_Main.Controls.Add(pnl_Projet);

            Label lbl_NomProjet = new Label();
            lbl_NomProjet.Text = "<h3>" + projet.nom + "</h3>";
            pnl_Projet.Controls.Add(lbl_NomProjet);

            Table tbTitre = new Table();
            tbTitre.CssClass = "table";
            TableHeaderRow  thr     = new TableHeaderRow();
            TableHeaderCell thc_nom = new TableHeaderCell();
            thc_nom.Text  = "Date";
            thc_nom.Width = new Unit("25%");
            thr.Cells.Add(thc_nom);
            TableHeaderCell thc_note = new TableHeaderCell();
            thc_note.Text  = "Note";
            thc_note.Width = new Unit("25%");
            thr.Cells.Add(thc_note);
            TableHeaderCell thc_Montant = new TableHeaderCell();
            thc_Montant.Width = new Unit("25%");
            thc_Montant.Text  = "Montant";
            thr.Cells.Add(thc_Montant);
            TableHeaderCell thc_Appr = new TableHeaderCell();
            thc_Appr.Width = new Unit("25%");
            thc_Appr.Text  = "Approuvé";
            thr.Cells.Add(thc_Appr);
            tbTitre.Rows.Add(thr);
            pnl_Projet.Controls.Add(tbTitre);


            List <T_Depense> lstDep = BD_CoEco.GetListeDepense();
            foreach (T_Depense dep in lstDep)
            {
                if (dep.idProjet == projet.idProjet && dep.idEmp == int.Parse(Session["idEmp"].ToString()))
                {
                    Panel pnl_depenses = new Panel();
                    pnl_Projet.Controls.Add(pnl_depenses);

                    T_Employe emp = BD_CoEco.GetEmpByID(dep.idEmp);
                    Table     tb  = new Table();
                    tb.CssClass = "table";
                    TableRow  tr      = new TableRow();
                    TableCell tc_date = new TableCell();
                    tc_date.Width = new Unit("25%");
                    HyperLink hl = new HyperLink();
                    if (dep.ddate == null)
                    {
                        hl.Text = " - ";
                    }
                    else
                    {
                        hl.Text = string.Format("{0:d}", dep.ddate);
                    }
                    hl.NavigateUrl = "AjouterDepenses.aspx?id=" + dep.idDepense.ToString() + "&Type=1";
                    tc_date.Controls.Add(hl);
                    tr.Cells.Add(tc_date);

                    TableCell tc_commentaire = new TableCell();
                    tc_commentaire.Width = new Unit("25%");
                    if (dep.descript == null || dep.descript == "")
                    {
                        tc_commentaire.Text = " - ";
                    }
                    else
                    {
                        tc_commentaire.Text = dep.descript;
                    }
                    tr.Cells.Add(tc_commentaire);

                    TableCell tc_total = new TableCell();
                    tc_total.Width = new Unit("25%");
                    float tot = (float)dep.montant;
                    tot          *= 100; tot = (float)Math.Round(tot); tot /= 100;
                    tc_total.Text = string.Format("{0:c}", tot);
                    tr.Cells.Add(tc_total);

                    TableCell tc_App = new TableCell();
                    tc_App.Width = new Unit("25%");
                    Panel pnl_App = new Panel();
                    if (dep.aprobation == true)
                    {
                        pnl_App.CssClass = "fas fa-check";
                    }
                    else if (dep.aprobation == false)
                    {
                        pnl_App.CssClass = "fas fa-times";
                    }
                    else
                    {
                        pnl_App.CssClass = "fas fa-question";
                    }
                    tc_App.Controls.Add(pnl_App);
                    tr.Cells.Add(tc_App);

                    tb.Rows.Add(tr);
                    pnl_depenses.Controls.Add(tb);
                }
            }

            List <T_Kilometrage> lstKm = BD_CoEco.GetListeKilometrage();
            foreach (T_Kilometrage km in lstKm)
            {
                if (km.idPro == projet.idProjet && km.idEmp == int.Parse(Session["idEmp"].ToString()))
                {
                    Panel pnl_Kilo = new Panel();
                    pnl_Projet.Controls.Add(pnl_Kilo);

                    pnl_Projet.CssClass = "Test";
                    T_Employe emp = BD_CoEco.GetEmpByID(km.idEmp);
                    Table     tb  = new Table();
                    tb.CssClass = "table";
                    TableRow  tr      = new TableRow();
                    TableCell tc_date = new TableCell();
                    tc_date.Width = new Unit("25%");
                    HyperLink hl = new HyperLink();
                    if (km.ddate == null)
                    {
                        hl.Text = "-";
                    }
                    else
                    {
                        hl.Text = string.Format("{0:d}", km.ddate);
                    }
                    hl.NavigateUrl = "AjouterDepenses.aspx?id=" + km.idKilo.ToString() + "&Type=2";
                    tc_date.Controls.Add(hl);
                    tr.Cells.Add(tc_date);

                    TableCell tc_commentaire = new TableCell();
                    tc_commentaire.Width = new Unit("25%");
                    if (km.commentaire == null || km.commentaire == "")
                    {
                        tc_commentaire.Text = "-";
                    }
                    else
                    {
                        tc_commentaire.Text = km.commentaire;
                    }
                    tr.Cells.Add(tc_commentaire);

                    TableCell tc_montant = new TableCell();
                    tc_montant.Width = new Unit("25%");
                    float total = km.nbKilo * BD_CoEco.GetTauxKiloById(km.idTaux).taux;
                    total          *= 100; total = (float)Math.Round(total); total /= 100;
                    tc_montant.Text = string.Format("{0:c}", total);
                    tr.Cells.Add(tc_montant);

                    TableCell tc_appr = new TableCell();
                    tc_appr.Width = new Unit("25%");
                    Panel pnl_App = new Panel();
                    //if (km.approbation == true)
                    //     pnl_App.CssClass = "fas fa-check";
                    // else if (km.approbation == false)
                    //     pnl_App.CssClass = "fas fa-times";
                    //  else
                    pnl_App.CssClass = "fas fa-question";
                    tc_appr.Controls.Add(pnl_App);
                    tr.Cells.Add(tc_appr);

                    tb.Rows.Add(tr);
                    pnl_Kilo.Controls.Add(tb);
                }
            }

            if (pnl_Projet.Controls.Count <= 2)
            {
                pnl_Main.Controls.Remove(pnl_Projet);
            }
        }
    }
Exemplo n.º 15
0
    private void load()
    {
        List <T_Projet> lstProjet = BD_CoEco.GetListeProjet();

        lstProjet = lstProjet.OrderBy(o => o.descript).ToList();

        List <T_Depense>     lstDep = BD_CoEco.GetListeDepense();
        List <T_Kilometrage> lstKm  = BD_CoEco.GetListeKilometrage();

        foreach (T_Projet projet in lstProjet)
        {
            Panel pnl_projet = new Panel();
            pnl_master.Controls.Add(pnl_projet);

            Label lbl_NomProjet = new Label();
            lbl_NomProjet.Text = "<h3>" + projet.nom + "</h3>";
            pnl_projet.Controls.Add(lbl_NomProjet);

            Table tbHeader = new Table();
            tbHeader.CssClass = "table";
            TableHeaderRow  thr     = new TableHeaderRow();
            TableHeaderCell thc_Emp = new TableHeaderCell();
            thc_Emp.Text  = "Employé";
            thc_Emp.Width = new Unit("25%");
            thr.Cells.Add(thc_Emp);
            TableHeaderCell thc_date = new TableHeaderCell();
            thc_date.Text  = "Date";
            thc_date.Width = new Unit("25%");
            thr.Cells.Add(thc_date);
            TableHeaderCell thc_montant = new TableHeaderCell();
            thc_montant.Text  = "Montant";
            thc_montant.Width = new Unit("25%");
            thr.Cells.Add(thc_montant);
            TableHeaderCell thc_app = new TableHeaderCell();
            thc_app.Text  = "Approuvé";
            thc_app.Width = new Unit("25%");
            thr.Cells.Add(thc_app);
            tbHeader.Rows.Add(thr);
            pnl_projet.Controls.Add(tbHeader);

            float total = 0;

            foreach (T_Depense depense in lstDep)
            {
                if (depense.idProjet == projet.idProjet)
                {
                    Panel pnl_dep = new Panel();
                    pnl_projet.Controls.Add(pnl_dep);

                    T_Employe emp = BD_CoEco.GetEmpByID(depense.idEmp);

                    Table tbRow = new Table();
                    tbRow.CssClass = "table";
                    TableRow  tr     = new TableRow();
                    TableCell tc_nom = new TableCell();
                    HyperLink hl     = new HyperLink();
                    hl.Width       = new Unit("25%");
                    hl.Text        = emp.prenom + " " + emp.nom;
                    hl.NavigateUrl = "AjouterDepenses.aspx?id=" + depense.idDepense + "&Type=1";
                    tc_nom.Controls.Add(hl);
                    tr.Cells.Add(tc_nom);
                    TableCell tc_date = new TableCell();
                    if (depense.ddate != null)
                    {
                        tc_date.Text = String.Format("{0:d}", ((DateTime)depense.ddate));
                    }
                    else
                    {
                        tc_date.Text = "";
                    }
                    tc_date.Width = new Unit("25%");
                    tr.Cells.Add(tc_date);
                    TableCell tc_montant = new TableCell();
                    float     tot        = 0;
                    if (depense.montant != null)
                    {
                        tot = (float)depense.montant * 100; tot = (float)Math.Round(tot); tot /= 100;
                    }
                    tc_montant.Text  = string.Format("{0:c}", tot);
                    tc_montant.Width = new Unit("25%");
                    tr.Cells.Add(tc_montant);
                    TableCell tc_app = new TableCell();
                    tc_app.Width = new Unit("25%");
                    CheckBox cbx_app = new CheckBox();
                    cbx_app.CheckedChanged += ApprouverDep;
                    cbx_app.AutoPostBack    = true;
                    cbx_app.ID              = "cbx_app-" + depense.idDepense + "-1";
                    if (depense.aprobation == null)
                    {
                        cbx_app.Checked = false;
                    }
                    else
                    {
                        cbx_app.Checked = (bool)depense.aprobation;
                    }
                    tc_app.Controls.Add(cbx_app);
                    tr.Cells.Add(tc_app);
                    tbRow.Rows.Add(tr);
                    pnl_dep.Controls.Add(tbRow);
                    if (depense.montant != null)
                    {
                        total += (float)depense.montant;
                    }
                }
            }

            foreach (T_Kilometrage kilometrage in lstKm)
            {
                if (kilometrage.idPro == projet.idProjet)
                {
                    Panel pnl_kilo = new Panel();
                    pnl_projet.Controls.Add(pnl_kilo);

                    T_Employe emp = BD_CoEco.GetEmpByID(kilometrage.idEmp);

                    Table tbrow = new Table();
                    tbrow.CssClass = "table";
                    TableRow  tr     = new TableRow();
                    TableCell tc_emp = new TableCell();
                    HyperLink hl     = new HyperLink();
                    hl.Text        = emp.prenom + " " + emp.nom;
                    hl.NavigateUrl = "AjouterDepenses.aspx?id=" + kilometrage.idKilo + "&Type=2";
                    tc_emp.Width   = new Unit("25%");
                    tc_emp.Controls.Add(hl);
                    tr.Cells.Add(tc_emp);
                    TableCell tc_date = new TableCell();
                    tc_date.Text  = string.Format("{0:d}", kilometrage.ddate);
                    tc_date.Width = new Unit("25%");
                    tr.Cells.Add(tc_date);
                    TableCell tc_montant = new TableCell();
                    tc_montant.Width = new Unit("25%");
                    float tot = kilometrage.nbKilo * BD_CoEco.GetTauxKiloById(kilometrage.idTaux).taux;
                    tot            *= 100; tot = (float)Math.Round(tot); tot /= 100;
                    tc_montant.Text = string.Format("{0:c}", tot);
                    tr.Cells.Add(tc_montant);
                    TableCell tc_app  = new TableCell();
                    CheckBox  cbx_app = new CheckBox();
                    cbx_app.CheckedChanged += ApprouverDep;
                    cbx_app.AutoPostBack    = true;
                    cbx_app.ID              = "cbx_app-" + kilometrage.idKilo + "-2";
                    if (kilometrage.approbation == null)
                    {
                        cbx_app.Checked = false;
                    }
                    else
                    {
                        cbx_app.Checked = (bool)kilometrage.approbation;
                    }
                    tc_app.Controls.Add(cbx_app);
                    tr.Cells.Add(tc_app);
                    tbHeader.Rows.Add(tr);
                    pnl_kilo.Controls.Add(tbrow);

                    total += kilometrage.nbKilo * BD_CoEco.GetTauxKiloById(kilometrage.idTaux).taux;
                }

                if (pnl_projet.Controls.Count == 2)
                {
                    pnl_master.Controls.Remove(pnl_projet);
                }
            }

            Table tb = new Table();
            tb.CssClass = "table";
            TableRow  tr_F         = new TableRow();
            TableCell tc_emptyCell = new TableCell();
            tc_emptyCell.Width      = new Unit("25%");
            tc_emptyCell.Text       = "<strong>Total</strong>";
            tc_emptyCell.ColumnSpan = 2;
            tr_F.Cells.Add(tc_emptyCell);
            TableCell tc_total = new TableCell();
            tc_total.Width      = new Unit("75%");
            tc_total.ColumnSpan = 2;

            tc_total.Text = string.Format("{0:c}", total);
            tr_F.Cells.Add(tc_total);
            tb.Rows.Add(tr_F);
            pnl_projet.Controls.Add(tb);

            if (total == 0)
            {
                pnl_master.Controls.Remove(pnl_projet);
            }
        }
    }
Exemplo n.º 16
0
    private void load()
    {
        panel_Contenu.Controls.Clear();

        List <T_Projet> lstPro = BD_CoEco.GetListeProjet();

        foreach (T_Projet projet in lstPro)
        {
            int nbCatCount = 0;
            if (BD_CoEco.GetFDTByProject(projet.idProjet).Count != 0)
            {
                Panel pnl_projet = new Panel();
                panel_Contenu.Controls.Add(pnl_projet);

                Label lbl_projet = new Label();
                lbl_projet.Text = "<h3>" + projet.nom + "</h3>";
                pnl_projet.Controls.Add(lbl_projet);

                List <T_CategoriePro> lstCat = BD_CoEco.GetListeCategorie(projet);
                foreach (T_CategoriePro categorie in lstCat)
                {
                    Panel pnl_categorie = new Panel();
                    pnl_projet.Controls.Add(pnl_categorie);

                    Label lbl_categorie = new Label();
                    lbl_categorie.Text = "<h5>" + categorie.descript + "</h5>";
                    pnl_categorie.Controls.Add(lbl_categorie);

                    Table tb = new Table();
                    tb.CssClass = "table";
                    TableHeaderRow  thr     = new TableHeaderRow();
                    TableHeaderCell thc_emp = new TableHeaderCell();
                    thc_emp.Width = new Unit("33%");
                    thc_emp.Text  = "Employé";
                    thr.Cells.Add(thc_emp);
                    TableHeaderCell thc_heures = new TableHeaderCell();
                    thc_heures.Text  = "Heures";
                    thc_heures.Width = new Unit("33%");
                    thr.Cells.Add(thc_heures);
                    TableHeaderCell thc_app = new TableHeaderCell();
                    thc_app.Text = "Approuver";
                    thr.Cells.Add(thc_app);
                    thc_app.Width = new Unit("33%");
                    tb.Rows.Add(thr);
                    pnl_categorie.Controls.Add(tb);

                    List <T_FeuilleDeTemps> lstFdt = BD_CoEco.GetFDTByProject(projet.idProjet);

                    int   fdtCount  = 0;
                    float heuresTot = 0;
                    foreach (T_FeuilleDeTemps feuilleDeTemps in lstFdt)
                    {
                        int annee   = int.Parse(tbx_Semaine.Text.Split('-')[0]);
                        int semaine = int.Parse(tbx_Semaine.Text.Split('-')[1].Remove(0, 1));
                        if (feuilleDeTemps.idCategorie == categorie.idCategorie && semaine == Utilitaires.GetWeek((DateTime)feuilleDeTemps.semaine) && annee == feuilleDeTemps.semaine.Value.Year)
                        {
                            fdtCount++;
                            nbCatCount++;
                            Panel panel_fdt = new Panel();
                            pnl_categorie.Controls.Add(panel_fdt);

                            T_Employe emp = BD_CoEco.GetEmpByID(feuilleDeTemps.idEmp);

                            Table tab = new Table();
                            tab.CssClass = "table";
                            TableRow tr = new TableRow();

                            //Partie pour les noms
                            TableCell tc_nom = new TableCell();
                            tc_nom.Width = new Unit("33%");
                            HyperLink hl = new HyperLink();
                            hl.Text        = emp.prenom + " " + emp.nom;
                            hl.NavigateUrl = "FDT_ConsultationAdm.aspx?idFDT=" + feuilleDeTemps.idFeuilleDeTemps.ToString();
                            tc_nom.Controls.Add(hl);
                            tr.Cells.Add(tc_nom);



                            TableCell tc_FDT = new TableCell();
                            tc_FDT.Width = new Unit("33%");
                            tc_FDT.Text  = Utilitaires.GetHeureFDT(feuilleDeTemps.idFeuilleDeTemps).ToString();
                            tr.Cells.Add(tc_FDT);

                            heuresTot += Utilitaires.GetHeureFDT(feuilleDeTemps.idFeuilleDeTemps);

                            TableCell tc_app = new TableCell();
                            tc_app.Width = new Unit("33%");
                            CheckBox cbx_app = new CheckBox();
                            cbx_app.AutoPostBack    = true;
                            cbx_app.ID              = "cbx_App-" + feuilleDeTemps.idFeuilleDeTemps;
                            cbx_app.Checked         = (bool)feuilleDeTemps.approbation;
                            cbx_app.CheckedChanged += cbx_pressed;
                            tc_app.Controls.Add(cbx_app);
                            tr.Cells.Add(tc_app);


                            tab.Rows.Add(tr);
                            panel_fdt.Controls.Add(tab);
                        }
                    }

                    if (fdtCount == 0)
                    {
                        pnl_projet.Controls.Remove(pnl_categorie);
                    }
                    else
                    {
                        //Ajouter total
                        Table tb_footer = new Table();
                        tb_footer.CssClass = "table";
                        TableFooterRow tfr      = new TableFooterRow();
                        TableCell      tc_titre = new TableCell();
                        tc_titre.Width = new Unit("33%");
                        tc_titre.Text  = "<strong>Total</strong>";
                        tfr.Cells.Add(tc_titre);
                        TableCell tc_total = new TableCell();
                        tc_total.Width      = new Unit("33%");
                        tc_total.ColumnSpan = 2;
                        tc_total.Text       = "<strong>" + heuresTot.ToString() + "</strong>";
                        tfr.Cells.Add(tc_total);
                        TableCell tc_vide = new TableCell();
                        tc_vide.Width = new Unit("33%");
                        tc_vide.Text  = "";
                        tfr.Cells.Add(tc_vide);
                        tb_footer.Rows.Add(tfr);
                        pnl_categorie.Controls.Add(tb_footer);
                    }
                }
                if (nbCatCount == 0)
                {
                    panel_Contenu.Controls.Remove(pnl_projet);
                }
            }
        }
    }