private bool tranzactiiEgale(Tranzactie tranz1, Tranzactie tranz2) { bool conturiEgale = (tranz1.ContClient != null && tranz2.ContClient != null && tranz1.ContClient.IBAN == tranz2.ContClient.IBAN) || (tranz1.ContClient == null && tranz2.ContClient == null); if (conturiEgale && tranz1.ContFurnizor.IBAN == tranz2.ContFurnizor.IBAN && tranz1.Factura.Valoare == tranz2.Factura.Valoare && tranz1.TotalCost == tranz2.TotalCost && tranz1.Moneda == tranz2.Moneda && tranz1.TipOperatiune == tranz2.TipOperatiune && tranz1.ValoareTotala == tranz2.ValoareTotala) { return(true); } return(false); }
private void updateCells(int indexF) { if (scenariu[indexF].ContClient == null) { MessageBox.Show("Nu a fost selectat un cont.", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Warning); scenariuDGV.CurrentCell.Value = ""; return; } //---------------------------------------- int indexCont; try { indexCont = conturiModificabile.FindIndex(c => c.IBAN == scenariu[indexF].ContClient.IBAN); } catch { return; } // Valoarea pe care vreau sa o platesc + cost double valDePlata = valoareFactura(indexF); Operatiune op = scenariu[indexF].ContClient.ListaOperatiuni.First(o => o.Denumire == MeniuPrincipal.DENUMIRE_OP_PLATA_FACTURA); double percentCost = (op.PercentageValue ?? 0) * (valDePlata); double costOp = (op.CostFix ?? 0) + (percentCost > (op.CostMinim ?? 0) ? percentCost : op.CostMinim ?? 0); //double costOp = (op.CostFix ?? 0) + (op.PercentageValue ?? 0) * ((op.CostMinim ?? 0) > valDePlata ? (op.CostMinim ?? 0) : valDePlata); double valExtrasaDinCont = valDePlata + costOp; double valVecheExtrasaDinCont = valoareFacturaCont(indexF, indexCont); if (valVecheExtrasaDinCont == -1) { valVecheExtrasaDinCont = 0; } //double soldInitial = soldInitialCont(indexCont); double soldRamas = soldCont(indexCont); if (valExtrasaDinCont <= soldRamas + valVecheExtrasaDinCont && valDePlata != -1) { valoareFacturaCont(indexF, indexCont, valExtrasaDinCont); soldCont(indexCont, soldRamas + valVecheExtrasaDinCont - valExtrasaDinCont); Tranzactie t = scenariu[indexF]; t.ValoareFactura = valoareFactura(indexF); t.ValoareTotala = valoareFacturaCont(indexF, indexCont); t.ContClient.Sold = soldCont(indexCont); t.ContClient.DataSold = DateTime.Now; t.Costuri.Clear(); t.AdaugaCost(op); scenariuDGV.Rows[indexF + pctStart[0]].Cells[coloanaValoare].Style.BackColor = culoareZonaEditabila; } else { valoareFactura(indexF, backupValue); scenariuDGV.Rows[indexF + pctStart[0]].Cells[coloanaValoare].Style.BackColor = Color.Red; } // calculeaza totalSoldFinal pe baza tabeluului----------------------------- for (int i = 0; i < monedeScenariu.Count; i++) { double totalSoldFinal = 0; for (int j = pctStart[1]; j < pctStart[1] + conturiModificabile.Count; j++) { if (scenariuDGV.Rows[randSoldRamas - 2].Cells[j].Value.ToString() == monedeScenariu[i]) { if (Double.TryParse(scenariuDGV.Rows[randSoldRamas].Cells[j].Value.ToString(), out double v)) { totalSoldFinal += v; } } } totalSoldRamas(i, totalSoldFinal); } // Valoare totala ---------------------------------------------------- string moneda = scenariuDGV.Rows[indexF + pctStart[0]].Cells[coloanaValoare + 1].Value.ToString(); int idxTot = monedeScenariu.IndexOf(moneda); // calculeaza total de plata pe baza tabeluului double tdp = 0; for (int j = pctStart[0]; j < pctStart[0] + scenariu.Count; j++) { if (scenariuDGV.Rows[j].Cells[coloanaValoare + 1].Value.ToString() == moneda) { if (Double.TryParse(scenariuDGV.Rows[j].Cells[coloanaValoare].Value.ToString(), out double v)) { tdp += v; } } } totalDePlata(idxTot, tdp); //------------------------------------------------------------------------- }
private void populareFacturi(List <Tranzactie> tranz) { for (int i = pctStart[0]; i < scenariuDGV.Rows.Count; i++) { scenariuDGV.Rows.RemoveAt(i--); } for (int i = 0; i < tranz.Count; i++) // Tranzactie t in tranz) { { Tranzactie t = tranz[i]; scenariuDGV.Rows.Add( t.Factura.Furnizor.Nume, t.ContFurnizor.IBAN, t.ContFurnizor.Banca.Nume, t.Factura.DataEmitere.ToString("dd/MM/yyyy"), t.Factura.DataScadenta.ToString("dd/MM/yyyy"), t.Factura.Valoare.ToString("N2"), // val facturii t.ValoareFactura.ToString("N2"), // val pe care vreau sa o platesc t.Moneda, " " ); if (t.ContClient == null) { scenariuDGV.Rows[scenariuDGV.Rows.Count - 1].Cells[coloanaValoare].Value = ""; continue; } int indexCont = conturiModificabile.FindIndex(c => c.IBAN == t.ContClient.IBAN); valoareFacturaCont(i, indexCont, t.ValoareTotala); if (soldCont(indexCont) == -1) { soldCont(indexCont, soldInitialCont(indexCont) - t.ValoareTotala); } else { soldCont(indexCont, soldCont(indexCont) - t.ValoareTotala); } // calculeaza totalSoldFinal pe baza tabeluului double totalSoldFinal = 0; string monedaC = conturiModificabile[indexCont].Moneda; for (int j = pctStart[1]; j < pctStart[1] + conturiModificabile.Count; j++) { if (scenariuDGV.Rows[randSoldRamas - 2].Cells[j].Value.ToString() == monedaC) { //Debug.WriteLine(scenariuDGV.Rows[randSoldRamas].Cells[j].Value.ToString()); totalSoldFinal += Convert.ToDouble(scenariuDGV.Rows[randSoldRamas].Cells[j].Value); } } totalSoldRamas(monedeScenariu.IndexOf(monedaC), totalSoldFinal); } // Adauga totaluri scenariuDGV.Rows.Add(); for (int i = 0; i < monedeScenariu.Count(); i++) { // Calculeaza totaluri double totalFactura = scenariu.Where(s => s.Moneda == monedeScenariu[i]).Sum(t => t.Factura.Valoare); double totalCosturi = scenariu.Where(s => s.Moneda == monedeScenariu[i]).Sum(t => t.TotalCost) ?? 0; // calculeaza total de plata pe baza tabeluului double v_totalDePlata = 0; for (int j = pctStart[0]; j < pctStart[0] + scenariu.Count; j++) { if (scenariuDGV.Rows[j].Cells[coloanaValoare + 1].Value.ToString() == monedeScenariu[i]) { if (Double.TryParse(scenariuDGV.Rows[j].Cells[coloanaValoare].Value.ToString(), out double v)) { v_totalDePlata += v; } } } // Linia cu total scenariuDGV.Rows.Add( "TOTAL " + monedeScenariu[i], "-", "-", "-", "-", totalFactura.ToString("N2"), v_totalDePlata, // total de plata monedeScenariu[i] ); //lv.Items.Add(lviT); totalDePlata(i, v_totalDePlata); } }