Esempio n. 1
0
        private async void btPrintRow_Click(object sender, EventArgs e)
        {
            if (dgvData.CurrentRow != null && dgvData.CurrentRow.Index != -1 && dtData != null && dtData.DefaultView.Count != 0)
            {
                DataRowView rowSelect = dtData.DefaultView[dgvData.CurrentRow.Index];

                int       id     = (int)rowSelect["id"];
                DataTable dtBody = Config.hCntMain.getRouteBody(id).Result;

                if (dtBody == null || dtBody.Rows.Count == 0)
                {
                    return;
                }

                await Task.Factory.StartNew(() =>
                {
                    Config.DoOnUIThread(() =>
                    {
                        blockers.SaveControlsEnabledState(this);
                        blockers.SetControlsEnabled(this, false);
                        //progressBar1.Visible = progressBar1.Enabled = true;
                        fLoad          = new Nwuram.Framework.UI.Forms.frmLoad();
                        fLoad.TopMost  = false;
                        fLoad.Owner    = this;
                        fLoad.TextWait = "Грузим отчётик!";
                        fLoad.Show();
                    }, this);

                    //if (report == null)
                    report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

                    int indexRow = 1;
                    int maxCol   = 5;

                    setWidthColumn(indexRow, 1, 14, report);
                    setWidthColumn(indexRow, 2, 15, report);
                    setWidthColumn(indexRow, 3, 40, report);
                    setWidthColumn(indexRow, 4, 13, report);
                    setWidthColumn(indexRow, 5, 13, report);

                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"Маршрут №{rowSelect["RouteNumber"]}", indexRow, 1);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                    report.SetFontSize(indexRow, 1, indexRow, 1, 18);
                    indexRow++;
                    indexRow++;


                    Config.DoOnUIThread(() =>
                    {
                        report.Merge(indexRow, 1, indexRow, maxCol);
                        report.AddSingleValue($"{label3.Text} {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
                        indexRow++;

                        report.Merge(indexRow, 1, indexRow, maxCol);
                        report.AddSingleValue($"{label5.Text}:{cmbDriver.Text}", indexRow, 1);
                        indexRow++;

                        report.Merge(indexRow, 1, indexRow, maxCol);
                        report.AddSingleValue($"{label6.Text}:{cmbShop.Text}", indexRow, 1);
                        indexRow++;

                        if (tbNumber.Text.Length > 0 || tbFioMan.Text.Length > 0)
                        {
                            report.Merge(indexRow, 1, indexRow, maxCol);
                            string str = "Фильтры: ";
                            if (tbNumber.Text.Length > 0)
                            {
                                str += $"Номер маршрута: {tbNumber.Text};";
                            }
                            if (tbFioMan.Text.Length > 0)
                            {
                                str += $"Водитель: {tbFioMan.Text};";
                            }
                            report.AddSingleValue($"{str}", indexRow, 1);


                            indexRow++;
                        }

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

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

                    report.AddSingleValue("№ заказа в маршруте", indexRow, 1);
                    report.AddSingleValue("№ заказа", indexRow, 2);
                    report.AddSingleValue("Адрес доставки", indexRow, 3);
                    report.AddSingleValue("Вес заказа, кг", indexRow, 4);
                    report.AddSingleValue("Длина маршрута, км", indexRow, 5);

                    report.SetFontBold(indexRow, 1, indexRow, maxCol);
                    report.SetBorders(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxCol);
                    report.SetWrapText(indexRow, 1, indexRow, maxCol);
                    indexRow++;
                    dtBody.DefaultView.Sort = "RouteNumber asc";
                    foreach (DataRowView row in dtBody.DefaultView)
                    {
                        setValueToCell(indexRow, 1, row["RouteNumber"]);
                        setValueToCell(indexRow, 2, row["OrderNumber"]);
                        setValueToCell(indexRow, 3, row["Address"]);
                        setValueToCell(indexRow, 4, row["weigth"]);
                        setValueToCell(indexRow, 5, row["RouteLength"]);

                        report.SetBorders(indexRow, 1, indexRow, maxCol);
                        report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxCol);
                        report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxCol);
                        report.SetCellAlignmentToRight(indexRow, 4, indexRow, 5);
                        indexRow++;
                    }

                    setValueToCell(indexRow, 3, "Итого");
                    decimal routeWeigth = dtBody.AsEnumerable().Sum(r => r.Field <decimal>("weigth"));
                    setValueToCell(indexRow, 4, routeWeigth);
                    decimal routeLength = dtBody.AsEnumerable().Sum(r => r.Field <decimal>("RouteLength"));
                    setValueToCell(indexRow, 5, routeLength);
                    report.SetBorders(indexRow, 1, indexRow, maxCol);
                    indexRow++;

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

                    Config.DoOnUIThread(() =>
                    {
                        blockers.RestoreControlEnabledState(this);
                        fLoad.Dispose();
                    }, this);
                });
            }
        }
Esempio n. 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;

            DateTime date = new DateTime(dtpYear.Value.Year, dtpMonth.Value.Month, 1);

            var result = await Task <bool> .Factory.StartNew(() =>
            {
                DataTable dtReport = _proc.GetReportFinesPay(date.Date);

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


                int indexRow   = 1;
                int maxColumns = 11;

                setWidthColumn(indexRow, 1, 8, report);
                setWidthColumn(indexRow, 2, 12, report);
                setWidthColumn(indexRow, 3, 30, report);
                setWidthColumn(indexRow, 4, 10, report);
                setWidthColumn(indexRow, 5, 17, report);
                setWidthColumn(indexRow, 6, 18, report);
                setWidthColumn(indexRow, 7, 10, report);
                setWidthColumn(indexRow, 8, 17, report);
                setWidthColumn(indexRow, 9, 18, report);



                #region "Head"
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.AddSingleValue($"Отчёт по дополнительным оплатам за {monthNames[date.Month - 1]} {date.Year}", 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


                report.AddSingleValue("№", indexRow, 1);
                report.AddSingleValue("Объект", indexRow, 2);
                report.AddSingleValue("Арендатор", indexRow, 3);
                report.AddSingleValue("№ договора", indexRow, 4);
                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.AddSingleValue("Примечание", indexRow, 11);

                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++;

                int npp = 1;
                foreach (DataRow row in dtReport.Rows)
                {
                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                    addDataToCell(npp, indexRow, 1, report);
                    addDataToCell(row["nameObject"], indexRow, 2, report);
                    addDataToCell(row["nameTenant"], indexRow, 3, report);
                    addDataToCell(row["Agreement"], indexRow, 4, report);
                    addDataToCell(row["cName"], indexRow, 5, report);
                    addDataToCell(row["Summa"], indexRow, 6, report);

                    addDataToCell(row["DateFines"], indexRow, 7, report);
                    addDataToCell(row["MetersData"], indexRow, 8, report);
                    addDataToCell(row["sumPay"], indexRow, 9, report);
                    addDataToCell(row["resultSum"], indexRow, 10, report);
                    addDataToCell(row["Comment"], indexRow, 11, report);

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



                addDataToCell("Итого", indexRow, 5, report);

                object objValue = dtReport.Compute("SUM(Summa)", "");
                addDataToCell(objValue, indexRow, 6, report);

                objValue = dtReport.Compute("SUM(sumPay)", "");
                addDataToCell(objValue, indexRow, 9, report);

                objValue = dtReport.Compute("SUM(resultSum)", "");
                addDataToCell(objValue, indexRow, 10, report);

                report.SetBorders(indexRow, 5, indexRow, 6);
                report.SetBorders(indexRow, 9, indexRow, 10);
                report.SetFontBold(indexRow, 1, indexRow, maxColumns);

                indexRow++;


                report.SetPageSetup(1, 9999, false);
                report.Show();


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

                return(true);
            });
        }
Esempio n. 3
0
        private async void BtPrint_Click(object sender, EventArgs e)
        {
            await Task.Factory.StartNew(() =>
            {
                Config.DoOnUIThread(() =>
                {
                    blockers.SaveControlsEnabledState(this);
                    blockers.SetControlsEnabled(this, false);
                    //progressBar1.Visible = progressBar1.Enabled = true;
                    fLoad          = new Nwuram.Framework.UI.Forms.frmLoad();
                    fLoad.TopMost  = false;
                    fLoad.Owner    = this;
                    fLoad.TextWait = "Грузим отчётик!";
                    fLoad.Show();
                }, this);

                //if (report == null)
                report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

                int indexRow = 1;
                int maxCol   = 0;

                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        maxCol++;
                    }
                }


                setWidthColumn(indexRow, 1, 13, report);
                setWidthColumn(indexRow, 2, 16, report);
                setWidthColumn(indexRow, 3, 25, report);
                setWidthColumn(indexRow, 4, 25, report);
                setWidthColumn(indexRow, 5, 17, report);
                setWidthColumn(indexRow, 6, 17, report);
                setWidthColumn(indexRow, 7, 20, report);

                report.Merge(indexRow, 1, indexRow, maxCol);
                report.AddSingleValue($"{this.Text}", indexRow, 1);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                report.SetFontSize(indexRow, 1, indexRow, 1, 18);
                indexRow++;
                indexRow++;


                Config.DoOnUIThread(() =>
                {
                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"{label3.Text} {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"{label5.Text}:{cmbDriver.Text}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"{label6.Text}:{cmbShop.Text}", indexRow, 1);
                    indexRow++;

                    if (tbNumber.Text.Length > 0 || tbFioMan.Text.Length > 0)
                    {
                        report.Merge(indexRow, 1, indexRow, maxCol);
                        string str = "Фильтры: ";
                        if (tbNumber.Text.Length > 0)
                        {
                            str += $"Номер маршрута: {tbNumber.Text};";
                        }
                        if (tbFioMan.Text.Length > 0)
                        {
                            str += $"Водитель: {tbFioMan.Text};";
                        }
                        report.AddSingleValue($"{str}", indexRow, 1);


                        indexRow++;
                    }

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

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

                maxCol = 0;
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        maxCol++;
                        report.AddSingleValue(col.HeaderText, indexRow, maxCol);
                    }
                }

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

                foreach (DataRowView row in dtData.DefaultView)
                {
                    maxCol = 0;
                    foreach (DataGridViewColumn col in dgvData.Columns)
                    {
                        if (col.Visible)
                        {
                            maxCol++;
                            setValueToCell(indexRow, maxCol, row[col.DataPropertyName]);
                        }
                    }

                    report.SetBorders(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToRight(indexRow, 5, indexRow, 7);
                    indexRow++;
                }

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

                Config.DoOnUIThread(() =>
                {
                    blockers.RestoreControlEnabledState(this);
                    fLoad.Dispose();
                }, this);
            });
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public static void printWriteOff(int id)
        {
            DataTable dtDataHead = readSQL.getActWriteOff(DateTime.Now, DateTime.Now, id);
            DataTable dtDataBody = readSQL.getContentWriteOff(id);


            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
            int indexRow = 1;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("Акт списания оборудования", indexRow, 1);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
            report.SetFontBold(indexRow, 1, indexRow, 1);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            indexRow++;
            indexRow++;

            report.Merge(indexRow, 5, indexRow, 6);
            report.AddSingleValue("Дата: " + ((DateTime)dtDataHead.Rows[0]["Date"]).ToShortDateString(), indexRow, 5);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("Причина: " + dtDataHead.Rows[0]["Reason"].ToString(), indexRow, 1);
            report.SetWrapText(indexRow, 1, indexRow, 1);
            //report.SetAutoFit(indexRow, 1, indexRow, 1);
            report.SetRowHeight(indexRow, 1, indexRow, 1, 60);
            indexRow++;
            indexRow++;


            report.AddSingleValue("№ п\\п", indexRow, 1);
            report.AddSingleValue("Наименование", indexRow, 2);
            report.AddSingleValue("Инвентарный номер", indexRow, 3);
            report.AddSingleValue("EAN", indexRow, 4);
            report.AddSingleValue("Местоположение", indexRow, 5);
            report.AddSingleValue("Комментарий", indexRow, 6);

            report.SetFontBold(indexRow, 1, indexRow, 6);
            report.SetBorders(indexRow, 1, indexRow, 6);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 6);
            indexRow++;

            foreach (DataRow row in dtDataBody.Rows)
            {
                report.AddSingleValue(row["npp"].ToString(), indexRow, 1);
                report.AddSingleValue(row["cName"].ToString(), indexRow, 2);
                report.AddSingleValue(row["InventoryNumber"].ToString(), indexRow, 3);
                report.AddSingleValue(row["EAN"].ToString(), indexRow, 4);
                report.AddSingleValue(row["nameLocation"].ToString(), indexRow, 5);
                //report.AddSingleValue(row[""].ToString(), indexRow, 6);
                report.SetBorders(indexRow, 1, indexRow, 6);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 6);
                indexRow++;
            }
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("ОЭЭС:", indexRow, 1);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("РБ5:", indexRow, 1);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("О1:", indexRow, 1);
            indexRow++;

            report.SetColumnAutoSize(5, 1, indexRow, 6);
            report.SetPageSetup(1, 9999, false);
            report.Show();
        }
Esempio n. 6
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);
            });
        }
Esempio n. 7
0
        private async void BtPrint_Click(object sender, EventArgs e)
        {
            int      id_driver = (int)cmbDriver.SelectedValue;
            DateTime dateStart = dtpStart.Value.Date;
            DateTime dateEnd   = dtpEnd.Value.Date;

            DataTable dtReport = Config.hCntMain.getReportDriver(dateStart, dateEnd, id_driver).Result;

            if (dtReport == null || dtReport.Rows.Count == 0)
            {
                MessageBox.Show("Нет данных для отчёта", "Выгрузка отчёта");
                return;
            }

            var groupDriver = dtReport.AsEnumerable()
                              .GroupBy(g => new { nameShop = g.Field <string>("nameShop"), id_Driver = g.Field <int>("id_Driver"), nameDriver = g.Field <string>("nameDriver"), DateRoute = g.Field <DateTime>("DateRoute"), CarNumber = g.Field <string>("CarNumber"), RouteNumber = g.Field <int>("RouteNumber"), id = g.Field <int>("id") })
                              .Select(s => new {
                s.Key.nameShop,
                s.Key.nameDriver,
                s.Key.DateRoute,
                s.Key.id_Driver,
                s.Key.CarNumber,
                s.Key.RouteNumber,
                s.Key.id,
                allCost       = s.Max(r => r.Field <decimal>("Cost100km")),
                allCostFull   = (s.Sum(r => r.Field <decimal>("RouteLength")) * s.Max(r => r.Field <decimal>("Cost100km"))) / 100.0m,
                sumWeightGood = s.Sum(r => r.Field <decimal>("weightGood"))
            }).OrderBy(o => o.nameShop).ThenBy(o => o.nameDriver).ThenBy(o => o.DateRoute).ThenBy(o => o.RouteNumber);



            await Task.Factory.StartNew(() =>
            {
                Config.DoOnUIThread(() =>
                {
                    blockers.SaveControlsEnabledState(this);
                    blockers.SetControlsEnabled(this, false);
                    //progressBar1.Visible = progressBar1.Enabled = true;
                    fLoad          = new Nwuram.Framework.UI.Forms.frmLoad();
                    fLoad.TopMost  = false;
                    fLoad.Owner    = this;
                    fLoad.TextWait = "Грузим отчётик!";
                    fLoad.Show();
                }, this);

                //if (report == null)
                report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

                int indexRow = 1;
                int maxCol   = 10;

                setWidthColumn(indexRow, 1, 14, report);
                setWidthColumn(indexRow, 2, 15, report);
                setWidthColumn(indexRow, 3, 20, report);
                setWidthColumn(indexRow, 4, 30, report);
                setWidthColumn(indexRow, 5, 30, report);

                setWidthColumn(indexRow, 6, 14, report);
                setWidthColumn(indexRow, 7, 13, report);
                setWidthColumn(indexRow, 8, 13, report);
                setWidthColumn(indexRow, 9, 14, report);
                setWidthColumn(indexRow, 10, 50, report);

                report.Merge(indexRow, 1, indexRow, maxCol);
                report.AddSingleValue("Отчет по водителям", indexRow, 1);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                report.SetFontSize(indexRow, 1, indexRow, 1, 18);
                indexRow++;
                indexRow++;


                Config.DoOnUIThread(() =>
                {
                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"{label3.Text} {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue($"{label5.Text}:{cmbDriver.Text}", indexRow, 1);
                    indexRow++;

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

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

                report.AddSingleValue("Магазин", indexRow, 1);
                report.AddSingleValue("Дата маршрута", indexRow, 2);
                report.AddSingleValue("№ маршрута", indexRow, 3);
                report.AddSingleValue("Водитель", indexRow, 4);
                report.AddSingleValue("Машина", indexRow, 5);
                report.AddSingleValue("Расход на 100 км. в городе, литр", indexRow, 6);
                report.AddSingleValue("Сумма веса заказов", indexRow, 7);
                report.AddSingleValue("Длина маршрута, км.", indexRow, 8);
                report.AddSingleValue("№ заказа", indexRow, 9);
                report.AddSingleValue("Адрес доставки", indexRow, 10);

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

                foreach (var gd in groupDriver)
                {
                    setValueToCell(indexRow, 1, gd.nameShop);
                    setValueToCell(indexRow, 2, gd.DateRoute);
                    setValueToCell(indexRow, 3, gd.RouteNumber);
                    setValueToCell(indexRow, 4, gd.nameDriver);
                    setValueToCell(indexRow, 5, gd.CarNumber);
                    setValueToCell(indexRow, 6, gd.allCost);
                    setValueToCell(indexRow, 7, gd.sumWeightGood);


                    EnumerableRowCollection <DataRow> rowCollect = dtReport.AsEnumerable().Where(r => r.Field <int>("id") == gd.id);

                    if (rowCollect.Count() > 0)
                    {
                        int indexStart = indexRow;
                        //DataRow row = rowCollect.First();

                        foreach (DataRow row in rowCollect)
                        {
                            setValueToCell(indexRow, 8, row["RouteLength"]);
                            setValueToCell(indexRow, 9, row["OrderNumber"]);
                            setValueToCell(indexRow, 10, row["Address"]);
                            report.SetBorders(indexRow, 1, indexRow, maxCol);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxCol);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxCol);
                            //report.SetCellAlignmentToRight(indexRow, 4, indexRow, 5);
                            indexRow++;
                        }

                        report.Merge(indexStart, 1, indexStart + rowCollect.Count() - 1, 1);
                        report.Merge(indexStart, 2, indexStart + rowCollect.Count() - 1, 2);
                        report.Merge(indexStart, 3, indexStart + rowCollect.Count() - 1, 3);
                        report.Merge(indexStart, 4, indexStart + rowCollect.Count() - 1, 4);
                        report.Merge(indexStart, 5, indexStart + rowCollect.Count() - 1, 5);
                        report.Merge(indexStart, 6, indexStart + rowCollect.Count() - 1, 6);
                        report.Merge(indexStart, 7, indexStart + rowCollect.Count() - 1, 7);
                    }
                }



                report.Merge(indexRow, 1, indexRow, 2);
                setValueToCell(indexRow, 1, "Итого кол-во маршрутов");
                setValueToCell(indexRow, 3, groupDriver.Count());

                setValueToCell(indexRow, 5, "Итого");

                setValueToCell(indexRow, 6, groupDriver.Sum(r => r.allCostFull));
                decimal routeLength = dtReport.AsEnumerable().Sum(r => r.Field <decimal>("weightGood"));
                setValueToCell(indexRow, 7, routeLength);
                routeLength = dtReport.AsEnumerable().Sum(r => r.Field <decimal>("RouteLength"));
                setValueToCell(indexRow, 8, routeLength);
                report.SetBorders(indexRow, 1, indexRow, 3);
                report.SetBorders(indexRow, 5, indexRow, 8);
                indexRow++;


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

                Config.DoOnUIThread(() =>
                {
                    blockers.RestoreControlEnabledState(this);
                    fLoad.Dispose();
                }, this);
            });
        }
Esempio n. 8
0
        private void getReport()
        {
            DoOnUIThread(delegate()
            {
                this.Enabled       = false;
                DataTable dtReport = proc.GetTenantReport((int)cbObjects.SelectedValue, (int)cbLandlord.SelectedValue, (int)cbActivties.SelectedValue);
                if (dtReport.Rows.Count == 0)
                {
                    MessageBox.Show("Нет данных для выгрузки", "Нет данных", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Enabled = true;
                    return;
                }
                else
                {
                    Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
                    int indexRow = 1;

                    report.SetPageOrientationToLandscape();

                    ///Заголовок
                    report.Merge(indexRow, 1, indexRow, 11);
                    report.AddSingleValue("ОТЧЕТ О ВИДАХ ДЕЯТЕЛЬНОСТИ АРЕНДАТОРОВ", indexRow, 1);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow + 1, 11);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow + 1, 11);
                    report.SetFontBold(indexRow, 1, indexRow, 11);
                    report.SetFontSize(indexRow, 1, indexRow, 11, 16);
                    indexRow++;
                    indexRow++;

                    ///Параметры
                    report.AddSingleValue("Объект:", indexRow, 2);
                    report.SetFontBold(indexRow, 2, indexRow, 2);
                    report.AddSingleValue(cbObjects.Text.Trim(), indexRow, 3);
                    indexRow++;
                    report.AddSingleValue("Арендодатель:", indexRow, 2);
                    report.SetFontBold(indexRow, 2, indexRow, 2);
                    report.AddSingleValue(cbLandlord.Text.Trim(), indexRow, 3);
                    indexRow++;
                    report.AddSingleValue("Вид деятельности:", indexRow, 2);
                    report.SetFontBold(indexRow, 2, indexRow, 2);
                    report.AddSingleValue(cbActivties.Text.Trim(), indexRow, 3);
                    indexRow++;
                    indexRow++;
                    report.AddSingleValue("Выгрузил:", indexRow, 2);
                    report.SetFontBold(indexRow, 2, indexRow, 2);
                    report.AddSingleValue(Nwuram.Framework.Settings.User.UserSettings.User.FullUsername.Trim(), indexRow, 3);
                    indexRow++;
                    report.AddSingleValue("Дата:", indexRow, 2);
                    report.SetFontBold(indexRow, 2, indexRow, 2);
                    report.AddSingleValue(proc.GetDate().ToString(), indexRow, 3);
                    indexRow++;
                    indexRow++;

                    ///Названия столбцов
                    report.Merge(indexRow, 1, indexRow + 1, 1);
                    report.AddSingleValue("Объект", indexRow, 1);
                    report.Merge(indexRow, 2, indexRow + 1, 2);
                    report.AddSingleValue("Арендодатель", indexRow, 2);
                    report.Merge(indexRow, 3, indexRow + 1, 3);
                    report.AddSingleValue("Вид деятельности", indexRow, 3);
                    report.Merge(indexRow, 4, indexRow + 1, 4);
                    report.AddSingleValue("№ п/п", indexRow, 4);
                    report.SetWrapText(indexRow, 4, indexRow + 1, 4);
                    report.Merge(indexRow, 5, indexRow + 1, 5);
                    report.AddSingleValue("Арендатор", indexRow, 5);
                    report.Merge(indexRow, 6, indexRow + 1, 6);
                    report.AddSingleValue("Вид договора", indexRow, 6);
                    report.Merge(indexRow, 7, indexRow, 9);
                    report.AddSingleValue("Местоположение", indexRow, 7);
                    report.AddSingleValue("Здание", indexRow + 1, 7);
                    report.AddSingleValue("Этаж", indexRow + 1, 8);
                    report.AddSingleValue("№ секции", indexRow + 1, 9);
                    report.Merge(indexRow, 10, indexRow + 1, 10);
                    report.AddSingleValue("Телефон", indexRow, 10);
                    report.Merge(indexRow, 11, indexRow + 1, 11);
                    report.AddSingleValue("Эл.почта", indexRow, 11);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow + 1, 11);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow + 1, 11);
                    report.SetBorders(indexRow, 1, indexRow + 1, 11);

                    report.SetFontBold(indexRow, 1, indexRow + 1, 11);
                    report.SetFontSize(indexRow, 1, indexRow + 1, 11, 14);
                    indexRow++;
                    indexRow++;

                    int ObjIndexStart = indexRow, ActIndexStart = indexRow, LandlordIndexStart = indexRow;
                    int NumPP         = 1;///Номер строки
                    var dtObject      = dtReport.AsEnumerable().Select(r => r.Field <int>("IdObject")).Distinct();;
                    foreach (var obj in dtObject)
                    {
                        ObjIndexStart = indexRow;
                        EnumerableRowCollection <DataRow> rcObj = dtReport.AsEnumerable().Where(r => r.Field <int>("IdObject") == obj);
                        report.AddSingleValue(rcObj.First()["Object"].ToString(), indexRow, 1);
                        var dtLandlord = rcObj.AsEnumerable().Select(r => r.Field <int>("IdLandlord")).Distinct();
                        foreach (var Landlord in dtLandlord)
                        {
                            LandlordIndexStart = indexRow;
                            EnumerableRowCollection <DataRow> rcLandlord = dtReport.AsEnumerable().Where(r => r.Field <int>("IdObject") == obj && r.Field <int>("IdLandlord") == Landlord);
                            report.AddSingleValue(rcLandlord.First()["Landlord"].ToString(), indexRow, 2);
                            var dtActivities = rcLandlord.AsEnumerable().Select(r => r.Field <int>("IdActivities")).Distinct();
                            foreach (var act in dtActivities)
                            {
                                ActIndexStart = indexRow;
                                EnumerableRowCollection <DataRow> rcAct = dtReport.AsEnumerable().Where(r => r.Field <int>("IdObject") == obj && r.Field <int>("IdLandlord") == Landlord && r.Field <int>("IdActivities") == act);
                                report.AddSingleValue(rcAct.First()["Activities"].ToString(), indexRow, 3);
                                foreach (var dr in rcAct)
                                {
                                    report.AddSingleValue(NumPP.ToString(), indexRow, 4);
                                    report.AddSingleValue(dr["Tenant"].ToString(), indexRow, 5);
                                    report.AddSingleValue(dr["TypeContract"].ToString(), indexRow, 6);
                                    report.AddSingleValue(dr["Building"].ToString(), indexRow, 7);
                                    report.AddSingleValue(dr["Floor"].ToString(), indexRow, 8);
                                    report.AddSingleValue(dr["Section"].ToString(), indexRow, 9);
                                    report.AddSingleValue(dr["Work_phone"].ToString(), indexRow, 10);
                                    report.AddSingleValue(dr["email"].ToString(), indexRow, 11);

                                    report.SetCellAlignmentToLeft(indexRow, 4, indexRow, 11);
                                    report.SetCellAlignmentToJustify(indexRow, 4, indexRow, 11);
                                    report.SetBorders(indexRow, 4, indexRow, 11);
                                    NumPP++;
                                    indexRow++;
                                }
                                report.Merge(ActIndexStart, 3, indexRow - 1, 3);
                                report.SetCellAlignmentToLeft(ActIndexStart, 3, indexRow - 1, 3);
                                report.SetCellAlignmentToJustify(ActIndexStart, 3, indexRow - 1, 3);
                                report.SetBorders(ActIndexStart, 3, indexRow - 1, 3);
                            }
                            report.Merge(LandlordIndexStart, 2, indexRow - 1, 2);
                            report.SetCellAlignmentToLeft(LandlordIndexStart, 2, indexRow - 1, 2);
                            report.SetCellAlignmentToJustify(LandlordIndexStart, 2, indexRow - 1, 2);
                            report.SetBorders(LandlordIndexStart, 2, indexRow - 1, 2);
                        }
                        report.Merge(ObjIndexStart, 1, indexRow - 1, 1);
                        report.SetCellAlignmentToLeft(ObjIndexStart, 1, indexRow - 1, 1);
                        report.SetCellAlignmentToJustify(ObjIndexStart, 1, indexRow - 1, 1);
                        report.SetBorders(ObjIndexStart, 1, indexRow - 1, 1);
                    }

                    report.SetColumnAutoSize(1, 1, indexRow - 1, 11);
                    report.SetColumnWidth(10, 4, 11, 4, 5);      ///Для № п/п
                    report.SetWrapText(12, 1, indexRow - 1, 11); ///Перенос текста для всех данных кроме телефон и почта
                    report.SetPageSetup(1, 1, true);
                    report.Show();
                }
                this.Enabled = true;
            });
        }
Esempio n. 9
0
        private async void btPrint_Click(object sender, EventArgs e)
        {
            var result = await Task <bool> .Factory.StartNew(() =>
            {
                if (dtData == null || dtData.Rows.Count == 0 || dtData.DefaultView.Count == 0)
                {
                    MessageBox.Show("Нет данных для формирования отчёта.", "Печать", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

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


                int indexRow   = 1;
                int maxColumns = 0;
                Config.DoOnUIThread(() =>
                {
                    blockers.SaveControlsEnabledState(this);
                    blockers.SetControlsEnabled(this, false);
                    progressBar1.Visible = true;

                    Logging.StartFirstLevel(79);
                    Logging.Comment("Произведена выгрузка отчета из формы \"Сравнение наименований товаров\" со следующими фильтрами:");
                    Logging.Comment($"Отдел ID:{cmbDeps.SelectedValue}; Наименование:{cmbDeps.Text}");
                    Logging.Comment($"Т/У группа ID:{cmbTU.SelectedValue}; Наименование:{cmbTU.Text}");
                    Logging.Comment($"Инв. группа ID:{cmbInv.SelectedValue}; Наименование:{cmbInv.Text}");
                    Logging.Comment($"Тип товара:{(rbAll.Checked ? rbAll.Text : rbSingle.Checked ? rbSingle.Text : rbMass.Text)}");
                    if (tbEan.Text.Trim().Length > 0)
                    {
                        Logging.Comment($"EAN:{tbEan.Text}");
                    }
                    if (tbNameTerminal.Text.Trim().Length > 0)
                    {
                        Logging.Comment($"Наименование товара на кассе:{tbNameTerminal.Text}");
                    }
                    if (tbName.Text.Trim().Length > 0)
                    {
                        Logging.Comment($"Короткое наименование товар на сайте:{tbName.Text}");
                    }

                    Logging.StopFirstLevel();
                }, this);

                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (!col.Visible || col.Name.Equals(cV.Name))
                    {
                        continue;
                    }
                    maxColumns++;
                    if (col.Name.Equals(cEan.Name))
                    {
                        setWidthColumn(indexRow, maxColumns, 17, report);
                    }
                    else
                    {
                        setWidthColumn(indexRow, maxColumns, 60, report);
                    }
                }


                #region "Head"
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.SetWrapText(indexRow, 1, indexRow, 1);
                report.SetRowHeight(indexRow, 1, indexRow, 1, 45);
                report.AddSingleValue($"Сравнение наименований товаров", indexRow, 1);
                report.SetFontBold(indexRow, 1, indexRow, 1);
                report.SetFontSize(indexRow, 1, indexRow, 1, 16);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                indexRow++;
                indexRow++;

                Config.DoOnUIThread(() =>
                {
                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Отдел: {cmbDeps.Text}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Т/У группа: {cmbTU.Text}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Инв. группа: {cmbInv.Text}", indexRow, 1);
                    indexRow++;

                    string typeGoods = rbAll.Checked ? rbAll.Text : rbMass.Checked ? rbMass.Text : rbSingle.Checked ? rbSingle.Text : "";

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Тип товара: {typeGoods}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Отдел: {cmbDeps.Text}", indexRow, 1);
                    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);
                }, this);
                indexRow++;
                indexRow++;
                #endregion

                int j = 0;
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (!col.Visible || col.Name.Equals(cV.Name))
                    {
                        continue;
                    }
                    j++;
                    report.AddSingleValue(col.HeaderText, indexRow, j);
                }

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

                foreach (DataRowView row in dtData.DefaultView)
                {
                    j = 0;
                    foreach (DataGridViewColumn col in dgvData.Columns)
                    {
                        if (!col.Visible || col.Name.Equals(cV.Name))
                        {
                            continue;
                        }
                        j++;
                        setValueToCell(indexRow, j, row[col.DataPropertyName]);
                    }

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

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

                report.SetPageSetup(1, 9999, true);
                report.ShowPreview();
                return(true);
            });
        }
Esempio n. 10
0
        private async void BtPrint_Click(object sender, EventArgs e)
        {
            await Task.Factory.StartNew(() =>
            {
                Config.DoOnUIThread(() =>
                {
                    blockers.SaveControlsEnabledState(this);
                    blockers.SetControlsEnabled(this, false);
                    //progressBar1.Visible = progressBar1.Enabled = true;
                    fLoad          = new Nwuram.Framework.UI.Forms.frmLoad();
                    fLoad.TopMost  = false;
                    fLoad.Owner    = this;
                    fLoad.TextWait = "Грузим отчётик!";
                    fLoad.Show();
                }, this);

                //if (report == null)
                report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

                int indexRow = 1;
                int maxCol   = 0;

                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        maxCol++;
                    }
                }


                setWidthColumn(indexRow, 1, 29, report);
                setWidthColumn(indexRow, 2, 22, report);
                setWidthColumn(indexRow, 3, 25, report);
                setWidthColumn(indexRow, 4, 25, report);

                report.Merge(indexRow, 1, indexRow, maxCol);
                report.AddSingleValue($"{this.Text}", indexRow, 1);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                report.SetFontSize(indexRow, 1, indexRow, 1, 18);
                indexRow++;
                indexRow++;

                Config.DoOnUIThread(() =>
                {
                    /*
                     * report.Merge(indexRow, 1, indexRow, maxCol);
                     * report.AddSingleValue($"{label5.Text}{cmbDeps.Text}", indexRow, 1);
                     * indexRow++;
                     *
                     * report.Merge(indexRow, 1, indexRow, maxCol);
                     * report.AddSingleValue($"{label3.Text}{cmbPost.Text}", indexRow, 1);
                     * indexRow++;
                     */
                    report.Merge(indexRow, 1, indexRow, maxCol);
                    report.AddSingleValue("Выгрузил: " + Nwuram.Framework.Settings.User.UserSettings.User.FullUsername, indexRow, 1);
                    indexRow++;

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

                maxCol = 0;
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        maxCol++;
                        report.AddSingleValue(col.HeaderText, indexRow, maxCol);
                    }
                }

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

                foreach (DataRowView row in dtData.DefaultView)
                {
                    maxCol = 0;
                    foreach (DataGridViewColumn col in dgvData.Columns)
                    {
                        if (col.Visible)
                        {
                            maxCol++;
                            setValueToCell(indexRow, maxCol, row[col.DataPropertyName]);
                        }
                    }

                    report.SetBorders(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxCol);
                    report.SetCellAlignmentToRight(indexRow, 3, indexRow, 4);
                    indexRow++;
                }

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

                Config.DoOnUIThread(() =>
                {
                    blockers.RestoreControlEnabledState(this);
                    fLoad.Dispose();
                }, this);
            });
        }
Esempio n. 11
0
        private async void btnPrint_Click(object sender, EventArgs e)
        {
            if (!chbCancel.Checked && !chbComplete.Checked && !chbЕmployesОrder.Checked)
            {
                return;
            }
            int id_Shop = (int)cmbShop.SelectedValue;
            var outer   = Task.Factory.StartNew(() =>    // внешняя задача
            {
                Config.DoOnUIThread(() =>
                {
                    blockers.SaveControlsEnabledState(this);
                    blockers.SetControlsEnabled(this, false);
                    //progressBar1.Visible = progressBar1.Enabled = true;
                    fLoad          = new Nwuram.Framework.UI.Forms.frmLoad();
                    fLoad.TopMost  = false;
                    fLoad.Owner    = this;
                    fLoad.TextWait = "Грузим отчётик!";
                    fLoad.Show();
                }, this);

                Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
                bool isShow = false;


                if (chbComplete.Checked)
                {
                    DataTable dtDataStatus3     = Config.connect.getReportData(dtpStart.Value, dtpEnd.Value, 3, id_Shop);
                    DataTable dtDataStatus3Body = (id_Shop == 1 ? Config.connect : Config.hCntSecond).getSumNotesOrderWithRCena(dtpStart.Value, dtpEnd.Value, 3, id_Shop);

                    if (dtDataStatus3 != null && dtDataStatus3.Rows.Count > 0)
                    {
                        isShow = true;
                        report.changeNameTab("Выполненные");

                        decimal sumOrder = 0, sumNote = 0, SummaDelivery = 0, sumPackage = 0, DeliveryCost = 0, valueOst = 0, valueDelta = 0;


                        int indexRow   = 1;
                        int maxColumns = 12;

                        setWidthColumn(indexRow, 1, 6, report);
                        setWidthColumn(indexRow, 2, 10, report);
                        setWidthColumn(indexRow, 3, 17, report);
                        setWidthColumn(indexRow, 4, 11, report);
                        setWidthColumn(indexRow, 5, 16, report);
                        setWidthColumn(indexRow, 6, 22, report);
                        setWidthColumn(indexRow, 7, 16, report);
                        setWidthColumn(indexRow, 8, 12, report);
                        setWidthColumn(indexRow, 9, 14, report);
                        setWidthColumn(indexRow, 10, 16, report);
                        setWidthColumn(indexRow, 11, 16, report);
                        setWidthColumn(indexRow, 12, 13, report);

                        #region "Head"
                        report.Merge(indexRow, 1, indexRow, maxColumns);
                        report.AddSingleValue($"Отчёт об выполненных заказах с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", 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

                        report.AddSingleValue("№ п/п", indexRow, 1);
                        report.AddSingleValue("Номер заказа", indexRow, 2);
                        report.AddSingleValue("Сумма заказа", indexRow, 3);
                        report.AddSingleValue("Дата доставки", indexRow, 4);
                        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.AddSingleValue("Остаток по доставке", indexRow, 11);
                        report.AddSingleValue("∆ по чеку", indexRow, 12);


                        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++;

                        int npp = 1;

                        var groupOrder = dtDataStatus3.AsEnumerable()
                                         .GroupBy(r => new { id_tOrders = r.Field <int>("id_tOrders") })
                                         .Select(g => new
                        {
                            g.Key.id_tOrders,
                            sumNote = g.Sum(r => r.Field <decimal>("sumNote"))
                        });

                        foreach (var g in groupOrder)
                        {
                            EnumerableRowCollection <DataRow> rowCollect = dtDataStatus3.AsEnumerable().Where(r => r.Field <int>("id_tOrders") == g.id_tOrders);
                            DataRow row  = rowCollect.First();
                            int startRow = indexRow;
                            report.SetWrapText(indexRow, 1, indexRow + rowCollect.Count() - 1, maxColumns);
                            report.Merge(indexRow, 1, indexRow + rowCollect.Count() - 1, 1);
                            report.Merge(indexRow, 2, indexRow + rowCollect.Count() - 1, 2);
                            report.Merge(indexRow, 3, indexRow + rowCollect.Count() - 1, 3);
                            report.Merge(indexRow, 4, indexRow + rowCollect.Count() - 1, 4);
                            report.Merge(indexRow, 5, indexRow + rowCollect.Count() - 1, 5);

                            report.Merge(indexRow, 7, indexRow + rowCollect.Count() - 1, 7);
                            report.Merge(indexRow, 8, indexRow + rowCollect.Count() - 1, 8);
                            report.Merge(indexRow, 9, indexRow + rowCollect.Count() - 1, 9);
                            report.Merge(indexRow, 10, indexRow + rowCollect.Count() - 1, 10);
                            report.Merge(indexRow, 11, indexRow + rowCollect.Count() - 1, 11);
                            report.Merge(indexRow, 12, indexRow + rowCollect.Count() - 1, 12);



                            report.AddSingleValue(npp.ToString(), indexRow, 1);
                            report.AddSingleValue(row["OrderNumber"].ToString(), indexRow, 2);
                            report.AddSingleValueObject(row["sumOrder"], indexRow, 3);
                            report.SetFormat(indexRow, 3, indexRow, 3, "0.00");
                            report.AddSingleValue(((DateTime)row["DeliveryDate"]).ToShortDateString(), indexRow, 4);

                            report.AddSingleValueObject(g.sumNote, indexRow, 5);
                            report.SetFormat(indexRow, 5, indexRow, 5, "0.00");

                            report.AddSingleValueObject(row["SummaDelivery"], indexRow, 7);
                            report.SetFormat(indexRow, 7, indexRow, 7, "0.00");

                            report.AddSingleValueObject(row["CountPackage"], indexRow, 8);
                            report.SetFormat(indexRow, 8, indexRow, 8, "0.00");

                            report.AddSingleValueObject(row["sumPackage"], indexRow, 9);
                            report.SetFormat(indexRow, 9, indexRow, 9, "0.00");

                            report.AddSingleValueObject(row["DeliveryCost"], indexRow, 10);
                            report.SetFormat(indexRow, 10, indexRow, 10, "0.00");


                            sumOrder      += (decimal)row["sumOrder"];
                            sumNote       += g.sumNote;
                            SummaDelivery += (decimal)row["SummaDelivery"];
                            sumPackage    += (decimal)row["sumPackage"];
                            DeliveryCost  += (decimal)row["DeliveryCost"];

                            decimal value = (decimal)row["SummaDelivery"] - (decimal)row["sumPackage"] - (decimal)row["DeliveryCost"];
                            valueOst     += value;
                            report.AddSingleValueObject(value, indexRow, 11);
                            report.SetFormat(indexRow, 11, indexRow, 11, "0.00");

                            if (dtDataStatus3Body != null)
                            {
                                decimal sum = dtDataStatus3Body.AsEnumerable().Where(r => r.Field <int>("id_tOrders") == (int)row["id_tOrders"]).Sum(r => r.Field <decimal>("resultSum"));
                                report.AddSingleValueObject(g.sumNote - sum, indexRow, 12);
                                valueDelta += g.sumNote - sum;
                            }
                            else
                            {
                                report.AddSingleValueObject(0, indexRow, 12);
                            }
                            report.SetFormat(indexRow, 12, indexRow, 12, "0.00");

                            foreach (DataRow rowSelect in rowCollect)
                            {
                                //report.AddSingleValueObject(rowSelect["sumNote"], indexRow, 5);
                                //report.SetFormat(indexRow, 5, indexRow, 5, "0.00");
                                report.AddSingleValue($"Касса:{rowSelect["KassNumber"]} Чек:{rowSelect["CheckNumber"]}", indexRow, 6);
                                indexRow++;
                            }



                            report.SetBorders(startRow, 1, indexRow - 1, maxColumns);
                            report.SetCellAlignmentToCenter(startRow, 1, indexRow - 1, maxColumns);
                            report.SetCellAlignmentToJustify(startRow, 1, indexRow - 1, maxColumns);
                            //indexRow++;
                            npp++;
                        }


                        report.SetFormat(indexRow, 2, indexRow, maxColumns, "0.00");

                        report.AddSingleValue($"Итого:", indexRow, 1);
                        report.AddSingleValueObject(sumOrder, indexRow, 3);
                        report.AddSingleValueObject(sumNote, indexRow, 5);
                        report.AddSingleValueObject(SummaDelivery, indexRow, 7);
                        report.AddSingleValueObject(sumPackage, indexRow, 9);
                        report.AddSingleValueObject(DeliveryCost, indexRow, 10);
                        report.AddSingleValueObject(valueOst, indexRow, 11);
                        report.AddSingleValueObject(valueDelta, indexRow, 12);

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

                if (chbCancel.Checked)
                {
                    DataTable dtData = Config.connect.getReportData(dtpStart.Value, dtpEnd.Value, 4, id_Shop);
                    if (dtData != null && dtData.Rows.Count > 0)
                    {
                        if (!isShow)
                        {
                            isShow = true;
                            report.changeNameTab("Отменённые");
                        }
                        else
                        {
                            report.GoToNextSheet("Отменённые");
                        }

                        int indexRow     = 1;
                        int maxColumns   = 9;
                        decimal sumOrder = 0;

                        setWidthColumn(indexRow, 1, 9, report);
                        setWidthColumn(indexRow, 2, 20, report);
                        setWidthColumn(indexRow, 3, 20, report);
                        setWidthColumn(indexRow, 4, 16, report);
                        setWidthColumn(indexRow, 5, 20, report);
                        setWidthColumn(indexRow, 6, 18, report);
                        setWidthColumn(indexRow, 7, 16, report);
                        setWidthColumn(indexRow, 8, 16, report);
                        setWidthColumn(indexRow, 9, 40, report);

                        #region "Head"
                        report.Merge(indexRow, 1, indexRow, maxColumns);
                        report.AddSingleValue($"Отчёт об отменённых заказах с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", 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

                        report.AddSingleValue("№ п/п", indexRow, 1);
                        report.AddSingleValue("ФИО", indexRow, 2);
                        report.AddSingleValue("Адрес", indexRow, 3);
                        report.AddSingleValue("Телефон", indexRow, 4);
                        report.AddSingleValue("e-mail", indexRow, 5);
                        report.AddSingleValue("Номер заказа", indexRow, 6);
                        report.AddSingleValue("Дата заказа", indexRow, 7);
                        report.AddSingleValue("Сумма заказа", indexRow, 8);
                        report.AddSingleValue("Комментарий об отмене заказа", indexRow, 9);

                        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++;

                        int npp = 1;

                        foreach (DataRowView row in dtData.DefaultView)
                        {
                            report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                            report.AddSingleValue(npp.ToString(), indexRow, 1);
                            report.AddSingleValue(row["FIO"].ToString(), indexRow, 2);
                            report.AddSingleValue(row["Address"].ToString(), indexRow, 3);
                            report.AddSingleValue(row["Phone"].ToString(), indexRow, 4);
                            report.AddSingleValue(row["Email"].ToString(), indexRow, 5);
                            report.AddSingleValue(row["OrderNumber"].ToString(), indexRow, 6);
                            report.AddSingleValue(((DateTime)row["DateOrder"]).ToShortDateString(), indexRow, 7);
                            report.AddSingleValueObject(row["sumOrder"], indexRow, 8);
                            report.SetFormat(indexRow, 4, indexRow, 4, "0.00");
                            report.AddSingleValue(row["Comment"].ToString(), indexRow, 9);

                            sumOrder += (decimal)row["sumOrder"];

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

                        report.SetFormat(indexRow, 2, indexRow, maxColumns, "0.00");

                        report.AddSingleValue($"Итого:", indexRow, 1);
                        report.AddSingleValueObject(sumOrder, indexRow, 8);

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

                if (chbЕmployesОrder.Checked)
                {
                    DataTable dtData = Config.connect.reportЕmployesОrder(dtpStart.Value, dtpEnd.Value, id_Shop);
                    if (dtData != null && dtData.Rows.Count > 0)
                    {
                        if (!isShow)
                        {
                            isShow = true;
                            report.changeNameTab("Отчет по сотрудникам");
                        }
                        else
                        {
                            report.GoToNextSheet("Отчет по сотрудникам");
                        }


                        int indexRow     = 1;
                        int maxColumns   = 8;
                        decimal sumOrder = 0;

                        setWidthColumn(indexRow, 1, 9, report);
                        setWidthColumn(indexRow, 2, 25, report);
                        setWidthColumn(indexRow, 3, 16, report);
                        setWidthColumn(indexRow, 4, 16, report);
                        setWidthColumn(indexRow, 5, 16, report);
                        setWidthColumn(indexRow, 6, 12, report);
                        setWidthColumn(indexRow, 7, 12, report);
                        setWidthColumn(indexRow, 8, 12, report);

                        #region "Head"
                        report.Merge(indexRow, 1, indexRow, maxColumns);
                        report.AddSingleValue($"Отчет по сотрудникам с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", 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

                        report.AddSingleValue("№ п/п", indexRow, 1);
                        report.AddSingleValue("ФИО сотрудника", indexRow, 2);
                        report.AddSingleValue("Дата заказа", indexRow, 3);
                        report.AddSingleValue("Номер заказа", indexRow, 4);
                        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++;


                        var groupCountCollector = dtData.AsEnumerable()
                                                  .Where(r => r.Field <bool>("Collector"))
                                                  .GroupBy(g => new { OrderNumber = g.Field <int>("OrderNumber") })
                                                  .Select(s => new { s.Key.OrderNumber, countCollector = s.Count() });

                        var groupKadr = dtData.AsEnumerable().GroupBy(r => new { id_Kadr = r.Field <int>("id_Kadr"), FIO = r.Field <string>("FIO") }).Select(s => new { s.Key.id_Kadr, s.Key.FIO });


                        int npp          = 1;
                        Color cCompleted = Color.FromArgb(244, 255, 96);
                        foreach (var gKadr in groupKadr)
                        {
                            EnumerableRowCollection <DataRow> rowCollect = dtData.AsEnumerable().Where(r => r.Field <int>("id_Kadr") == gKadr.id_Kadr).OrderBy(r => r.Field <int>("OrderNumber"));
                            report.Merge(indexRow, 2, indexRow + rowCollect.Count() - 1, 2);
                            setValueToCell(indexRow, 2, gKadr.FIO, report);
                            var groupDate = rowCollect.AsEnumerable().GroupBy(g => new { DeliveryDate = g.Field <DateTime>("DeliveryDate") }).Select(s => new { s.Key.DeliveryDate });

                            decimal countCollector = 0;
                            int countKassCheck     = 0;
                            int countDelivery      = 0;

                            foreach (var gDate in groupDate)
                            {
                                EnumerableRowCollection <DataRow> rowCollectDate = rowCollect.Where(r => r.Field <DateTime>("DeliveryDate") == gDate.DeliveryDate);

                                report.Merge(indexRow, 3, indexRow + rowCollectDate.Count() - 1, 3);
                                setValueToCell(indexRow, 3, gDate.DeliveryDate, report);

                                foreach (DataRow row in rowCollectDate)
                                {
                                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                                    setValueToCell(indexRow, 1, npp, report);
                                    setValueToCell(indexRow, 4, row["OrderNumber"], report);
                                    setValueToCell(indexRow, 5, row["countRow"], report);
                                    if ((bool)row["Collector"])
                                    {
                                        decimal valResult = Convert.ToDecimal((int)row["countRow"]) / Convert.ToDecimal(groupCountCollector.Where(r => r.OrderNumber == (int)row["OrderNumber"]).First().countCollector);
                                        countCollector   += valResult;
                                        setValueToCell(indexRow, 6, valResult, report);
                                    }
                                    if ((bool)row["KassCheck"])
                                    {
                                        setValueToCell(indexRow, 7, row["KassCheck"], report);
                                        countKassCheck++;
                                    }
                                    if ((bool)row["Delivery"])
                                    {
                                        setValueToCell(indexRow, 8, row["Delivery"], report);
                                        countDelivery++;
                                    }
                                    if (!(bool)row["isCompleted"])
                                    {
                                        report.SetCellColor(indexRow, 4, indexRow, maxColumns, cCompleted);
                                    }
                                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                                    indexRow++;
                                    npp++;
                                }
                            }


                            report.Merge(indexRow, 1, indexRow, 5);
                            setValueToCell(indexRow, 1, $"Итого:", report);
                            setValueToCell(indexRow, 6, countCollector, report);
                            setValueToCell(indexRow, 7, countKassCheck, report);
                            setValueToCell(indexRow, 8, countDelivery, report);

                            report.SetBorders(indexRow, 1, indexRow, maxColumns);
                            report.SetFontBold(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                            report.SetCellAlignmentToRight(indexRow, 1, indexRow, 1);
                            //report.SetCellAlignmentToRight(indexRow, 6, indexRow, maxColumns);

                            indexRow++;
                        }
                        report.SetCellColor(indexRow + 1, 1, indexRow + 1, 1, cCompleted);
                        setValueToCell(indexRow + 1, 2, "-заказ не выполнен", report);
                    }
                }

                Config.DoOnUIThread(() =>
                {
                    blockers.RestoreControlEnabledState(this);
                    fLoad.Dispose();
                }, this);

                if (isShow)
                {
                    report.SetPageSetup(1, 9999, true);
                    report.Show();
                }
                else
                {
                    MessageBox.Show("Нет данных для отчёта", "Выгрузка отчёта", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                #region логирование
                Logging.StartFirstLevel(79);
                Logging.Comment("Произведена выгрузка в Excel отчета по работе онлайн-магазина");
                Logging.Comment($"Период с: {dtpStart.Value.ToShortDateString()} по: {dtpEnd.Value.ToShortDateString()}");
                Logging.Comment($"Отчет о выполненых заказах: {(chbComplete.Checked ? "Да" : "Нет")}");
                Logging.Comment($"Отчет об отмененных заказах: {(chbCancel.Checked ? "Да" : "Нет")}");
                Logging.Comment("Завершение выгрузки отчета по работе онлайн магазина");
                Logging.StopFirstLevel();
                #endregion
            });
        }
Esempio n. 12
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            if (dgvData.Rows.Count == 0)
            {
                MessageBox.Show("Нет данных для формирования отчёта!", "Выгрузка отчёта", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            Logging.StartFirstLevel(79);

            Logging.Comment($"Фомирование отчёта из \"{this.Text}\"");

            Logging.Comment($"Договор:{tbAgreement.Text}");
            Logging.Comment($"Арендатор:{tbTenant.Text}");
            Logging.Comment($"Арендодатель:{tbLandLord.Text}");
            Logging.Comment($"Место:{tbNamePlace.Text}");

            Logging.Comment($"Период с:{dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}");
            Logging.Comment($"Объект аренды ID:{cmbObject.SelectedValue}; Наименование:{cmbObject.Text}");
            Logging.Comment($"Съезд подтвержден: {(chbCongressAccept.Checked ? "Да" : "Нет")}");
            Logging.Comment($"Аннуляция поддтверждена/имеется расторжение договора: {(chbDropAgreements.Checked ? "Да" : "Нет")}");

            Logging.StopFirstLevel();

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
            int indexRow   = 1;
            int maxColumns = 0;

            foreach (DataGridViewColumn col in dgvData.Columns)
            {
                if (col.Visible)
                {
                    maxColumns++;
                }
            }

            setWidthColumn(indexRow, 1, 25, report);
            setWidthColumn(indexRow, 2, 23, report);
            setWidthColumn(indexRow, 3, 14, report);
            setWidthColumn(indexRow, 4, 11, report);
            setWidthColumn(indexRow, 5, 50, report);
            setWidthColumn(indexRow, 6, 16, report);
            setWidthColumn(indexRow, 7, 13, report);
            setWidthColumn(indexRow, 8, 15, report);
            setWidthColumn(indexRow, 9, 13, report);


            #region "Head"
            report.Merge(indexRow, 1, indexRow, maxColumns);
            report.AddSingleValue("Отчёт по съездам арендаторов", 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($"Период с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
            indexRow++;

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

            if (tbLandLord.Text.Trim().Length > 0 || tbTenant.Text.Trim().Length > 0 || tbAgreement.Text.Trim().Length > 0 || tbNamePlace.Text.Trim().Length > 0)
            {
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.AddSingleValue($"Фильтры: " +
                                      $"{(tbLandLord.Text.Trim().Length > 0 ? $"Арендодатель: {tbLandLord.Text.Trim()}" : "")}; " +
                                      $"{(tbLandLord.Text.Trim().Length > 0 ? $"Арендатор: {tbTenant.Text.Trim()}" : "")}; " +
                                      $"{(tbLandLord.Text.Trim().Length > 0 ? $"Номер договора: {tbAgreement.Text.Trim()}" : "")}; " +
                                      $"{(tbLandLord.Text.Trim().Length > 0 ? $"Местоположение места аренды: {tbNamePlace.Text.Trim()}" : "")}; ", indexRow, 1);
                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

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


            foreach (DataGridViewRow row in dgvData.Rows)
            {
                Color rColor = Color.White;
                if ((!(bool)dtData.DefaultView[row.Index]["isLinkPetitionLeave"] || !(bool)dtData.DefaultView[row.Index]["isConfirmed_LinkPetitionLeave"]) && (bool)dtData.DefaultView[row.Index]["isConfirmed"])
                {
                    rColor = panel2.BackColor;
                }

                if ((bool)dtData.DefaultView[row.Index]["isLinkPetitionLeave"] && (bool)dtData.DefaultView[row.Index]["isConfirmed_LinkPetitionLeave"])
                {
                    rColor = panel3.BackColor;
                }
                else if (dtData.DefaultView[row.Index]["isCancelAgreements"] != DBNull.Value && (bool)dtData.DefaultView[row.Index]["isConfirmed"])
                {
                    rColor = panel3.BackColor;
                }

                report.SetCellColor(indexRow, 1, indexRow, maxColumns, rColor);

                indexColumn = 0;
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        indexColumn++;
                        if (row.Cells[col.Index].Value is DateTime)
                        {
                            report.AddSingleValue(((DateTime)row.Cells[col.Index].Value).ToShortDateString(), indexRow, indexColumn);
                        }
                        else
                        {
                            report.AddSingleValue(row.Cells[col.Index].Value.ToString(), indexRow, indexColumn);
                        }
                        report.SetWrapText(indexRow, indexColumn, indexRow, indexColumn);
                        if ((bool)dtData.DefaultView[row.Index]["isLinkPetitionLeave"] && col.Index == Date_of_Departure.Index)
                        {
                            report.SetCellColor(indexRow, indexColumn, indexRow, indexColumn, panel1.BackColor);
                        }
                    }
                }

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


            indexRow++;
            report.Merge(indexRow, 2, indexRow, maxColumns);
            report.SetCellColor(indexRow, 1, indexRow, 1, panel1.BackColor);
            report.AddSingleValue($"{label4.Text}", indexRow, 2);
            indexRow++;

            report.Merge(indexRow, 2, indexRow, maxColumns);
            report.SetCellColor(indexRow, 1, indexRow, 1, panel2.BackColor);
            report.AddSingleValue($"{chbCongressAccept.Text}", indexRow, 2);
            indexRow++;

            report.Merge(indexRow, 2, indexRow, maxColumns);
            report.SetCellColor(indexRow, 1, indexRow, 1, panel3.BackColor);
            report.AddSingleValue($"{chbDropAgreements.Text}", indexRow, 2);
            report.SetPageSetup(1, 9999, true);

            report.Show();
        }
Esempio n. 13
0
        private async void btViewCartGoods_Click(object sender, EventArgs e)
        {
            report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
            TabPage      tp  = tabControl1.SelectedTab;
            DataGridView grd = null;
            DataTable    dt  = null;

            switch (tabControl1.SelectedIndex)
            {
            case 0:
                grd = dgvData;
                dt  = dgvData.DataSource as DataTable;
                break;

            case 1:
                grd = dgvDataPrice;
                dt  = dgvDataPrice.DataSource as DataTable;
                break;

            case 2:
                grd = dgvDataNewGoods;
                dt  = dgvDataNewGoods.DataSource as DataTable;
                break;
            }


            int indexRow   = 1;
            int maxColumns = 0;

            blockers.SaveControlsEnabledState(this);
            blockers.SetControlsEnabled(this, false);
            progressBar1.Visible = true;
            var result = await Task <bool> .Factory.StartNew(() =>
            {
                foreach (DataGridViewColumn col in grd.Columns)
                {
                    if (col.Visible)
                    {
                        maxColumns++;
                        if (new List <string>(new string[] { cDeps.Name, cNameDepPrice.Name, cNameDepNewGoods.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 13, report);
                        }
                        if (new List <string>(new string[] { cGrp1.Name, nameGrp1Atfer.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 13, report);
                        }
                        if (new List <string>(new string[] { cEan.Name, cEanPrice.Name, cEanNewGoods.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 15, report);
                        }
                        if (new List <string>(new string[] { cNameBefore.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 40, report);
                        }
                        if (new List <string>(new string[] { cNameAfter.Name, cNamePrice.Name, cNameNewGoods.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 40, report);
                        }
                        if (new List <string>(new string[] { cPriceBefore.Name, cPriceNewGoods.Name, cPriceAfter.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 11, report);
                        }
                        if (new List <string>(new string[] { cSell.Name, cOstMorning.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 11, report);
                        }
                        if (new List <string>(new string[] { cNdsBefore.Name, cNdsAfter.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 11, report);
                        }
                        if (new List <string>(new string[] { cUlBefore.Name, cUlAfter.Name, cUlNewGoods.Name }).Contains(col.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 11, report);
                        }
                    }
                }


                #region "Head"
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.AddSingleValue($"{tp.Text}", indexRow, 1);
                report.SetFontBold(indexRow, 1, indexRow, 1);
                report.SetFontSize(indexRow, 1, indexRow, 1, 16);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                indexRow++;
                indexRow++;

                Config.DoOnUIThread(() =>
                {
                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Магазин: {cmbShop.Text}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"{label4.Text}: {dtpDate.Value.ToShortDateString()}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Отдел: {cmbDeps.Text}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, maxColumns);
                    report.AddSingleValue($"Т/У группа: {cmbGrp1.Text}", indexRow, 1);
                    indexRow++;


                    //if (tbEan.Text.Trim().Length != 0 || tbName.Text.Trim().Length != 0)
                    //{
                    //    report.Merge(indexRow, 1, indexRow, maxColumns);
                    //    report.AddSingleValue($"Фильтр: {(tbEan.Text.Trim().Length != 0 ? $"EAN:{tbEan.Text.Trim()} | " : "")} {(tbName.Text.Trim().Length != 0 ? $"Наименование:{tbName.Text.Trim()}" : "")}", indexRow, 1);
                    //    indexRow++;
                    //}
                }, this);

                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

                int indexCol = 0;
                foreach (DataGridViewColumn col in grd.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.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                indexRow++;

                foreach (DataRowView row in dt.DefaultView)
                {
                    indexCol = 1;
                    report.SetWrapText(indexRow, indexCol, indexRow, maxColumns);
                    foreach (DataGridViewColumn col in grd.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++;
                        }
                    }

                    if (chbReserv.Checked && (bool)row["isReserv"])
                    {
                        report.SetCellColor(indexRow, 1, indexRow, maxColumns, panel1.BackColor);
                    }

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

                    indexRow++;
                }

                if (chbReserv.Checked)
                {
                    indexRow++;
                    report.SetCellColor(indexRow, 1, indexRow, 1, panel1.BackColor);
                    report.Merge(indexRow, 2, indexRow, maxColumns);
                    report.AddSingleValue($"{chbReserv.Text}", indexRow, 2);
                }

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

                report.SetPageSetup(1, 9999, true);
                report.Show();
                return(true);
            });
        }
Esempio n. 14
0
        private async void btPrint_Click(object sender, EventArgs e)
        {
            int id_Shop = (int)cmbShop.SelectedValue;
            int id_dep  = (int)cmbDeps.SelectedValue;

            report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
            blockers.SaveControlsEnabledState(this);
            blockers.SetControlsEnabled(this, false);
            progressBar1.Visible = true;

            var result = await Task <bool> .Factory.StartNew(() =>
            {
                DataTable dtDbase1, dtKassRealiz;
                Task <DataTable> task;

                if (id_Shop == 1)
                {
                    task = Config.hCntMain.GetListTovarForValidateReport(id_dep);
                    task.Wait();
                    dtDbase1 = task.Result;

                    task = Config.hCntMainKassRealizz.GetListTovarForValidateReport(id_dep);
                    task.Wait();
                    dtKassRealiz = task.Result;
                }
                else
                {
                    task = Config.hCntSecond.GetListTovarForValidateReport(id_dep);
                    task.Wait();
                    dtDbase1 = task.Result;

                    task = Config.hCntSecondKassRealizz.GetListTovarForValidateReport(id_dep);
                    task.Wait();
                    dtKassRealiz = task.Result;
                }


                if (dtKassRealiz != null && dtKassRealiz.Rows.Count > 0)
                {
                    DataTable dtTmp = dtDbase1.Clone();

                    var query = (from g in dtDbase1.AsEnumerable()
                                 join k in dtKassRealiz.AsEnumerable() on new { Q = g.Field <string>("ean") } equals new { Q = k.Field <string>("ean") } into t1
                                 from leftjoin1 in t1.DefaultIfEmpty()
                                 select dtTmp.LoadDataRow(new object[]
                    {
                        g.Field <int>("id_tovar"),
                        g.Field <string>("ean"),
                        g.Field <string>("cname"),
                        g.Field <decimal>("rcena"),
                        g.Field <DateTime>("DateCreate"),
                        g.Field <string>("FIO"),
                        g.Field <int>("id_otdel"),
                        g.Field <string>("nameDep"),
                        g.Field <int?>("idPromo"),
                        leftjoin1 == null ? null : leftjoin1.Field <decimal?>("price"),
                        leftjoin1 == null ? null : leftjoin1.Field <string>("FIO"),
                        leftjoin1 == null ? null : leftjoin1.Field <DateTime?>("s_time"),
                    }, false));


                    dtDbase1 = query
                               .Where(r => r.Field <decimal?>("rcena") != r.Field <decimal?>("priceKass"))
                               .OrderBy(r => r.Field <int>("id_otdel")).ThenBy(r => r.Field <string>("ean"))
                               .CopyToDataTable();



                    //foreach (DataRow row in dtDbase1.Rows)
                    //{
                    //    EnumerableRowCollection<DataRow> rowCollect = dtKassRealiz.AsEnumerable()
                    //    .Where(r => r.Field<string>("ean") == (string)row["ean"]);//&& Math.Abs(((DateTime)row["DateCreate"] - r.Field<DateTime>("s_time")).TotalSeconds) < 4);

                    //    if (rowCollect.Count() > 0)
                    //    {
                    //        row["priceKass"] = rowCollect.First()["price"];
                    //        row["FIOKass"] = rowCollect.First()["FIO"];
                    //        row["dateKass"] = rowCollect.First()["s_time"];

                    //        //rowCollect.First().Delete();
                    //    }
                    //}
                }


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


                int indexRow   = 1;
                int maxColumns = 10;

                setWidthColumn(indexRow, 1, 8, report);
                setWidthColumn(indexRow, 2, 12, report);
                setWidthColumn(indexRow, 3, 14, report);

                setWidthColumn(indexRow, 4, 50, report);
                setWidthColumn(indexRow, 5, 10, report);
                setWidthColumn(indexRow, 6, 19, report);
                setWidthColumn(indexRow, 7, 18, report);
                setWidthColumn(indexRow, 8, 10, report);
                setWidthColumn(indexRow, 9, 19, report);
                setWidthColumn(indexRow, 10, 18, report);



                #region "Head"
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.AddSingleValue($"{this.Text}", 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

                report.Merge(indexRow, 1, indexRow + 1, 1);
                report.AddSingleValue("№", indexRow, 1);

                report.Merge(indexRow, 2, indexRow + 1, 2);
                report.AddSingleValue("Отдел", indexRow, 2);

                report.Merge(indexRow, 3, indexRow + 1, 3);
                report.AddSingleValue("EAN", indexRow, 3);

                report.Merge(indexRow, 4, indexRow + 1, 4);
                report.AddSingleValue("Наименование", indexRow, 4);


                report.Merge(indexRow, 5, indexRow, 7);
                report.AddSingleValue("На кассе", indexRow, 5);
                report.AddSingleValue("Цена", indexRow + 1, 5);
                report.AddSingleValue("Дата установки", indexRow + 1, 6);
                report.AddSingleValue("Выгрузил на кассу", indexRow + 1, 7);


                report.Merge(indexRow, 8, indexRow, 10);
                report.AddSingleValue("В программе ТК", indexRow, 8);
                report.AddSingleValue("Цена", indexRow + 1, 8);
                report.AddSingleValue("Дата установки", indexRow + 1, 9);
                report.AddSingleValue("Сохранил в программе", indexRow + 1, 10);
                report.SetFontBold(indexRow, 1, indexRow + 1, maxColumns);
                report.SetBorders(indexRow, 1, indexRow + 1, maxColumns);
                report.SetWrapText(indexRow, 1, indexRow + 1, maxColumns);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow + 1, maxColumns);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow + 1, maxColumns);
                indexRow++;
                indexRow++;

                int npp = 1;
                foreach (DataRow row in dtDbase1.Rows)
                {
                    report.SetWrapText(indexRow, 1, indexRow, maxColumns);

                    addDataToCell(npp, indexRow, 1, report);
                    addDataToCell(row["nameDep"], indexRow, 2, report);

                    addDataToCell(row["ean"], indexRow, 3, report);
                    addDataToCell(row["cname"], indexRow, 4, report);

                    addDataToCell(row["priceKass"], indexRow, 5, report);
                    addDataToCell(row["dateKass"], indexRow, 6, report, true);
                    addDataToCell(row["FIOKass"], indexRow, 7, report);


                    addDataToCell(row["rcena"], indexRow, 8, report);
                    addDataToCell(row["DateCreate"], indexRow, 9, report, true);
                    addDataToCell(row["FIO"], indexRow, 10, report);


                    report.SetBorders(indexRow, 1, indexRow, maxColumns);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumns);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                    report.SetCellAlignmentToRight(indexRow, 5, indexRow, 5);
                    report.SetCellAlignmentToRight(indexRow, 8, indexRow, 8);
                    indexRow++;

                    npp++;
                }

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


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

                return(true);
            });
        }