Пример #1
0
    protected void btnCreate_Click(object sender, EventArgs e)
    {
        List <PaymentInfo>    lastPaymentInfos = listPaymentInfos;
        GridViewRowCollection displayedRows    = gvNewPolicies.Rows;

        foreach (GridViewRow gvRow in displayedRows)
        {
            CheckBox    cbIsForCashReporting = gvRow.FindControl("cbIsForCashReporting") as CheckBox;
            int         paymentInfoID        = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value);
            PaymentInfo payI = lastPaymentInfos.Where(f => f.ID == paymentInfoID).SingleOrDefault();
            payI.IsForCashReporting = cbIsForCashReporting.Checked;
        }
        listPaymentInfos = lastPaymentInfos;
        List <PaymentInfo> listPaymentInfo = listPaymentInfos.Where(c => c.IsForCashReporting == true).ToList();

        if (listPaymentInfo.Count > 0)
        {
            DateTime   reportDate = DateTime.Parse(tbReportDate.Text);
            CashReport cr         = new CashReport();
            cr.Number             = CashReport.GetNextNumber(this.PageUser.Branch);
            cr.BranchID           = this.PageUser.BranchID;
            cr.CashReportDate     = reportDate;
            cr.CashReportStatusID = CashReportStatuse.GetByCode(CashReportStatuse.ZA_ODOBRUVANjE).ID;
            cr.Discard            = false;
            cr.IsAccountBooked    = false;
            cr.TotalValue         = 0;
            cr.Insert();
            decimal totValue = 0;
            foreach (PaymentInfo payI in listPaymentInfo)
            {
                totValue += payI.Value;
                CashReportItem cri = new CashReportItem();
                cri.PaymentID    = payI.ID;
                cri.CashReportID = cr.ID;
                cri.IsActive     = true;
                cri.Insert();
                Payment uPayment = Payment.Get(payI.ID);
                uPayment.IsCashReported = true;
                Payment.Table.Context.SubmitChanges();
            }
            CashReport crTmp = CashReport.Get(cr.ID);
            crTmp.TotalValue = totValue;
            CashReport.Table.Context.SubmitChanges();
            btnPrintCashReport.Enabled = true;
            ViewState["CashReportID"]  = cr.ID;
        }
    }
Пример #2
0
        public static void PrintCashReport(CashReport cr)
        {
            PDFCreators creator = new PDFCreators(true, 15, 15, 15, 15);

            creator.OpenPDF();
            creator.GetContentByte();
            creator.AddJDBLogoForFactures(10, 775);
            creator.SetTitleLeft10(" ");
            creator.SetTitleLeft10(" ");
            creator.SetTitleLeft10(" ");
            if (cr.Discard)
            {
                creator.SetTitleCenterForFactureNumber("СТОРНИРАН КАСОВ ИЗВЕШТАЈ бр. " + cr.Number);
            }
            else
            {
                creator.SetTitleCenterForFactureNumber("КАСОВ ИЗВЕШТАЈ бр. " + cr.Number);
            }
            creator.SetTitleLeft10("Статус: " + cr.CashReportStatuse.Name);
            creator.SetTitleLeft10("Датум: " + cr.CashReportDate.ToShortDateString());
            creator.SetTitleLeft10("Филијала: " + cr.Branch.Code + " " + cr.Branch.Name);
            List <CashReportItem> lstCRI = CashReportItem.GetByCashReport(cr.ID);

            creator.SetTitleLeft10(" ");
            creator.SetTitleLeft10("Кеш уплата");
            Broker.DataAccess.PaymentType ptCash   = Broker.DataAccess.PaymentType.GetByCode(Broker.DataAccess.PaymentType.CASH);
            List <CashReportItem>         cashList = lstCRI.Where(c => c.Payment.PaymentTypeID == ptCash.ID).ToList();

            string[]   headers          = { "Ред. бр.", "Број на полиса", "Компанија", "Подкласа", "Договорувач", "Уплата" };
            float[]    widthPercentages = { 8, 10, 17, 18, 32, 15 };
            TypeCode[] typeCodes        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
            creator.CreateTable_Facture(headers.Length, headers, widthPercentages);
            object[] values;
            int      ordinalNumber = 1;
            decimal  totCash       = 0;

            foreach (CashReportItem cri in cashList)
            {
                values    = new object[headers.Length];
                values[0] = ordinalNumber.ToString();
                values[1] = cri.Payment.Rate.PolicyItem.PolicyNumber;
                values[2] = cri.Payment.Rate.PolicyItem.Policy.InsuranceCompany.ShortName;
                values[3] = cri.Payment.Rate.PolicyItem.InsuranceSubType.ShortDescription;
                values[4] = cri.Payment.Rate.PolicyItem.Policy.Client.Name;
                values[5] = String.Format("{0:#,0.00}", cri.Payment.Value);
                creator.AddDataRowForFactures(values, headers.Length, typeCodes);
                ordinalNumber++;
                totCash += cri.Payment.Value;
            }
            values    = new object[headers.Length];
            values[0] = "";
            values[1] = "";
            values[2] = "";
            values[3] = "";
            values[4] = "Вкупно";
            values[5] = String.Format("{0:#,0.00}", totCash);
            creator.AddDataRowForFactures(values, headers.Length, typeCodes);
            creator.AddTable();

            creator.SetTitleLeft10(" ");
            creator.SetTitleLeft10("Кредитни картички");
            Broker.DataAccess.PaymentType ptCreditCard   = Broker.DataAccess.PaymentType.GetByCode(Broker.DataAccess.PaymentType.CREDITCARD);
            List <CashReportItem>         creditCardList = lstCRI.Where(c => c.Payment.PaymentTypeID == ptCreditCard.ID).ToList();

            string[]   headersCC          = { "Ред. бр.", "Број на полиса", "Компанија", "Подкласа", "Договорувач", "Банка", "Уплата" };
            float[]    widthPercentagesCC = { 7, 9, 16, 17, 27, 10, 14 };
            TypeCode[] typeCodesCC        = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal };
            creator.CreateTable_Facture(headersCC.Length, headersCC, widthPercentagesCC);
            object[] valuesCC;
            int      ordinalNumberCC = 1;
            decimal  totCreditCard   = 0;

            foreach (CashReportItem cri in creditCardList)
            {
                valuesCC    = new object[headersCC.Length];
                valuesCC[0] = ordinalNumberCC.ToString();
                valuesCC[1] = cri.Payment.Rate.PolicyItem.PolicyNumber;
                valuesCC[2] = cri.Payment.Rate.PolicyItem.Policy.InsuranceCompany.ShortName;
                valuesCC[3] = cri.Payment.Rate.PolicyItem.InsuranceSubType.ShortDescription;
                valuesCC[4] = cri.Payment.Rate.PolicyItem.Policy.Client.Name;
                if (cri.Payment.BankCreditCardID != null)
                {
                    valuesCC[5] = cri.Payment.BankCreditCard.Bank.Name;
                }
                else
                {
                    valuesCC[5] = "";
                }
                valuesCC[6] = String.Format("{0:#,0.00}", cri.Payment.Value);
                creator.AddDataRowForFactures(valuesCC, headersCC.Length, typeCodesCC);
                ordinalNumberCC++;
                totCreditCard += cri.Payment.Value;
            }
            valuesCC    = new object[headersCC.Length];
            valuesCC[0] = "";
            valuesCC[1] = "";
            valuesCC[2] = "";
            valuesCC[3] = "";
            valuesCC[4] = "";
            valuesCC[5] = "Вкупно";
            valuesCC[6] = String.Format("{0:#,0.00}", totCreditCard);
            creator.AddDataRowForFactures(valuesCC, headersCC.Length, typeCodesCC);
            creator.AddTable();
            creator.SetTitleLeft10(" ");
            creator.SetTitleRightBold14("Вкупно: " + String.Format("{0:#,0.00}", (totCreditCard + totCash)));
            creator.FinishPDF_FileName("KasovIzvestaj" + cr.ID);
        }