void frm_CallBack(object sender, Tarification.Helper.CustumEventArgs e)
        {
            var mand       = ((CsMandatementGc)dg_Campagne.SelectedItem);
            var DataSource = (List <CsMandatementGc>)dg_Campagne.ItemsSource;
            int index      = DataSource.IndexOf(mand);

            //Implementer le callback
            if (e.Bag != null)
            {
                var ListFacture = (List <CsLclient>)e.Bag;

                foreach (var item in ListFacture)
                {
                    CsDetailMandatementGc facture = new CsDetailMandatementGc();
                    facture.CENTRE = item.CENTRE;
                    facture.CLIENT = item.CLIENT;
                    facture.ORDRE  = item.ORDRE;

                    facture.PERIODE          = item.REFEM;
                    facture.MONTANT          = item.MONTANT;
                    facture.NDOC             = item.NDOC;
                    facture.DATECREATION     = DateTime.Now;
                    facture.DATEMODIFICATION = DateTime.Now;
                    facture.FK_IDCLIENT      = item.FK_IDCLIENT;
                    facture.FK_IDMANDATEMENT = mand.PK_ID;
                    facture.STATUS           = "1";
                    facture.USERCREATION     = UserConnecte.matricule;
                    facture.USERMODIFICATION = UserConnecte.matricule;


                    if (!mand.DETAILMANDATEMENTGC_.Select(f => f.NDOC).Contains(facture.NDOC))
                    {
                        mand.DETAILMANDATEMENTGC_.Add(facture);
                    }
                }
                mand.DETAILMANDATEMENTGC_.ForEach(f => MiseAJourMontantDetailMandatement(mand, f));
                DataSource[index]       = mand;
                dg_Campagne.ItemsSource = DataSource;

                dg_Campagne.SelectedItem = mand;
                dg_facture.ItemsSource   = mand.DETAILMANDATEMENTGC_;
                btn_Actualiser_Click(null, null);
            }
        }
        private static void MiseAJourMontantDetailMandatement(CsMandatementGc LeMand, CsDetailMandatementGc item_)
        {
            item_.MONTANT_RESTANT = 0;
            item_.MONTANT_REGLER  = 0;
            if (LeMand.PAIEMENTGC_ != null && LeMand.PAIEMENTGC_.Count != 0)
            {
                foreach (var paiement in LeMand.PAIEMENTGC_)
                {
                    var detailmand = paiement.DETAILCAMPAGNEGC_.Where(dm => dm.CENTRE == item_.CENTRE && dm.CLIENT == item_.CLIENT && dm.ORDRE == item_.ORDRE && dm.NDOC == item_.NDOC);
                    if (detailmand != null)
                    {
                        item_.MONTANT_REGLER = ObtienValeurIntNullable(item_.MONTANT_REGLER) + ObtienValeurIntNullable(detailmand.Sum(c => c.MONTANT));
                    }
                }
            }
            item_.MONTANT_RESTANT = (ObtienValeurIntNullable(item_.MONTANT)) - ObtienValeurIntNullable(item_.MONTANT_REGLER);

            item_.MONTANT_VERSER = 0;
        }
Example #3
0
        private void MiseAJourMandatement(bool Isvalide)
        {
            CsCampagneGc CampAnSelectioner = new CsCampagneGc();

            CampAnSelectioner = (CsCampagneGc)dg_Campagne.SelectedItem;

            var datasource = (List <CsDetailCampagneGc>)dg_facture.ItemsSource;

            UpdateDataSource(Isvalide, datasource);

            var MandatementGc = ListMandatementGc.FirstOrDefault(m => m.FK_IDCAMPAGNA == CampAnSelectioner.PK_ID);

            if (MandatementGc == null)
            {
                var Mandatement = new CsMandatementGc {
                    FK_IDCAMPAGNA = CampAnSelectioner.PK_ID, MONTANT = datasource.Where(f => f.IsMontantValide == true).Sum(dm => dm.MONTANT), DATECREATION = DateTime.Now, DATEMODIFICATION = DateTime.Now, USERCREATION = UserConnecte.matricule, USERMODIFICATION = UserConnecte.matricule, NUMEROMANDATEMENT = txt_Numdeataire.Text
                };
                List <CsDetailMandatementGc> DETAILMANDATEMENTGC_ = new List <CsDetailMandatementGc>();
                foreach (var item in datasource)
                {
                    if (item.IsMontantValide == true)
                    {
                        CsDetailMandatementGc DetailMandatement = new CsDetailMandatementGc();

                        DetailMandatement.CENTRE           = item.CENTRE;
                        DetailMandatement.CLIENT           = item.CLIENT;
                        DetailMandatement.ORDRE            = item.ORDRE;
                        DetailMandatement.DATECREATION     = DateTime.Now;
                        DetailMandatement.DATEMODIFICATION = DateTime.Now;
                        DetailMandatement.FK_IDMANDATEMENT = Mandatement.PK_ID;
                        DetailMandatement.MONTANT          = item.MONTANT;
                        DetailMandatement.MONTANT_REGLER   = DetailMandatement.MONTANT;
                        DetailMandatement.MONTANT_VERSER   = DetailMandatement.MONTANT;
                        DetailMandatement.MONTANT_RESTANT  = 0;
                        DetailMandatement.NDOC             = item.NDOC;
                        DetailMandatement.PERIODE          = item.PERIODE;
                        DetailMandatement.STATUS           = item.STATUS;
                        DetailMandatement.USERCREATION     = UserConnecte.matricule;
                        DetailMandatement.USERMODIFICATION = UserConnecte.matricule;

                        DETAILMANDATEMENTGC_.Add(DetailMandatement);
                    }
                }
                Mandatement.DETAILMANDATEMENTGC_ = DETAILMANDATEMENTGC_;
                ListMandatementGc.Add(Mandatement);
            }
            else
            {
                MandatementGc.MONTANT           = datasource.Where(f => f.IsMontantValide == true).Sum(dm => dm.MONTANT);
                MandatementGc.NUMEROMANDATEMENT = txt_Numdeataire.Text;
                List <CsDetailMandatementGc> DETAILMANDATEMENTGC_ = new List <CsDetailMandatementGc>();
                foreach (var item in datasource)
                {
                    if (item.IsMontantValide == true)
                    {
                        CsDetailMandatementGc DetailMandatement = new CsDetailMandatementGc();

                        DetailMandatement.CENTRE           = item.CENTRE;
                        DetailMandatement.CLIENT           = item.CLIENT;
                        DetailMandatement.ORDRE            = item.ORDRE;
                        DetailMandatement.DATECREATION     = DateTime.Now;
                        DetailMandatement.DATEMODIFICATION = DateTime.Now;
                        DetailMandatement.FK_IDMANDATEMENT = MandatementGc.PK_ID;
                        DetailMandatement.MONTANT          = item.MONTANT;
                        DetailMandatement.MONTANT_REGLER   = DetailMandatement.MONTANT;
                        DetailMandatement.MONTANT_VERSER   = DetailMandatement.MONTANT;
                        DetailMandatement.MONTANT_RESTANT  = 0;
                        DetailMandatement.NDOC             = item.NDOC;
                        DetailMandatement.PERIODE          = item.PERIODE;
                        DetailMandatement.STATUS           = item.STATUS;
                        DetailMandatement.USERCREATION     = UserConnecte.matricule;
                        DetailMandatement.USERMODIFICATION = UserConnecte.matricule;

                        DETAILMANDATEMENTGC_.Add(DetailMandatement);
                    }
                }
                MandatementGc.DETAILMANDATEMENTGC_ = DETAILMANDATEMENTGC_;

                var mand  = ListMandatementGc.FirstOrDefault(m => m.PK_ID == MandatementGc.PK_ID);
                var index = ListMandatementGc.IndexOf(mand);
                ListMandatementGc[index] = MandatementGc;
            }

            txt_Montant_Mandatement.Text = datasource.Where(f => f.IsMontantValide == true).Sum(dm => dm.MONTANT).ToString();
        }
Example #4
0
        private void dg_facture_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)
        {
            var DetailCampagne = (CsDetailCampagneGc)dg_facture.SelectedItem;

            if (DetailCampagne != null)
            {
                if (DetailCampagne.MONTANT_VERSER > DetailCampagne.MONTANT_RESTANT)
                {
                    Message.ShowWarning("Le montant du mandatement doit être inférieur ou egale au montant restant à payer", "Avertissement");

                    var DataSource = (List <CsDetailCampagneGc>)dg_facture.ItemsSource;
                    int index      = DataSource.IndexOf(DetailCampagne);
                    DetailCampagne.MONTANT_VERSER = 0;
                    DataSource[index]             = DetailCampagne;

                    dg_facture.ItemsSource = DataSource.OrderBy(d => d.NOM).ToList();
                }
                else
                {
                    CsCampagneGc CampAnSelectioner = new CsCampagneGc();
                    CampAnSelectioner = (CsCampagneGc)dg_Campagne.SelectedItem;

                    var datasource = (List <CsDetailCampagneGc>)dg_facture.ItemsSource;
                    txt_Montant_Mandatement.Text = datasource.Sum(dm => dm.MONTANT_VERSER).ToString();

                    var MandatementGc = ListMandatementGc.FirstOrDefault(m => m.FK_IDCAMPAGNA == CampAnSelectioner.PK_ID);
                    if (MandatementGc == null)
                    {
                        var Mandatement = new CsMandatementGc {
                            FK_IDCAMPAGNA = CampAnSelectioner.PK_ID, MONTANT = datasource.Sum(dm => dm.MONTANT_VERSER), DATECREATION = DateTime.Now, DATEMODIFICATION = DateTime.Now, USERCREATION = UserConnecte.matricule, USERMODIFICATION = UserConnecte.matricule, NUMEROMANDATEMENT = txt_Numdeataire.Text
                        };
                        List <CsDetailMandatementGc> DETAILMANDATEMENTGC_ = new List <CsDetailMandatementGc>();
                        foreach (var item in datasource)
                        {
                            if (item.MONTANT_VERSER != null && item.MONTANT_VERSER > 0)
                            {
                                CsDetailMandatementGc DetailMandatement = new CsDetailMandatementGc();

                                DetailMandatement.CENTRE           = item.CENTRE;
                                DetailMandatement.CLIENT           = item.CLIENT;
                                DetailMandatement.ORDRE            = item.ORDRE;
                                DetailMandatement.DATECREATION     = DateTime.Now;
                                DetailMandatement.DATEMODIFICATION = DateTime.Now;
                                DetailMandatement.FK_IDMANDATEMENT = Mandatement.PK_ID;
                                DetailMandatement.MONTANT          = item.MONTANT_VERSER;
                                DetailMandatement.NDOC             = item.NDOC;
                                DetailMandatement.PERIODE          = item.PERIODE;
                                DetailMandatement.STATUS           = item.STATUS;
                                DetailMandatement.USERCREATION     = UserConnecte.matricule;
                                DetailMandatement.USERMODIFICATION = UserConnecte.matricule;

                                DETAILMANDATEMENTGC_.Add(DetailMandatement);
                            }
                        }
                        Mandatement.DETAILMANDATEMENTGC_ = DETAILMANDATEMENTGC_;
                        ListMandatementGc.Add(Mandatement);
                    }
                    else
                    {
                        MandatementGc.MONTANT           = datasource.Sum(dm => dm.MONTANT_VERSER);
                        MandatementGc.NUMEROMANDATEMENT = txt_Numdeataire.Text;
                        List <CsDetailMandatementGc> DETAILMANDATEMENTGC_ = new List <CsDetailMandatementGc>();
                        foreach (var item in datasource)
                        {
                            if (item.MONTANT_VERSER != null && item.MONTANT_VERSER > 0)
                            {
                                CsDetailMandatementGc DetailMandatement = new CsDetailMandatementGc();

                                DetailMandatement.CENTRE           = item.CENTRE;
                                DetailMandatement.CLIENT           = item.CLIENT;
                                DetailMandatement.ORDRE            = item.ORDRE;
                                DetailMandatement.DATECREATION     = DateTime.Now;
                                DetailMandatement.DATEMODIFICATION = DateTime.Now;
                                DetailMandatement.FK_IDMANDATEMENT = MandatementGc.PK_ID;
                                DetailMandatement.MONTANT          = item.MONTANT_VERSER;
                                DetailMandatement.NDOC             = item.NDOC;
                                DetailMandatement.PERIODE          = item.PERIODE;
                                DetailMandatement.STATUS           = item.STATUS;
                                DetailMandatement.USERCREATION     = UserConnecte.matricule;
                                DetailMandatement.USERMODIFICATION = UserConnecte.matricule;

                                DETAILMANDATEMENTGC_.Add(DetailMandatement);
                            }
                        }
                        MandatementGc.DETAILMANDATEMENTGC_ = DETAILMANDATEMENTGC_;

                        var mand  = ListMandatementGc.FirstOrDefault(m => m.PK_ID == MandatementGc.PK_ID);
                        var index = ListMandatementGc.IndexOf(mand);
                        ListMandatementGc[index] = MandatementGc;
                    }
                }
            }
        }