private void SumPayments(SumPaymentList xSumPaymentList) { int iColDraft = -1; int iCol = -1; int iColPayment = -1; if (IsDocInvoice) { iColDraft = dt_XInvoice.Columns.IndexOf("JOURNAL_DocInvoice_$_dinv_$$Draft"); iCol = dt_XInvoice.Columns.IndexOf("JOURNAL_DocInvoice_$_dinv_$$GrossSum"); iColPayment = dt_XInvoice.Columns.IndexOf("JOURNAL_DocInvoice_$_dinv_$_metopay_$$PaymentType"); } else if (IsDocProformaInvoice) { iColDraft = dt_XInvoice.Columns.IndexOf("JOURNAL_DocProformaInvoice_$_dpinv_$$Draft"); iCol = dt_XInvoice.Columns.IndexOf("JOURNAL_DocProformaInvoice_$_dpinv_$$GrossSum"); iColPayment = dt_XInvoice.Columns.IndexOf("JOURNAL_DocProformaInvoice_$_dpinv_$_metopay_$$PaymentType"); } int iCount = dt_XInvoice.Rows.Count; int i = 0; for (i = 0; i < iCount; i++) { if ((bool)dt_XInvoice.Rows[i][iColDraft]) { continue; } else { if (dt_XInvoice.Rows[i][iColPayment] is string) { xSumPaymentList.Add((decimal)dt_XInvoice.Rows[i][iCol], (string)dt_XInvoice.Rows[i][iColPayment]); } } } }
private void SetLabels() { if (dt_XInvoice.Rows.Count>0) { string currency_symbol = GlobalData.BaseCurrency.Symbol; SumPaymentList xSumPaymentList = new SumPaymentList(); SumPayments(xSumPaymentList); if (xSumPaymentList.SumPayment_List.Count > 0) { lbl_Payment1.Text = xSumPaymentList.SumPayment_List[0].PaymentType + " = " + xSumPaymentList.SumPayment_List[0].Sum.ToString() + " " + currency_symbol; } if (xSumPaymentList.SumPayment_List.Count > 1) { lbl_Payment2.Text = xSumPaymentList.SumPayment_List[1].PaymentType + " = " + xSumPaymentList.SumPayment_List[1].Sum.ToString() + " " + currency_symbol; } decimal gross_sum = 0; decimal net_sum = 0; decimal tax_sum = 0; if (IsDocInvoice) { gross_sum = Sum("JOURNAL_DocInvoice_$_dinv_$$GrossSum"); net_sum = Sum("JOURNAL_DocInvoice_$_dinv_$$NetSum"); tax_sum = Sum("JOURNAL_DocInvoice_$_dinv_$$TaxSum"); } else if (IsDocProformaInvoice) { gross_sum = Sum("JOURNAL_DocProformaInvoice_$_dpinv_$$GrossSum"); net_sum = Sum("JOURNAL_DocProformaInvoice_$_dpinv_$$NetSum"); tax_sum = Sum("JOURNAL_DocProformaInvoice_$_dpinv_$$TaxSum"); } lbl_Sum_All.Text = lngRPM.s_Sum_All.s + gross_sum.ToString() + " " + currency_symbol; lbl_Sum_Tax.Text = lngRPM.s_Sum_Tax.s + tax_sum.ToString() + " " + currency_symbol; ; lbl_Sum_WithoutTax.Text = lngRPM.s_Sum_WithoutTax.s + net_sum.ToString() + " " + currency_symbol; } else { lbl_Sum_All.Text = ""; lbl_Sum_Tax.Text = ""; lbl_Sum_WithoutTax.Text = ""; lbl_Payment2.Text = ""; lbl_Payment1.Text = ""; } }