Esempio n. 1
0
 private void setWidthColumn(int indexRow, int indexCol, int width, Nwuram.Framework.ToExcelNew.ExcelUnLoad report)
 {
     report.SetColumnWidth(indexRow, indexCol, indexRow, indexCol, width);
 }
Esempio n. 2
0
        private void printBlockPass(int indexRow, int indexCol, Nwuram.Framework.ToExcelNew.ExcelUnLoad rep, string nameShort, string fio, string code)
        {
            int rowStart = indexRow;

            //Размеры колонок
            //rep.SetBorders(indexRow, indexCol, indexRow+8, indexCol+4);
            rep.SetColumnWidth(indexRow, indexCol, indexRow, indexCol, 15);
            rep.SetColumnWidth(indexRow, indexCol + 1, indexRow, indexCol, 8);

            rep.SetColumnWidth(indexRow, indexCol + 2, indexRow, indexCol + 2, 10);
            rep.SetColumnWidth(indexRow, indexCol + 3, indexRow, indexCol + 3, 5);

            rep.SetColumnWidth(indexRow, indexCol + 4, indexRow, indexCol + 4, 12);
            //Начало
            rep.Merge(indexRow, indexCol, indexRow, indexCol + 1);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 1, "Times New Roman");
            rep.AddSingleValue("Пропуск", indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 16);
            rep.SetCellAlignmentToLeft(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToJustify(indexRow, indexCol, indexRow, indexCol);
            rep.SetFontBold(indexRow, indexCol, indexRow, indexCol);

            //+2 колонки
            rep.Merge(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetFontName(indexRow, indexCol + 2, indexRow, indexCol + 3, "Times New Roman");
            rep.AddSingleValue("часы работы", indexRow, indexCol + 2);
            rep.SetFontSize(indexRow, indexCol + 2, indexRow, indexCol + 3, 12);
            rep.SetCellAlignmentToLeft(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetCellAlignmentToJustify(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetFontBold(indexRow, indexCol + 2, indexRow, indexCol + 3);


            //Колонка +4
            rep.SetFontName(indexRow, indexCol + 4, indexRow, indexCol + 4, "Code EAN13");
            rep.Merge(indexRow, indexCol + 4, indexRow + 8, indexCol + 4);
            rep.SetOrientation(indexRow, indexCol + 4, indexRow, indexCol + 4, 90);
            rep.SetFontSize(indexRow, indexCol + 4, indexRow, indexCol + 4, 41);
            rep.AddSingleValue(ConvertToNewEan(code), indexRow, indexCol + 4);
            rep.SetCellAlignmentToLeft(indexRow, indexCol + 4, indexRow, indexCol + 4);
            rep.SetCellAlignmentToJustify(indexRow, indexCol + 4, indexRow, indexCol + 4);


            //Вторая строка
            indexRow++;
            rep.Merge(indexRow, indexCol, indexRow, indexCol + 1);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 1, "Times New Roman");
            rep.AddSingleValue("на служебную парковку", indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 12);
            rep.SetCellAlignmentToLeft(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToJustify(indexRow, indexCol, indexRow, indexCol);
            //rep.SetFontBold(indexRow, indexCol, indexRow, indexCol);

            //+2 колонки
            rep.Merge(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetFontName(indexRow, indexCol + 2, indexRow, indexCol + 3, "Times New Roman");
            rep.AddSingleValue("с 7:30 до 2:30", indexRow, indexCol + 2);
            rep.SetFontSize(indexRow, indexCol + 2, indexRow, indexCol + 3, 12);
            rep.SetCellAlignmentToLeft(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetCellAlignmentToJustify(indexRow, indexCol + 2, indexRow, indexCol + 3);
            rep.SetFontBold(indexRow, indexCol + 2, indexRow, indexCol + 3);

            //3 и 4 строка
            indexRow++;
            indexRow++;
            rep.Merge(indexRow, indexCol, indexRow, indexCol + 3);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 1, "Times New Roman");
            rep.AddSingleValue(fio, indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 12);
            rep.SetCellAlignmentToCenter(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToJustify(indexRow, indexCol, indexRow, indexCol);
            rep.SetFontBold(indexRow, indexCol, indexRow, indexCol);

            //5 строка
            indexRow++;
            rep.Merge(indexRow, indexCol, indexRow, indexCol + 3);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 1, "Times New Roman");
            rep.AddSingleValue("(Фамилия И.О.)", indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 9);
            rep.SetCellAlignmentToCenter(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToTop(indexRow, indexCol, indexRow, indexCol);
            //rep.SetFontBold(indexRow, indexCol, indexRow, indexCol);

            //6 и 7 и 8 строка
            indexRow++;
            indexRow++;
            //rep.Merge(indexRow, indexCol, indexRow, indexCol);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 1, "Times New Roman");
            rep.AddSingleValue("Гос. Номер а/м:", indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 11);
            rep.SetCellAlignmentToLeft(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToJustify(indexRow, indexCol, indexRow, indexCol);
            //rep.SetFontBold(indexRow, indexCol, indexRow, indexCol);

            rep.Merge(indexRow, indexCol + 1, indexRow + 1, indexCol + 3);
            rep.SetWrapText(indexRow, indexCol + 1, indexRow + 1, indexCol + 3);
            rep.SetFontName(indexRow, indexCol + 1, indexRow, indexCol + 3, "Times New Roman");
            rep.AddSingleValue(nameShort, indexRow, indexCol + 1);
            rep.SetFontSize(indexRow, indexCol + 1, indexRow, indexCol + 3, 12);
            rep.SetCellAlignmentToCenter(indexRow, indexCol + 1, indexRow, indexCol + 3);
            rep.SetCellAlignmentToJustify(indexRow, indexCol + 1, indexRow, indexCol + 3);
            rep.SetFontBold(indexRow, indexCol + 1, indexRow, indexCol + 3);


            //9 строка
            indexRow++;
            indexRow++;
            rep.Merge(indexRow, indexCol, indexRow, indexCol + 3);
            rep.SetFontName(indexRow, indexCol, indexRow, indexCol + 3, "Times New Roman");
            rep.AddSingleValue("Подпись РДО ___________", indexRow, indexCol);
            rep.SetFontSize(indexRow, indexCol, indexRow, indexCol, 11);
            rep.SetCellAlignmentToLeft(indexRow, indexCol, indexRow, indexCol);
            rep.SetCellAlignmentToJustify(indexRow, indexCol, indexRow, indexCol);

            rep.SetBordersToAll(rowStart, indexCol, rowStart, indexCol + 4, OfficeOpenXml.Style.ExcelBorderStyle.Medium, 1);
            rep.SetBordersToAll(indexRow, indexCol, indexRow, indexCol + 4, OfficeOpenXml.Style.ExcelBorderStyle.Medium, 2);


            rep.SetBordersToAll(rowStart, indexCol, indexRow, indexCol, OfficeOpenXml.Style.ExcelBorderStyle.Medium, 3);

            rep.SetBordersToAll(rowStart, indexCol + 4, indexRow, indexCol + 4, OfficeOpenXml.Style.ExcelBorderStyle.Medium, 4);

            rep.SetBordersToAll(rowStart, indexCol + 3, indexRow, indexCol + 3, OfficeOpenXml.Style.ExcelBorderStyle.Medium, 4);
        }
Esempio n. 3
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. 4
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            if (rbErrorRealiz.Checked)
            {
                Task <DataTable> task = Parameters.hConnect.GetReportMainKass(dtpStart.Value.Date, dtpEnd.Value.Date, 1);
                task.Wait();
                if (task.Result == null || task.Result.Rows.Count == 0)
                {
                    MessageBox.Show("Нет данных для отчёта!", "Выгрузка отчёта", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Logging.StartFirstLevel(489);
                Logging.Comment($"Период с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}");
                Logging.Comment($"Отчет по ошибкам в реализации");
                Logging.StopFirstLevel();


                DataTable dtReport = task.Result.Copy();

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

                report.Merge(indexRow, 1, indexRow, 7);
                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, 7);
                report.AddSingleValue($"Период с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
                indexRow++;

                report.Merge(indexRow, 1, indexRow, 7);
                report.AddSingleValue($"Магазин: {(ConnectionSettings.GetServer().Contains("K21") ? "K21" : "X14")}", indexRow, 1);
                indexRow++;

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

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


                report.SetColumnWidth(1, 1, 1, 1, 26);
                report.SetColumnWidth(1, 2, 1, 2, 20);
                report.SetColumnWidth(1, 3, 1, 3, 28);
                report.SetColumnWidth(1, 4, 1, 4, 21);
                report.SetColumnWidth(1, 5, 1, 5, 22);
                report.SetColumnWidth(1, 6, 1, 6, 22);
                report.SetColumnWidth(1, 7, 1, 7, 22);

                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.SetFontBold(indexRow, 1, indexRow, 7);
                report.SetBorders(indexRow, 1, indexRow, 7);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 7);
                indexRow++;

                foreach (DataRow row in dtReport.Rows)
                {
                    report.SetBorders(indexRow, 1, indexRow, 7);
                    report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 7);
                    report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 7);
                    report.SetWrapText(indexRow, 1, indexRow, 7);
                    report.AddSingleValue($"{((DateTime)row["Data"]).ToShortDateString()}", indexRow, 1);
                    report.AddSingleValue($"{row["nameType"]}", indexRow, 2);
                    report.AddSingleValue($"{row["DateSubmission"]}", indexRow, 3);
                    report.AddSingleValue($"{row["Number"]}", indexRow, 4);
                    report.AddSingleValue($"{row["Comment"]}", indexRow, 5);
                    report.AddSingleValue($"{row["DateConfirm"]}", indexRow, 6);
                    report.AddSingleValue($"{row["Fault"]}", indexRow, 7);
                    indexRow++;
                }

                report.Show();
            }
            else if (rbNullDataValidate.Checked)
            {
                Task <DataTable> task = Parameters.hConnect.GetReportMainKass(dtpStart.Value.Date, dtpEnd.Value.Date, 2);
                task.Wait();
                if (task.Result == null || task.Result.Rows.Count == 0)
                {
                    MessageBox.Show("Нет данных для отчёта!", "Выгрузка отчёта", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Logging.StartFirstLevel(489);
                Logging.Comment($"Период с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}");
                Logging.Comment($"Отчет об отсутствии сверки данных");
                Logging.StopFirstLevel();

                DataTable dtReport = task.Result.Copy();

                task = Parameters.hConnect.GetRealizForReportMainKass(dtpStart.Value.Date, dtpEnd.Value.Date);
                task.Wait();
                DataTable dtRealiz = new DataTable();
                if (task.Result != null && task.Result.Rows.Count != 0)
                {
                    dtRealiz = task.Result.Copy();
                }


                task = Parameters.hConnectVVO.GetRealizForReportMainKass(dtpStart.Value.Date, dtpEnd.Value.Date);
                task.Wait();
                DataTable dtRealizVVO = new DataTable();
                if (task.Result != null && task.Result.Rows.Count != 0)
                {
                    dtRealizVVO = task.Result.Copy();
                }

                Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();
                bool isFirstTab = true;
                for (int i = 3; i >= 1; i--)
                {
                    EnumerableRowCollection <DataRow> rowCollect = dtReport.AsEnumerable().Where(r => r.Field <int>("type") == i);
                    if (rowCollect.Count() == 0)
                    {
                        continue;
                    }
                    if (!isFirstTab)
                    {
                        report.GoToNextSheet();
                    }


                    int indexRow = 1;

                    report.Merge(indexRow, 1, indexRow, 3);
                    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, 3);
                    report.AddSingleValue($"Период с {dtpStart.Value.ToShortDateString()} по {dtpEnd.Value.ToShortDateString()}", indexRow, 1);
                    indexRow++;

                    report.Merge(indexRow, 1, indexRow, 3);
                    report.AddSingleValue($"Магазин: {(ConnectionSettings.GetServer().Contains("K21") ? "K21" : "X14")}", indexRow, 1);
                    indexRow++;

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

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


                    report.SetColumnWidth(1, 1, 1, 1, 26);
                    report.SetColumnWidth(1, 2, 1, 2, 20);
                    report.SetColumnWidth(1, 3, 1, 3, 28);

                    report.AddSingleValue("Причина", indexRow, 1);
                    report.AddSingleValue("Дата", indexRow, 2);
                    report.AddSingleValue("Отдел", indexRow, 3);

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

                    #region "Нет данных «Главная касса»"
                    if (i == 1)
                    {
                        //EnumerableRowCollection<DataRow> rowCollect = dtReport.AsEnumerable().Where(r => r.Field<int>("type") == 1);
                        if (rowCollect.Count() > 0)
                        {
                            if (isFirstTab)
                            {
                                isFirstTab = false; report.changeNameTab("Нет данных «Главная касса»");
                            }
                            else
                            {
                                report.changeNameTab("Нет данных «Главная касса»");
                            }

                            int headerStart = indexRow;

                            for (DateTime ii11 = dtpStart.Value; ii11 <= dtpEnd.Value; ii11 = ii11.AddDays(1))
                            {
                                int  midStart = indexRow;
                                bool showData = false;


                                if (rowCollect.AsEnumerable().Where(r => !r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == ii11.Date).Count() == 0)
                                {
                                    showData = true;
                                    report.AddSingleValue("Все отделы, кроме ВВО", indexRow, 3);
                                    indexRow++;
                                }

                                if (rowCollect.AsEnumerable().Where(r => r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == ii11.Date).Count() == 0)
                                {
                                    showData = true;
                                    report.AddSingleValue("Отдел ВВО", indexRow, 3);
                                    indexRow++;
                                }

                                if (showData)
                                {
                                    report.Merge(midStart, 2, indexRow - 1, 2);
                                    report.AddSingleValue($"{ii11.ToShortDateString()}", midStart, 2);
                                    report.SetCellAlignmentToCenter(midStart, 2, indexRow - 1, 2);
                                    report.SetCellAlignmentToJustify(midStart, 2, indexRow - 1, 2);
                                }
                            }

                            if (indexRow > headerStart)
                            {
                                report.Merge(headerStart, 1, indexRow - 1, 1);
                                report.SetBorders(headerStart, 1, indexRow - 1, 3);
                                report.SetCellAlignmentToCenter(headerStart, 1, indexRow - 1, 1);
                                report.SetCellAlignmentToJustify(headerStart, 1, indexRow - 1, 1);
                                report.SetWrapText(headerStart, 1, indexRow - 1, 1);
                                report.AddSingleValue($"Нет данных «Главная касса»", headerStart, 1);
                            }
                        }
                    }
                    #endregion

                    #region "Нет сверки с «Реал. SQL»"
                    if (i == 2)
                    {
                        //EnumerableRowCollection<DataRow> rowCollect = dtReport.AsEnumerable().Where(r => r.Field<int>("type") == 2);
                        if (rowCollect.Count() > 0)
                        {
                            if (isFirstTab)
                            {
                                isFirstTab = false; report.changeNameTab("Нет сверки с «Реал. SQL»");
                            }
                            else
                            {
                                report.changeNameTab("Нет сверки с «Реал. SQL»");
                            }
                            int headerStart = indexRow;

                            var groupData = rowCollect.AsEnumerable()
                                            .GroupBy(g => new { date = g.Field <DateTime>("Data") })
                                            .Select(s => new { s.Key.date });
                            foreach (var gDate in groupData)
                            {
                                int  midStart = indexRow;
                                bool showData = false;


                                foreach (DataRow row in rowCollect.AsEnumerable().Where(r => !r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == gDate.date.Date))
                                {
                                    showData = true;
                                    report.AddSingleValue("Все отделы, кроме ВВО", indexRow, 3);
                                    indexRow++;
                                }

                                foreach (DataRow row in rowCollect.AsEnumerable().Where(r => r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == gDate.date.Date))
                                {
                                    showData = true;
                                    report.AddSingleValue("Отдел ВВО", indexRow, 3);
                                    indexRow++;
                                }

                                if (showData)
                                {
                                    report.Merge(midStart, 2, indexRow - 1, 2);
                                    report.AddSingleValue($"{gDate.date.ToShortDateString()}", midStart, 2);
                                    report.SetCellAlignmentToCenter(midStart, 2, indexRow - 1, 2);
                                    report.SetCellAlignmentToJustify(midStart, 2, indexRow - 1, 2);
                                }
                            }

                            if (indexRow > headerStart)
                            {
                                report.Merge(headerStart, 1, indexRow - 1, 1);
                                report.AddSingleValue($"Нет сверки с «Реал. SQL»", headerStart, 1);
                                report.SetBorders(headerStart, 1, indexRow - 1, 3);
                                report.SetCellAlignmentToCenter(headerStart, 1, indexRow - 1, 1);
                                report.SetCellAlignmentToJustify(headerStart, 1, indexRow - 1, 1);
                            }
                        }
                    }
                    #endregion

                    #region "Данные «Реал. SQL» отличаются от сохраненных"
                    if (i == 3)
                    {
                        //EnumerableRowCollection<DataRow> rowCollect = dtReport.AsEnumerable().Where(r => r.Field<int>("type") == 3);
                        if (rowCollect.Count() > 0)
                        {
                            if (isFirstTab)
                            {
                                isFirstTab = false; report.changeNameTab("Данные «Реал. SQL» отличаются от сохраненных");
                            }
                            else
                            {
                                report.changeNameTab("Данные «Реал. SQL» отличаются от сохраненных");
                            }
                            int headerStart = indexRow;

                            var groupData = rowCollect.AsEnumerable()
                                            .GroupBy(g => new { date = g.Field <DateTime>("Data") })
                                            .Select(s => new { s.Key.date });
                            foreach (var gDate in groupData)
                            {
                                int  midStart = indexRow;
                                bool showData = false;

                                foreach (DataRow row in rowCollect.AsEnumerable().Where(r => !r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == gDate.date.Date))
                                {
                                    if (dtRealiz.Rows.Count > 0)
                                    {
                                        if (dtRealiz.AsEnumerable().Where(r => r.Field <DateTime>("dreal").Date == gDate.date.Date && r.Field <decimal>("RealSql") == (decimal)row["MainKass"]).Count() == 0)
                                        {
                                            showData = true;
                                            report.AddSingleValue("Все отделы, кроме ВВО", indexRow, 3);
                                            indexRow++;
                                        }
                                    }
                                    else
                                    {
                                        showData = true;
                                        report.AddSingleValue("Все отделы, кроме ВВО", indexRow, 3);
                                        indexRow++;
                                    }
                                }

                                foreach (DataRow row in rowCollect.AsEnumerable().Where(r => r.Field <bool>("isVVO") && r.Field <DateTime>("Data").Date == gDate.date.Date))
                                {
                                    if (dtRealizVVO.Rows.Count > 0)
                                    {
                                        if (dtRealizVVO.AsEnumerable().Where(r => r.Field <DateTime>("dreal").Date == gDate.date.Date && r.Field <decimal>("RealSql") == (decimal)row["MainKass"]).Count() == 0)
                                        {
                                            showData = true;
                                            report.AddSingleValue("Отдел ВВО", indexRow, 3);
                                            indexRow++;
                                        }
                                    }
                                    else
                                    {
                                        showData = true;
                                        report.AddSingleValue("Отдел ВВО", indexRow, 3);
                                        indexRow++;
                                    }
                                }

                                if (showData)
                                {
                                    report.Merge(midStart, 2, indexRow - 1, 2);
                                    report.AddSingleValue($"{gDate.date.ToShortDateString()}", midStart, 2);
                                    report.SetCellAlignmentToCenter(midStart, 2, indexRow - 1, 2);
                                    report.SetCellAlignmentToJustify(midStart, 2, indexRow - 1, 2);
                                }
                            }

                            if (indexRow > headerStart)
                            {
                                report.Merge(headerStart, 1, indexRow - 1, 1);
                                report.SetBorders(headerStart, 1, indexRow - 1, 3);
                                report.SetCellAlignmentToCenter(headerStart, 1, indexRow - 1, 1);
                                report.SetCellAlignmentToJustify(headerStart, 1, indexRow - 1, 1);
                                report.SetWrapText(headerStart, 1, indexRow - 1, 1);
                                report.AddSingleValue($"Данные «Реал. SQL» отличаются от сохраненных", headerStart, 1);
                            }
                        }
                    }
                    #endregion
                }

                report.Show();
            }
        }
Esempio n. 5
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            int id_typeDoc = (int)cmbTypeDoc.SelectedValue;
            EnumerableRowCollection <DataRow> rowCollect = dtPostVsDeps.AsEnumerable().Where(r => r.Field <bool>("isSelect"));

            if (!chbAllDepsAndPosts.Checked && rowCollect.Count() == 0)
            {
                MessageBox.Show("Необходимо выбрать должность и отдел!", "Информирование", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }

            Task <DataTable> task = Config.hCntMain.getReportInformationUser(id_typeDoc);

            task.Wait();

            if (task.Result == null || task.Result.Rows.Count == 0)
            {
                MessageBox.Show("Нет данных для отчёта!", "Информирование", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }

            DataTable dtReport = task.Result.Clone();

            if (!chbAllDepsAndPosts.Checked)
            {
                foreach (DataRow row in rowCollect)
                {
                    EnumerableRowCollection <DataRow> rowToReport = task.Result.AsEnumerable().Where(r => r.Field <int>("id_Departments") == (int)row["id_Departments"] && r.Field <int>("id_Posts") == (int)row["id_Posts"]);
                    if (rowToReport.Count() > 0)
                    {
                        dtReport.Merge(rowToReport.CopyToDataTable());
                    }
                }
            }
            else if (UserSettings.User.StatusCode.ToLower().Equals("ркв"))
            {
                foreach (DataRow row in dtDepsLinkToDep.Rows)
                {
                    EnumerableRowCollection <DataRow> rowToReport = task.Result.AsEnumerable().Where(r => r.Field <int>("id_Departments") == (int)row["id_DepartmentsView"]);
                    if (rowToReport.Count() > 0)
                    {
                        dtReport.Merge(rowToReport.CopyToDataTable());
                    }
                }
            }
            else
            {
                dtReport = task.Result.Copy();
            }

            if (dtReport.Rows.Count == 0)
            {
                MessageBox.Show("Нет данных для отчёта!", "Информирование", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }

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

            report.Merge(indexRow, 1, indexRow, maxColumn);
            report.AddSingleValue("Документы, ожидающие ознакомления", indexRow, 1);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumn);
            report.SetFontBold(indexRow, 1, indexRow, maxColumn);
            report.SetFontSize(indexRow, 1, indexRow, maxColumn, 16);
            indexRow++;

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

            report.Merge(indexRow, 1, indexRow, maxColumn);
            report.AddSingleValue($"Дата выгрузки:{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}", indexRow, 1);
            report.SetCellAlignmentToRight(indexRow, 1, indexRow, maxColumn);
            indexRow++;
            indexRow++;

            report.AddSingleValue("№", indexRow, 1);
            report.AddSingleValue("Отдел", indexRow, 2);
            report.AddSingleValue("Должность", indexRow, 3);
            report.AddSingleValue("Наименование документа", indexRow, 4);
            report.AddSingleValue("Дата отправки на ознакомление", indexRow, 5);
            report.SetBorders(indexRow, 1, indexRow, maxColumn);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, maxColumn);
            report.SetWrapText(indexRow, 1, indexRow, maxColumn);
            report.SetFontBold(indexRow, 1, indexRow, maxColumn);

            report.SetColumnWidth(indexRow, 1, indexRow, 1, 6);
            report.SetColumnWidth(indexRow, 2, indexRow, 2, 25);
            report.SetColumnWidth(indexRow, 3, indexRow, 3, 25);
            report.SetColumnWidth(indexRow, 4, indexRow, 4, 50);
            report.SetColumnWidth(indexRow, 5, indexRow, 5, 20);

            indexRow++;

            var groupDeps = dtReport.AsEnumerable().GroupBy(r => new { id_Departments = r.Field <int>("id_Departments"), nameDep = r.Field <string>("nameDep") })
                            .Select(s => new
            {
                s.Key.id_Departments,
                s.Key.nameDep
            });

            int npp = 1;

            foreach (var gDep in groupDeps)
            {
                int startIndexGroupDeps = indexRow;
                var groupPost           = dtReport.AsEnumerable()
                                          .Where(r => r.Field <int>("id_Departments") == gDep.id_Departments)
                                          .GroupBy(r => new { id_Posts = r.Field <int>("id_Posts"), namePost = r.Field <string>("namePost") })
                                          .Select(s => new
                {
                    s.Key.id_Posts,
                    s.Key.namePost
                });

                foreach (var gPost in groupPost)
                {
                    int startIndexGroupPost = indexRow;
                    rowCollect = dtReport.AsEnumerable()
                                 .Where(r => r.Field <int>("id_Departments") == gDep.id_Departments && r.Field <int>("id_Posts") == gPost.id_Posts);

                    foreach (DataRow row in rowCollect)
                    {
                        report.AddSingleValue($"{npp}", indexRow, 1);
                        report.AddSingleValue($"{row["cName"]}", indexRow, 4);
                        report.AddSingleValue($"{((DateTime)row["DateEdit"]).ToShortDateString()}", indexRow, 5);
                        report.SetCellAlignmentToCenter(indexRow, 4, indexRow, 5);
                        report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                        report.SetWrapText(indexRow, 4, indexRow, 4);
                        report.SetBorders(indexRow, 1, indexRow, 5);
                        indexRow++;
                        npp++;
                    }

                    report.Merge(startIndexGroupPost, 3, indexRow - 1, 3);
                    report.AddSingleValue($"{gPost.namePost}", startIndexGroupPost, 3);
                    report.SetCellAlignmentToCenter(startIndexGroupPost, 3, startIndexGroupPost, 3);
                    report.SetCellAlignmentToJustify(startIndexGroupPost, 3, startIndexGroupPost, 3);
                    report.SetWrapText(startIndexGroupPost, 3, startIndexGroupPost, 3);
                    report.SetBorders(startIndexGroupPost, 3, startIndexGroupPost, 3);
                }
                report.Merge(startIndexGroupDeps, 2, indexRow - 1, 2);
                report.AddSingleValue($"{gDep.nameDep.Trim()}", startIndexGroupDeps, 2);
                report.SetCellAlignmentToCenter(startIndexGroupDeps, 2, startIndexGroupDeps, 2);
                report.SetCellAlignmentToJustify(startIndexGroupDeps, 2, startIndexGroupDeps, 2);
                report.SetWrapText(startIndexGroupDeps, 2, startIndexGroupDeps, 2);
                report.SetBorders(startIndexGroupDeps, 2, startIndexGroupDeps, 2);
            }

            report.Show();
        }