Esempio n. 1
0
    private void FillClientPaymentsList()
    {
        string paramStr = " ";

        if (rblActive.SelectedIndex > 0)
        {
            paramStr += " AND Active = " + rblActive.SelectedValue;
        }
        if (txtName.Text.Trim() != String.Empty)
        {
            paramStr += " AND PaymentID = " + txtName.Text;
        }
        if (Page.RouteData.Values["clientId"] != null)
        {
            long cID = Convert.ToInt64(Page.RouteData.Values["clientId"]);
            paramStr += string.Format(" AND Client_ID = {0} ", cID);

            // Assign client links.
            lnkAddPayment.HRef = string.Format("{0}{1}/addpayments.aspx", "client-", cID);

            var statistics = new SaleInvoicesManager().GetClientSalesPaymentsShortStatistics(cID);
            if (statistics != null)
            {
                //decimal invoicesVal = (decimal)result.Sum(s => s.SalePrice);
                //decimal paymVal = (decimal)result.Where(e => e.InOutType == "payment").Sum(ss => ss.ExpenseValue);
                //var firstBalance = result.FirstOrDefault().OpeningBalance;
                string usedCurrency = "(AED)"; // ((result.Where(r => r.ExchangeRate == 1).FirstOrDefault() != null) ? (result.Where(r => r.ExchangeRate == 1).FirstOrDefault().CurrencySymbol) : (result.FirstOrDefault().CurrencySymbol));
                //decimal openVal = (firstBalance != null ? (decimal)firstBalance : 0);

                divOpeningbalance.InnerHtml = string.Format("{0:F} {1}", statistics.ClientFirstBalance, usedCurrency);
                divTotalInvoices.InnerHtml  = "<a href='" + Request.Url.AbsolutePath.Replace("payments", "invoices") + "'>" + string.Format("{0:F} {1}", statistics.Invoices, usedCurrency) + "</a>";
                divTotalPayments.InnerHtml  = string.Format("{0:F} {1}", (statistics.Payments + statistics.SubPayments + statistics.InvoicesFirstAmount + statistics.NewBalance), usedCurrency);
                divRemainder.InnerHtml      = string.Format("{0:F} {1}", ((statistics.ClientFirstBalance + statistics.Invoices) - (statistics.Payments + statistics.SubPayments + statistics.InvoicesFirstAmount + statistics.NewBalance)), usedCurrency);
                if (statistics.NewBalance > 0)
                {
                    divNewBalance.InnerHtml = string.Format("<a class='toolTip' title='Divide this amount on invoices.' href='{0}-{1}/viewsubinvoices.aspx'>{2:F} {3}</a>", ResolveClientUrl("subinvoice"), cID, statistics.NewBalance, usedCurrency);
                }
                else
                {
                    divNewBalance.InnerHtml = "0.00 (AED)";
                }
            }
        }

        var result = new ClientPaymentsManager().GetClientPayments(paramStr);

        if (result != null)
        {
            gvClientPayments.DataSource = result;
            gvClientPayments.DataBind();

            if (result.FirstOrDefault() != null)
            {
                lblClientName.Text = " for: " + result.FirstOrDefault().ClientName;
            }
        }
    }
    private void ShowClientPaymentInformation(int Id)
    {
        var result = new ClientPaymentsManager().GetClientPaymentDetails(Id);

        if (result != null)
        {
            //hfID.Value = result.ClientPaymentID.ToString();
            txtDate.Text         = MinutesuaeConcrete.GetDateOnly(result.PaymentDate);
            txtPaymentValue.Text = result.PaymentValue.ToString();
            txtReceivedName.Text = result.ReceiverName;
            txtShortdesc.Text    = result.Notes;
            //cbActive.Checked = (bool)result.Active;

            ddlClients.SelectedValue    = result.Client_ID.ToString();
            ddlCurrency.SelectedValue   = result.Currency_ID.ToString();
            ddlExchangeCo.SelectedValue = result.ExchangeCompany_ID.ToString();

            if (result.Invoice_ID != null)
            {
                ltlInvoiceID.Text = result.Invoice_ID.ToString();
            }
        }
    }