Exemplo n.º 1
0
        private void LoadNewAvoir()
        {
            try
            {
                var detail = new DetailsDossier();

                //Set référence
                _numAvoir            = detail.GetLastAvoirId(dateAvoir.Value);
                textBoxRefAvoir.Text = _numAvoir.ToString("D");

                if (_numGroupe.Count != 0)
                {
                    // _montant = detail.GetGroupeInfo(_numGroupe).MNT_HT ?? 0;

                    // var factures = detail.GetFactures(_numGroupe);
                    var factures = new List <FACTURE>();

                    //Get factures of each groupe then put them all in one list
                    _numGroupe.ForEach(g =>
                    {
                        var groupeFactures = detail.GetFactures(g);
                        //add each groupe factures to the global list
                        groupeFactures.ForEach(factures.Add);
                    });

                    PopulateFacutresListView(factures);
                    foreach (ListViewItem item in listViewFactures.Items)
                    {
                        item.Checked = true;
                    }
                    textBoxMontantAv.Text = string.Format("{0:#,##0.00}", _montant);
                    textBoxCreance.Text   = string.Format("{0:#,##0.00}", _reste);
                }
                //set totals values
                decimal t, m;
                TotalFactures(out t, out m);

                //disable facture item check
                listViewFactures.ItemCheck += listViewFactures_ItemCheck;
                _designation = textBoxDesc.Text;
                Calculation();
                CheckType();
            }
            catch (Exception e)
            {
                Messages.Error("Error Creating avoir :" + e.Message);
                ErrorLog.LogError("Error Creating avoir", e);
                Close();
            }
        }
Exemplo n.º 2
0
 private void AvoirForm_Load(object sender, EventArgs e)
 {
     try
     {
         // TODO: This line of code loads data into the 'clientDataSet.Client' table. You can move, or remove it, as needed.
         clientTableAdapter.Fill(clientDataSet.AF_CLIENT, Settings.Default.entite);
         var detail = new DetailsDossier();
         //Set référence
         _numAvoir            = detail.GetLastAvoirId(dateAvoir.Value);
         textBoxRefAvoir.Text = _numAvoir.ToString("D");
         dateExercice.Value   = dateExercice.Maximum = DateTime.Now.Year - 1;
         Calculation();
         CheckType();
         PopulateComboxBoxPalierEf();
         PopulateComboboxPromotion();
     }
     catch (Exception ex)
     {
         Messages.Error(ex.Message);
         ErrorLog.LogError("Load", ex);
         Close();
     }
 }
Exemplo n.º 3
0
        private bool InsertAvoir(AVOIR_FINANCIER avoir)
        {
            try
            {
                decimal mntAv;
                decimal.TryParse(textBoxMontantAv.Text, out mntAv);

                using (var model = new ExpFinanceEntities())
                {
                    var detail = new DetailsDossier();


                    //Set référence (if new avoir get the new num according to the year)
                    if (_avoir == null)
                    {
                        _numAvoir = detail.GetLastAvoirId(dateAvoir.Value);
                    }

                    avoir.numAvoir       = _numAvoir;
                    avoir.montant        = mntAv;
                    avoir.dateAvoir      = dateAvoir.Value.Date;
                    avoir.designation    = _designation;
                    avoir.montantCheque  = _cheque;
                    avoir.montantCreance = _creance;
                    avoir.Observation    = _observation;
                    avoir.typeAvoir      = (byte)_typeAvoir;
                    model.AVOIR_FINANCIER.AddOrUpdate(avoir);


                    var op = new AF_OPS_LOG
                    {
                        instant   = DateTime.Now,
                        username  = Environment.UserName,
                        numavoir  = _numAvoir,
                        Operation = "Avoir inséré"
                    };

                    model.AF_OPS_LOG.Add(op);


                    //insert the related groups
                    foreach (int g in _numGroupe)
                    {
                        var avoirGroupe = new AF_AVOIR_GROUPE
                        {
                            numAvoir = avoir.numAvoir,
                            IDG      = g,
                            Libre    = 0
                        };

                        model.AF_AVOIR_GROUPE.Add(avoirGroupe);
                    }

                    //Insert in the etat table
                    foreach (int g in _numGroupe)
                    {
                        var etat = new AF_ETAT_AVOIR
                        {
                            numDossier = detail.GetGroupeInfo(g).NDOSSIER,
                            numAvoir   = avoir.numAvoir,
                            IDG        = g,
                            Etat       = 3,
                            dateHeure  = DateTime.Now
                        };

                        model.AF_ETAT_AVOIR.Add(etat);
                    }


                    model.SaveChanges();
                    return(true);
                }
            }

            catch (Exception ex)
            {
                Messages.Error("Erreur insertion avoir:" + ex.Message);
                ErrorLog.LogError("Erreur insertion avoir", ex);
                return(false);
            }
        }
Exemplo n.º 4
0
        private bool InsertAvoir(AVOIR_FINANCIER avoir)
        {
            try
            {
                decimal mntAv;
                decimal.TryParse(textBoxMontantAv.Text, out mntAv);

                using (var model = new ExpFinanceEntities())
                {
                    var detail = new DetailsDossier();

                    //Set référence
                    _numAvoir            = detail.GetLastAvoirId(dateAvoir.Value);
                    textBoxRefAvoir.Text = _numAvoir.ToString("D");
                    int codePromo;
                    int.TryParse(comboBoxPromotions.SelectedValue?.ToString(), out codePromo);

                    avoir.numAvoir          = _numAvoir;
                    avoir.montant           = mntAv;
                    avoir.dateAvoir         = dateAvoir.Value.Date;
                    avoir.designation       = textBoxDesc.Text;
                    avoir.montantCheque     = _cheque;
                    avoir.montantCreance    = _creance;
                    avoir.Observation       = _observation;
                    avoir.typeAvoir         = (byte)_typeAvoir;
                    avoir.numAvoirComptable = codePromo;

                    var op = new AF_OPS_LOG
                    {
                        instant   = DateTime.Now,
                        username  = Environment.UserName,
                        numavoir  = _numAvoir,
                        Operation = "Avoir inséré"
                    };

                    model.AF_OPS_LOG.Add(op);
                    //int nac;
                    //if (int.TryParse(textBoxNAC.Text, out nac))
                    //{
                    //    avoir.numAvoirComptable = nac;
                    //}

                    var libre = _isFacture ? (byte)1 : (byte)2;

                    //insert the related group
                    var avoirGroupe = new AF_AVOIR_GROUPE
                    {
                        numAvoir = avoir.numAvoir,
                        IDG      = _numGroupe,
                        Libre    = libre
                    };

                    model.AF_AVOIR_GROUPE.Add(avoirGroupe);


                    //Insert in the etat table
                    var etat = new AF_ETAT_AVOIR
                    {
                        numDossier = _nDossier,
                        numAvoir   = avoir.numAvoir,
                        IDG        = _numGroupe,
                        Etat       = 3,
                        dateHeure  = DateTime.Now
                    };

                    model.AF_ETAT_AVOIR.Add(etat);

                    model.AVOIR_FINANCIER.Add(avoir);
                    model.SaveChanges();
                    return(true);
                }
            }
            catch (Exception e)
            {
                Messages.Error(@"Erreur insertion avoir financier: ");
                ErrorLog.LogError(@"Erreur insertion avoir financier: ", e);
                return(false);
            }
        }