Пример #1
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            Logging.StartFirstLevel(79);

            foreach (Control cnt in this.Controls)
            {
                if (!cnt.Visible)
                {
                    continue;
                }

                if (cnt is TextBox)
                {
                    Logging.Comment($"{cnt.Tag}: {cnt.Text}");
                }
            }

            Logging.Comment($"Объект ID:{cmbObject.SelectedValue}; Наименование:{cmbObject.Text}");
            Logging.Comment($"Тип договора ID:{cmbTypeDoc.SelectedValue}; Наименование:{cmbTypeDoc.Text}");
            Logging.Comment($"Тип оплат ID:{cmbTypePayment.SelectedValue}; Наименование:{cmbTypePayment.Text}");
            foreach (Control cnt in this.groupBox1.Controls)
            {
                if (!cnt.Visible)
                {
                    continue;
                }

                if (cnt is RadioButton)
                {
                    if ((cnt as RadioButton).Checked)
                    {
                        Logging.Comment($"Тип долгов:{cnt.Text}");
                        break;
                    }
                }
            }
            Logging.StopFirstLevel();

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

            int indexRow = 1;

            int maxColumns = 0;

            int indexSumPay = 9, indexSumItogSum = 10, indexSumOwe = 11;

            foreach (DataGridViewColumn col in dgvData.Columns)
            {
                if (col.Visible)
                {
                    maxColumns++;
                    if (col.Name.Equals("nameTenant"))
                    {
                        setWidthColumn(indexRow, maxColumns, 20, report);
                    }
                    if (col.Name.Equals("cAgreements"))
                    {
                        setWidthColumn(indexRow, maxColumns, 22, report);
                    }
                    if (col.Name.Equals("cObject"))
                    {
                        setWidthColumn(indexRow, maxColumns, 22, report);
                    }
                    if (col.Name.Equals("cPlace"))
                    {
                        setWidthColumn(indexRow, maxColumns, 35, report);
                    }
                    if (col.Name.Equals("cSumMeter"))
                    {
                        setWidthColumn(indexRow, maxColumns, 15, report);
                    }
                    if (col.Name.Equals("cSumDoc"))
                    {
                        setWidthColumn(indexRow, maxColumns, 20, report);
                    }
                    if (col.Name.Equals("cSumPay"))
                    {
                        indexSumPay = maxColumns; setWidthColumn(indexRow, maxColumns, 18, report);
                    }
                    if (col.Name.Equals("cSumItogSum"))
                    {
                        indexSumItogSum = maxColumns;
                        setWidthColumn(indexRow, maxColumns, 15, report);
                    }
                    if (col.Name.Equals("cSumOwe"))
                    {
                        indexSumOwe = maxColumns;
                        setWidthColumn(indexRow, maxColumns, 15, report);
                    }
                    if (col.Name.Equals("cPrcOwe"))
                    {
                        setWidthColumn(indexRow, maxColumns, 15, report);
                    }
                    if (col.Name.Equals("cDateCloseSection"))
                    {
                        setWidthColumn(indexRow, maxColumns, 20, report);
                    }
                    if (col.Name.Equals("cNameAddPayment"))
                    {
                        setWidthColumn(indexRow, maxColumns, 23, report);
                    }
                    //Console.WriteLine(col.Name);
                }
            }

            #region "Head"
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Журнал должников по {(rbPayDopDoc.Checked?"доп.":"")} оплатам", indexRow, 1);
            report.SetFontBold(indexRow, 1, indexRow, 1);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
            indexRow++;
            indexRow++;

            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Объект аренды: {cmbObject.Text}", indexRow, 1);
            indexRow++;

            if (tbAgreements.Text.Trim().Length > 0 || tbTenant.Text.Trim().Length > 0 || tbPlace.Text.Trim().Length > 0)
            {
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.AddSingleValue($"Фильтры: " +
                                      $"{(tbTenant.Text.Trim().Length == 0 ? "" : "Арендатор: " + tbTenant.Text.Trim())} " +
                                      $"{(tbPlace.Text.Trim().Length == 0 ? "" : "    Местоположение места аренды: " + tbPlace.Text.Trim())} " +
                                      $"{(tbAgreements.Text.Trim().Length == 0 ? "" : "   Номер договора: " + tbAgreements.Text.Trim())}", indexRow, 1);
                indexRow++;
            }

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("Выгрузил: " + Nwuram.Framework.Settings.User.UserSettings.User.FullUsername, indexRow, 1);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("Дата выгрузки: " + DateTime.Now.ToString(), indexRow, 1);
            indexRow++;
            indexRow++;
            #endregion

            #region "Блок для долгов"
            indexRow++;
            var ResultGroup = dtData.DefaultView.ToTable().AsEnumerable().GroupBy(r => r.Field <int>("id_Tenant"));
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Общее кол-во должников: {ResultGroup.Count()}", indexRow, 1);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Кол-во секций с долгами: {dtData.DefaultView.Count}", indexRow, 1);
            indexRow++;

            EnumerableRowCollection <DataRow> RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field <decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 100);
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Кол-во должников с долгом от 100% и выше: {RowCollect.Count()}", indexRow, 1);
            indexRow++;

            RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field <decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 50 && r.Field <decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") <= 99);
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Кол-во должников с долгом от 50 до 99%: {RowCollect.Count()}", indexRow, 1);
            indexRow++;


            RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field <decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 0 && r.Field <decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") <= 49);
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue($"Кол-во должников с долгом от 0 до 49%: {RowCollect.Count()}", indexRow, 1);
            indexRow++;
            indexRow++;
            #endregion



            int indexCol = 0;
            foreach (DataGridViewColumn col in dgvData.Columns)
            {
                if (col.Visible)
                {
                    indexCol++;
                    report.AddSingleValue(col.HeaderText, indexRow, indexCol);
                }
            }
            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
            report.SetBorders(indexRow, 1, indexRow, maxColumns);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
            report.SetPrintRepeatHead(indexRow, indexRow);
            indexRow++;

            foreach (DataRowView row in dtData.DefaultView)
            {
                indexCol = 1;
                report.SetWrapText(indexRow, indexCol, indexRow, maxColumns);
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        if (row[col.DataPropertyName] is DateTime)
                        {
                            report.AddSingleValue(((DateTime)row[col.DataPropertyName]).ToShortDateString(), indexRow, indexCol);
                        }
                        else
                        if (row[col.DataPropertyName] is decimal || row[col.DataPropertyName] is double)
                        {
                            report.AddSingleValueObject(row[col.DataPropertyName], indexRow, indexCol);
                            report.SetFormat(indexRow, indexCol, indexRow, indexCol, "0.00");
                        }
                        else
                        {
                            report.AddSingleValue(row[col.DataPropertyName].ToString(), indexRow, indexCol);
                        }

                        indexCol++;
                    }
                }

                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                indexRow++;
            }

            #region "Bottom"
            report.AddSingleValue($"Итого", indexRow, 1);
            report.SetBorders(indexRow, 1, indexRow, 1);

            object varSum = dtData.DefaultView.ToTable().Compute($"SUM({(rbPayDoc.Checked ? "SummaPaymentFine_1" : "SummaPaymentFine_2")})", "");
            report.AddSingleValue($"{((decimal)varSum).ToString("0.00")}", indexRow, indexSumPay);

            varSum = dtData.DefaultView.ToTable().Compute($"SUM({(rbPayDoc.Checked ? "SummaFine_1" : "SummaFine_2")})", "");
            report.AddSingleValue($"{((decimal)varSum).ToString("0.00")}", indexRow, indexSumItogSum);

            varSum = dtData.DefaultView.ToTable().Compute($"SUM({(rbPayDoc.Checked ? "SummaPenny_1" : "SummaPenny_2")})", "");
            report.AddSingleValue($"{((decimal)varSum).ToString("0.00")}", indexRow, indexSumOwe);
            report.SetFormat(indexRow, indexSumPay, indexRow, indexSumOwe, "0.00");
            report.SetBorders(indexRow, indexSumPay, indexRow, indexSumOwe);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
            indexRow++;

            /*
             * indexRow++;
             * var ResultGroup = dtData.DefaultView.ToTable().AsEnumerable().GroupBy(r => r.Field<int>("id_Tenant"));
             * report.Merge(indexRow, 1, indexRow, maxColumns);
             * report.AddSingleValue($"Общее кол-во должников: {ResultGroup.Count()}", indexRow, 1);
             * indexRow++;
             *
             *
             * EnumerableRowCollection<DataRow> RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field<decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 100);
             * report.Merge(indexRow, 1, indexRow, maxColumns);
             * report.AddSingleValue($"Кол-во должников с долгом от 100% и выше: {RowCollect.Count()}", indexRow, 1);
             * indexRow++;
             *
             * RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field<decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 50 && r.Field<decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") <= 99);
             * report.Merge(indexRow, 1, indexRow, maxColumns);
             * report.AddSingleValue($"Кол-во должников с долгом от 50 до 99%: {RowCollect.Count()}", indexRow, 1);
             * indexRow++;
             *
             *
             * RowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field<decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") >= 0 && r.Field<decimal>(rbPayDoc.Checked ? "PrcPenny_1" : "PrcPenny_2") <= 49);
             * report.Merge(indexRow, 1, indexRow, maxColumns);
             * report.AddSingleValue($"Кол-во должников с долгом от 0 до 49%: {RowCollect.Count()}", indexRow, 1);
             * indexRow++;
             */
            #endregion


            report.SetPageSetup(1, 9999, true);

            /*
             * var groupByPost = dtData.DefaultView.ToTable().AsEnumerable().GroupBy(r => new { id = r.Field<int>("id_Tenant") })
             *  .Select(s => new { s.Key.id });
             *
             * foreach (var gPost in groupByPost)
             * {
             *  EnumerableRowCollection<DataRow> rowCollect = dtData.DefaultView.ToTable().AsEnumerable().Where(r => r.Field<int>("id_Tenant") == gPost.id);
             *  int startMergRow = indexRow;
             *
             *  foreach (DataRow row in rowCollect)
             *  {
             *      indexCol = 1;
             *      report.SetWrapText(indexRow, indexCol, indexRow, maxColumns);
             *      foreach (DataGridViewColumn col in dgvData.Columns)
             *      {
             *          if (col.Visible)
             *          {
             *              if (new List<int>() { nameTenant.Index, cSumPay.Index, cSumItogSum.Index, cSumOwe.Index, cPrcOwe.Index }.Contains(col.Index))
             *              {
             *                  indexCol++;
             *                  continue;
             *              }
             *
             *
             *              if (row[col.DataPropertyName] is DateTime)
             *                  report.AddSingleValue(((DateTime)row[col.DataPropertyName]).ToShortDateString(), indexRow, indexCol);
             *              else
             *                 if (row[col.DataPropertyName] is decimal)
             *              {
             *                  report.AddSingleValueObject(row[col.DataPropertyName], indexRow, indexCol);
             *                  report.SetFormat(indexRow, indexCol, indexRow, indexCol, "0.00");
             *              }
             *              else
             *                  report.AddSingleValue(row[col.DataPropertyName].ToString(), indexRow, indexCol);
             *
             *              indexCol++;
             *          }
             *      }
             *
             *      report.SetBorders(indexRow, 1, indexRow, maxColumns);
             *      report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
             *      report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
             *      indexRow++;
             *  }
             *
             *  indexCol = 1;
             *  foreach (DataGridViewColumn col in dgvData.Columns)
             *  {
             *      if (new List<int>() { nameTenant.Index, cSumPay.Index, cSumItogSum.Index, cSumOwe.Index, cPrcOwe.Index }.Contains(col.Index))
             *      {
             *          report.Merge(startMergRow, indexCol, indexRow - 1, indexCol);
             *
             *          if (rowCollect.First()[col.DataPropertyName] is DateTime)
             *              report.AddSingleValue(((DateTime)rowCollect.First()[col.DataPropertyName]).ToShortDateString(), startMergRow, indexCol);
             *          else
             *               if (rowCollect.First()[col.DataPropertyName] is decimal)
             *          {
             *              report.AddSingleValueObject(rowCollect.First()[col.DataPropertyName], startMergRow, indexCol);
             *              report.SetFormat(startMergRow, indexCol, startMergRow, indexCol, "0.00");
             *          }
             *          else
             *              report.AddSingleValue(rowCollect.First()[col.DataPropertyName].ToString(), startMergRow, indexCol);
             *
             *      }
             *      indexCol++;
             *  }
             * }
             */

            report.Show();
        }
Пример #2
0
        private async void btPrint_Click(object sender, EventArgs e)
        {
            report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
            blockers.SaveControlsEnabledState(this);
            blockers.SetControlsEnabled(this, false);
            progressBar1.Visible = true;

            var result = await Task <bool> .Factory.StartNew(() =>
            {
                DataTable dtReport = _proc.GetReportPayAgreement(dtpStart.Value.Date, dtpEnd.Value.Date);


                if (dtReport == null || dtReport.Rows.Count == 0)
                {
                    DoOnUIThread(() =>
                    {
                        MessageBox.Show("Нет данных для выгрузки", "Выгрузка отчёта", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        blockers.RestoreControlEnabledState(this);
                        progressBar1.Visible = false;
                    }, this);
                    return(false);
                }

                Logging.StartFirstLevel(79);
                Logging.Comment("Выгрузка отчёта по добавленным оплатам");
                Logging.StopFirstLevel();

                int indexRow     = 1;
                int maxColumns   = 9;
                bool isFirstLoad = false;

                List <int> numbers = new List <int>()
                {
                    1, 3, 2
                };
                //for (int i = 1; i <= 3; i++)
                foreach (int i in numbers)
                {
                    EnumerableRowCollection <DataRow> rowCollect = dtReport.AsEnumerable()
                                                                   .Where(r => r.Field <int>("id_PayType") == i)
                                                                   .OrderBy(r => r.Field <DateTime>("Date"));
                    if (rowCollect.Count() == 0)
                    {
                        continue;
                    }


                    if (!isFirstLoad)
                    {
                        isFirstLoad = true;
                        report.changeNameTab(rowCollect.First()["namePayType"].ToString());
                    }
                    else
                    {
                        report.GoToNextSheet(rowCollect.First()["namePayType"].ToString());
                    }

                    indexRow = 1;

                    #region "Head"
                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"{rowCollect.First()["namePayType"]}", indexRow, 1);
                    report.SetFontBold(indexRow, 1, indexRow, 1);
                    report.SetFontSize(indexRow, 1, indexRow, 1, 16);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                    indexRow++;
                    indexRow++;


                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue("Выгрузил: " + Nwuram.Framework.Settings.User.UserSettings.User.FullUsername, indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue("Дата выгрузки: " + DateTime.Now.ToString(), indexRow, 1);
                    indexRow++;
                    indexRow++;
                    #endregion

                    setWidthColumn(indexRow, 1, 21, report);
                    setWidthColumn(indexRow, 2, 21, report);
                    setWidthColumn(indexRow, 3, 20, report);
                    setWidthColumn(indexRow, 4, 30, report);

                    report.AddSingleValue("Арендодатель", indexRow, 1);
                    report.AddSingleValue("Арендатор", indexRow, 2);
                    report.AddSingleValue("Номер договора", indexRow, 3);
                    report.AddSingleValue("Местоположение по договору", indexRow, 4);
                    report.SetPrintRepeatHead(indexRow, indexRow);

                    #region "Обеспечительный платёж"
                    if (i == 1)
                    {
                        maxColumns = 8;
                        setWidthColumn(indexRow, 5, 14, report);
                        setWidthColumn(indexRow, 6, 17, report);
                        setWidthColumn(indexRow, 7, 20, report);

                        report.AddSingleValue("Дата оплаты", indexRow, 5);
                        report.AddSingleValue("Сумма оплаты", indexRow, 6);
                        report.AddSingleValue("Тип обеспечительного платежа", indexRow, 7);
                        report.AddSingleValue("Тип операции", indexRow, 8);


                        report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                        report.SetBorders(indexRow, 1, indexRow, maxColumns);
                        report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                        indexRow++;

                        EnumerableRowCollection <DataRow> Rows = rowCollect.Where(r => r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Наличные", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);

                                    addDataToCell(row["Date"], indexRow, 5, report);
                                    addDataToCell(row["Summa"], indexRow, 6, report);
                                    addDataToCell(row["nameSavePayment"], indexRow, 7, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 8, report);


                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }

                        Rows = rowCollect.Where(r => !r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Безналичный расчёт", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);

                                    addDataToCell(row["Date"], indexRow, 5, report);
                                    addDataToCell(row["Summa"], indexRow, 6, report);
                                    addDataToCell(row["nameSavePayment"], indexRow, 7, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 8, report);

                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }
                    }
                    #endregion

                    #region "Оплата аренды"
                    if (i == 2)
                    {
                        maxColumns = 8;
                        setWidthColumn(indexRow, 5, 14, report);
                        setWidthColumn(indexRow, 6, 17, report);
                        setWidthColumn(indexRow, 7, 10, report);
                        setWidthColumn(indexRow, 8, 17, report);

                        report.AddSingleValue("Дата оплаты", indexRow, 5);
                        report.AddSingleValue("Сумма оплаты", indexRow, 6);
                        report.AddSingleValue("Тип операции", indexRow, 7);
                        report.AddSingleValue("План в который попадает оплата", indexRow, 8);


                        report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                        report.SetBorders(indexRow, 1, indexRow, maxColumns);
                        report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                        indexRow++;

                        EnumerableRowCollection <DataRow> Rows = rowCollect.Where(r => r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Наличные", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);

                                    addDataToCell(row["Date"], indexRow, 5, report);
                                    addDataToCell(row["Summa"], indexRow, 6, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 7, report);
                                    addDataToCell(row["PlaneDate"], indexRow, 8, report);

                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }

                        Rows = rowCollect.Where(r => !r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Безналичный расчёт", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);

                                    addDataToCell(row["Date"], indexRow, 5, report);
                                    addDataToCell(row["Summa"], indexRow, 6, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 7, report);
                                    addDataToCell(row["PlaneDate"], indexRow, 8, report);

                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }
                    }
                    #endregion

                    #region "Дополнительная оплата"
                    if (i == 3)
                    {
                        maxColumns = 10;
                        setWidthColumn(indexRow, 5, 17, report);
                        setWidthColumn(indexRow, 6, 13, report);
                        setWidthColumn(indexRow, 7, 12, report);
                        setWidthColumn(indexRow, 8, 12, report);
                        setWidthColumn(indexRow, 9, 15, report);
                        setWidthColumn(indexRow, 10, 13, report);


                        report.AddSingleValue("Тип доп оплаты", indexRow, 5);
                        report.AddSingleValue("Дата выписки оплаты", indexRow, 6);
                        report.AddSingleValue("Дата оплаты", indexRow, 7);
                        report.AddSingleValue("Сумма оплаты", indexRow, 8);
                        report.AddSingleValue("Тип операции", indexRow, 9);
                        report.AddSingleValue("План в который попадает оплата", indexRow, 10);


                        report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                        report.SetBorders(indexRow, 1, indexRow, maxColumns);
                        report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                        report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                        indexRow++;

                        EnumerableRowCollection <DataRow> Rows = rowCollect.Where(r => r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Наличные", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);


                                    addDataToCell(row["nameAddPayment"], indexRow, 5, report);
                                    addDataToCell(row["DateFines"], indexRow, 6, report);

                                    addDataToCell(row["Date"], indexRow, 7, report);
                                    addDataToCell(row["Summa"], indexRow, 8, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 9, report);
                                    addDataToCell(row["PlaneDate"], indexRow, 10, report);

                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }

                        Rows = rowCollect.Where(r => !r.Field <bool>("isCash"));
                        if (Rows.Count() > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxColumns);
                            report.AddSingleValue("Безналичный расчёт", indexRow, 1);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            indexRow++;

                            var gData = Rows.AsEnumerable().GroupBy(g => new { Date = g.Field <DateTime>("Date") }).Select(s => new { s.Key.Date });
                            foreach (var rData in gData)
                            {
                                report.Merge(indexRow, 1, indexRow, maxColumns);
                                report.AddSingleValue($"{rData.Date.ToShortDateString()}", indexRow, 1);
                                report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                                report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                indexRow++;

                                foreach (DataRow row in Rows.AsEnumerable().Where(r => r.Field <DateTime>("Date").Date == rData.Date))
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    addDataToCell(row["nameTenant"], indexRow, 1, report);
                                    addDataToCell(row["nameLandLord"], indexRow, 2, report);
                                    addDataToCell(row["Agreement"], indexRow, 3, report);
                                    addDataToCell(row["namePlace"], indexRow, 4, report);

                                    addDataToCell(row["nameAddPayment"], indexRow, 5, report);
                                    addDataToCell(row["DateFines"], indexRow, 6, report);

                                    addDataToCell(row["Date"], indexRow, 7, report);
                                    addDataToCell(row["Summa"], indexRow, 8, report);
                                    addDataToCell(row["nameToTenant"], indexRow, 9, report);
                                    addDataToCell(row["PlaneDate"], indexRow, 10, report);

                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                }
                            }
                        }
                    }
                    #endregion

                    report.SetPageSetup(1, 9999, true);
                }

                report.Show();


                DoOnUIThread(() =>
                {
                    blockers.RestoreControlEnabledState(this);
                    progressBar1.Visible = false;
                }, this);

                return(true);
            });
        }