Example #1
0
        private void treeSelectionEnvFlux_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode nd = treeSelectionEnvFlux.SelectedNode;

            if (nd.Parent == null)
            {
                return;
            }                                  //Noeud sans parent
            if (nd.Nodes.Count > 0)
            {
                return;
            }                                   //Noeud avec enfant

            foreach (TreeNode ndd in nd.Parent.Nodes)
            {
                ndd.ForeColor = Color.Black;
            }

            nd.ForeColor = (nd.ForeColor == Color.Black? Color.Red : Color.Black);

            if (nd.Parent.Tag.ToString() == "ENVELOPPE")
            {
                Enveloppe_Select = (nd.ForeColor == Color.Black ? -1 : int.Parse(nd.Name));
            }

            if (nd.Parent.Tag.ToString() == "FLUX")
            {
                Flux_Select = (nd.ForeColor == Color.Black ? TypeFlux.Dépenses : (TypeFlux)nd.Tag);
            }

            if (nd.Parent.Tag.ToString() == "MONTANT")
            {
                Montant_Select = (nd.ForeColor == Color.Black ? TypeMontant.CP : (TypeMontant)nd.Tag);
            }

            if (nd.Parent.Tag.ToString() == "ORG")
            {
                budget_org_Select = (nd.ForeColor == Color.Black ? 0: int.Parse(nd.Name));
            }

            if (nd.Parent.Tag.ToString() == "GEO")
            {
                budget_geo_Select = (nd.ForeColor == Color.Black ? 0 : int.Parse(nd.Name));
            }

            Afficher_ListeOperation();
            Afficher_ListeVirement();
        }
Example #2
0
        void Valider()
        {
            if (lstPeriode.SelectedIndex < 0)
            {
                MessageBox.Show("Période ?"); return;
            }
            if (lstTypeVirement.SelectedIndex < 0)
            {
                MessageBox.Show("Type de virement ?"); return;
            }

            if (choixListe_Src.ListeSelection.Count == 0)
            {
                MessageBox.Show("Un compte source doit être sélectionné ?"); return;
            }
            if (lstEnveloppe_Src.SelectedIndex < 0)
            {
                MessageBox.Show("Enveloppe de la source ?"); return;
            }
            if (lstORG_Src.SelectedIndex < 0)
            {
                MessageBox.Show("ORG de la source ?"); return;
            }
            if (lstGEO_Src.SelectedIndex < 0)
            {
                MessageBox.Show("GEO de la source ?"); return;
            }

            if (choixListe_Dest.ListeSelection.Count == 0)
            {
                MessageBox.Show("Un compte destination doit être sélectionné ?"); return;
            }
            if (lstEnveloppe_Dest.SelectedIndex < 0)
            {
                MessageBox.Show("Enveloppe de la destination ?"); return;
            }
            if (lstORG_Dest.SelectedIndex < 0)
            {
                MessageBox.Show("ORG de la destination ?"); return;
            }
            if (lstGEO_Dest.SelectedIndex < 0)
            {
                MessageBox.Show("GEO de la destination ?"); return;
            }

            if (lstTypeMontant.SelectedIndex < 0)
            {
                MessageBox.Show("Type de montant ?"); return;
            }

            string LibelleVirement = "VIREMENT";
            string CodeVirement    = "VIR-" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
            int    Periode         = listePeriode[lstPeriode.SelectedIndex].ID;

            TypeMontant TypeMontant = (TypeMontant)lstTypeMontant.SelectedIndex;


            double Montant = double.Parse(lblMontant.Text);

            budget_virement.Acces = Acces;

            budget_virement.Periode   = Periode;
            budget_virement.Type_Flux = TypeFlux;
            budget_virement.Libelle   = LibelleVirement;
            budget_virement.Code      = CodeVirement;

            int Enveloppe_Src = listeTypeEnveloppe[lstEnveloppe_Src.SelectedIndex].ID;
            int ORG_Src       = listeORG[lstORG_Src.SelectedIndex].ID;
            int GEO_Src       = listeGEO[lstGEO_Src.SelectedIndex].ID;
            int Compte_ID_Src = choixListe_Src.ListeSelection[0].ID;

            budget_virement.Enveloppe_Src  = Enveloppe_Src;
            budget_virement.Compte_ID_Src  = Compte_ID_Src;
            budget_virement.Budget_ORG_Src = ORG_Src;
            budget_virement.Budget_GEO_Src = GEO_Src;

            int Enveloppe_Dest = listeTypeEnveloppe[lstEnveloppe_Dest.SelectedIndex].ID;
            int ORG_Dest       = listeORG[lstORG_Dest.SelectedIndex].ID;
            int GEO_Dest       = listeGEO[lstGEO_Dest.SelectedIndex].ID;
            int Compte_ID_Dest = choixListe_Dest.ListeSelection[0].ID;

            budget_virement.Enveloppe_Dest  = Enveloppe_Dest;
            budget_virement.Compte_ID_Dest  = Compte_ID_Dest;
            budget_virement.Budget_ORG_Dest = ORG_Dest;
            budget_virement.Budget_GEO_Dest = GEO_Dest;

            budget_virement.DateDemande  = string.Format("{0:yyyyMMdd}", lblDateDemande.Value);
            budget_virement.DateEffet    = string.Format("{0:yyyyMMdd}", lblDateEffet.Value);
            budget_virement.Type_Montant = TypeMontant;
            budget_virement.Montant      = Montant;
            budget_virement.Commentaire  = lblCommentaire.Text.Trim();

            TypeElement typeElement = Acces.type_BUDGET_VIREMENT;

            if (Creation)
            {
                if (!(Acces.Existe_Element(typeElement, "CODE", CodeVirement)))
                {
                    budget_virement.ID = Acces.Ajouter_Element(typeElement, budget_virement);
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(typeElement, budget_virement);
            }

            this.DialogResult = DialogResult.OK;
        }
Example #3
0
        void Valider()
        {
            if (lstTypeEnveloppe.SelectedIndex < 0)
            {
                MessageBox.Show("Enveloppe ?"); return;
            }
            if (lstPeriode.SelectedIndex < 0)
            {
                MessageBox.Show("Période ?"); return;
            }
            if (lstTypeFlux.SelectedIndex < 0)
            {
                MessageBox.Show("Flux ?"); return;
            }
            if (ChoixCompte.ListeSelection.Count == 0)
            {
                MessageBox.Show("Un compte doit être sélectionné  ?"); return;
            }
            if (ChoixCompte.ListeSelection.Count > 1)
            {
                MessageBox.Show("Un seul compte doit être sélectionné  ?"); return;
            }
            if (lstORG.SelectedIndex < 0)
            {
                MessageBox.Show("ORG ?"); return;
            }
            if (lstGEO.SelectedIndex < 0)
            {
                MessageBox.Show("GEO ?"); return;
            }
            if (lstTypeMontant.SelectedIndex < 0)
            {
                MessageBox.Show("Type de montant ?"); return;
            }
            if (lstTypeOperation.SelectedIndex < 0)
            {
                MessageBox.Show("Type d'opération ?"); return;
            }

            string LibelleOpe = "OPERATION";
            string CodeOpe    = "OPE-" + string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);
            int    Enveloppe  = listeTypeEnveloppe[lstTypeEnveloppe.SelectedIndex].ID;
            int    Periode    = listePeriode[lstPeriode.SelectedIndex].ID;
            var    TypeFlux   = (TypeFlux)lstTypeFlux.SelectedIndex;

            int Compte_ID = ChoixCompte.ListeSelection[0].ID;

            TypeMontant TypeMontant = (TypeMontant)lstTypeMontant.SelectedIndex;
            int         ORG         = listeORG[lstORG.SelectedIndex].ID;
            int         GEO         = listeGEO[lstGEO.SelectedIndex].ID;

            double Montant = double.Parse(lblMontant.Text);

            budget_operation.Acces = Acces;

            budget_operation.Libelle = LibelleOpe;
            budget_operation.Code    = CodeOpe;

            budget_operation.Enveloppe = Enveloppe;
            budget_operation.Periode   = Periode;
            budget_operation.Type_Flux = TypeFlux;

            budget_operation.Compte_ID  = Compte_ID;
            budget_operation.Budget_ORG = ORG;
            budget_operation.Budget_GEO = GEO;

            budget_operation.DateOperation  = string.Format("{0:yyyyMMdd}", lblDateOpe.Value);
            budget_operation.Type_Operation = listeTypeOperation[lstTypeOperation.SelectedIndex].ID;
            budget_operation.Type_Montant   = TypeMontant;
            budget_operation.Montant        = Montant;
            budget_operation.Commentaire    = lblCommentaire.Text.Trim();

            TypeElement typeElement = Acces.type_BUDGET_OPERATION;

            if (Creation)
            {
                if (!(Acces.Existe_Element(typeElement, "CODE", CodeOpe)))
                {
                    budget_operation.ID = Acces.Ajouter_Element(typeElement, budget_operation);

                    if (TypeMontant == TypeMontant.AE)
                    {
                        if (MessageBox.Show("Créer une opération en CP correspondante ?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            string mt = Microsoft.VisualBasic.Interaction.InputBox("Saisir le montant des CP", "Montant des CP", string.Format("{0:# ### ###.00}", budget_operation.Montant));
                            if (mt.Length > 0)
                            {
                                budget_operation.ID           = 0;
                                budget_operation.Type_Montant = TypeMontant.CP;
                                budget_operation.Montant      = double.Parse(mt);
                                budget_operation.ID           = Acces.Ajouter_Element(typeElement, budget_operation);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Code existant"); return;
                }
            }
            else
            {
                Acces.Enregistrer(typeElement, budget_operation);
            }

            this.DialogResult = DialogResult.OK;
        }