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(); } }
void SetDetails(int row) { try { //getting details var details = new DetailsDossier(); var idg = TableGetID_GF(row); if (idg == 0) { return; } var groupe = details.GetGroupeInfo(idg); if (groupe == null) { return; } var promotion = details.GetPromoInfo(groupe.ID_LIGNE ?? 0); //getting invoices nums var factures = details.GetFactures(idg); var listeFactures = ""; factures.ForEach(x => listeFactures += x.NUM_FACT + @" | "); listeFactures = listeFactures.Remove(listeFactures.Length - 2); tableFactures.Controls.Clear(); int i = 0, l = 0; factures.ForEach(f => { if (i > 5) { i = 0; l++; } var linkFacture = new LinkLabel { Text = ((int)f.NUM_FACT).ToString("D"), LinkColor = Color.DimGray, Font = new Font("Segoe UI Semibold", 8.5F, FontStyle.Bold, GraphicsUnit.Point, ((0))) }; linkFacture.Click += (sender, args) => ViewFacture(f.NUM_FACT, f.CODE_CLIENT, f.ENTITE); tableFactures.Controls.Add(linkFacture, i, l); i++; }); //Setting details to the view textBoxPromotion.Text = promotion.NOM_PROMOTION; NomClient = textBoxClient.Text = TableGetClientName(row); textBoxFactures.Text = listeFactures; textBoxDateD.Text = groupe.DATE_DOSSIER != null?groupe.DATE_DOSSIER.Value.ToShortDateString() : default(string); decimal txRest = 0; decimal.TryParse(groupe.REF_RISTOURNE, out txRest); if (groupe.MONTANT_RISTOURNE > 0) { decimal.TryParse(groupe.REF_RISTOURNE, out txRest); } else { txRest = groupe.TX_REST ?? 0; } textBoxNumDossier.Text = groupe.NDOSSIER; textBoxMarge.Text = string.Format("{0:#,##0.00 Da}", groupe.MARGE); textBoxMarge.Text += @" ( " + string.Format("{0:P2}", groupe.MARGE / groupe.MNT_TTC) + @" )"; textBoxMargeRest.Text = string.Format("{0:#,##0.00 Da}", groupe.MARGE_REST - groupe.MONTANT_RISTOURNE ?? 0); textBoxMargeRest.Text += @" ( " + string.Format("{0:P2}", txRest / 100) + @" )"; textBoxTypePromo.Text = groupe.TYPE_PROMOTION; } catch (Exception ex) { Messages.Error("Erreur lecture de données"); ErrorLog.LogError("set details", ex); Close(); } }
private void LoadAvoir(AVOIR_FINANCIER avoir) { try { using (var model = new ExpFinanceEntities()) { var detail = new DetailsDossier(); //Set références _numAvoir = avoir.numAvoir; textBoxRefAvoir.Text = _numAvoir.ToString("D"); _montant = avoir.montant; _cheque = avoir.montantCheque; _creance = avoir.montantCreance; _observation = avoir.Observation; textBoxDesc.Text = avoir.designation; textBoxObservation.Text = avoir.Observation; dateAvoir.Value = avoir.dateAvoir; //Get cheques _chequesList = (from c in model.CHEQUE where c.numAvoir == avoir.numAvoir select c).ToList(); RebindListBoxCheque(); TotalCheque(); //Set type switch (avoir.typeAvoir) { case 1: _isCheque = true; _isCreance = false; break; case 2: _isCreance = true; _isCheque = false; break; case 3: _isCheque = _isCreance = true; break; default: _isCheque = _isCreance = false; break; } //Get Groupe Factures related to the avoir _numGroupe = (from afg in model.AF_AVOIR_GROUPE where afg.numAvoir == _numAvoir select afg.IDG).ToList(); // ReSharper disable once ConstantNullCoalescingCondition if (_numGroupe.Count == 0) { throw new NullReferenceException("Les groupse factures liés à cette avoir n'existe plus !"); } // 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); //disable facture item check listViewFactures.ItemCheck -= listViewFactures_ItemCheck; foreach (ListViewItem item in listViewFactures.Items) { item.Checked = true; } //set totals values decimal t, m; TotalFactures(out t, out m); //set reste _reste = _montant - (_creance + _cheque); textBoxMontantAv.Text = $"{_montant:#,##0.00}"; textBoxCreance.Text = $"{_creance:#,##0.00}"; //enable facture item check listViewFactures.ItemCheck += listViewFactures_ItemCheck; CheckType(); } } catch (Exception e) { Messages.Error("Error Loading avoir :" + e.Message); ErrorLog.LogError("Error Loading avoir", e); Close(); } }