Example #1
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();
        }
Example #2
0
        private void btExcel_Click(object sender, EventArgs e)
        {
            Logging.StartFirstLevel(79);

            Logging.Comment("Произведена выгрузка в Excel отчета «Отчет по сканерам»");

            Logging.Comment("Операцию выполнил: ID:" + Nwuram.Framework.Settings.User.UserSettings.User.Id
                            + " ; ФИО:" + Nwuram.Framework.Settings.User.UserSettings.User.FullUsername);
            Logging.StopFirstLevel();

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad("Лист - 1");
            report.SetPageOrientationToLandscape();

            int indexRow = 1;

            report.Merge(indexRow, 1, indexRow, 9);
            report.AddSingleValue("Отчёт по сканерам", indexRow, 1);
            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 3);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 3);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            indexRow++;

            report.Merge(indexRow, 1, indexRow, 9);
            report.AddSingleValue("Период с : " + dtpStart.Value.ToShortDateString() + " по: " + dtpEnd.Value.ToShortDateString(), indexRow, 1);
            indexRow++;

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

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

            int indexColum = 1;

            foreach (DataGridViewColumn col in dgvScaner.Columns)
            {
                report.AddSingleValue(col.HeaderText, indexRow, indexColum);
                indexColum++;
                if (col.Name.Equals("cTimeDrop"))
                {
                    report.AddSingleValue("Сканер Выдал", indexRow, indexColum);
                    indexColum++;
                }
            }

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

            foreach (DataRowView r in dtJournalScaner.DefaultView)
            {
                report.AddSingleValue(r["InventoryNumber"].ToString(), indexRow, 1);
                report.AddSingleValue(r["EAN"].ToString(), indexRow, 2);
                report.AddSingleValue(r["cName"].ToString(), indexRow, 3);
                report.AddSingleValue(r["nameOut"].ToString(), indexRow, 4);
                report.AddSingleValue(r["nameDeps"].ToString(), indexRow, 5);
                report.AddSingleValue(r["DateOut"].ToString(), indexRow, 6);
                report.AddSingleValue(r["FIO"].ToString(), indexRow, 7);
                report.AddSingleValue(r["nameGet"].ToString(), indexRow, 8);
                report.AddSingleValue(r["DateGet"].ToString(), indexRow, 9);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 9);
                report.SetBorders(indexRow, 1, indexRow, 9);
                indexRow++;
            }


            report.SetColumnAutoSize(1, 1, indexRow - 1, 9);
            report.Show();
        }
Example #3
0
        public static void createReport(int id_hardware, DateTime startDate, DateTime endDate, string strType, int type, List <string> listFilter)
        {
            DataTable dtReport = new DataTable();

            if (id_hardware != 0)
            {
                dtReport = readSQL.getReportHistory(id_hardware, null, null, null);
            }
            else
            {
                dtReport = readSQL.getReportHistory(id_hardware, startDate, endDate, type);
            }

            if (dtReport == null)
            {
                MessageBox.Show("Нет данных для выгрузки!", "Информирование");; return;
            }
            if (dtReport.Rows.Count == 0)
            {
                MessageBox.Show("Нет данных для выгрузки!", "Информирование");; return;
            }


            if (listFilter != null)
            {
                EnumerableRowCollection <DataRow> rowsFind = dtReport.AsEnumerable().Where(r => listFilter.Contains(r.Field <string>("cName").Trim()));
                if (rowsFind.Count() == 0)
                {
                    MessageBox.Show("Нет данных для выгрузки!", "Информирование");; return;
                }

                dtReport = rowsFind.CopyToDataTable();
            }

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

            int indexRow = 1;

            string[] listTitle = new string[] { "Инв. номер", @"Оборудование\Комплектующее", @"Наименование оборуд.\комплект.", @"Дата добавления оборудования", "Параметр", "Значение До", "Значение после", "Время изменения", "Кто изменил" };

            report.Merge(indexRow, 1, indexRow, listTitle.Length);
            report.AddSingleValue("Отчёт по изменению в оборудовании", indexRow, 1);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            report.SetFontBold(indexRow, 1, indexRow, 1);
            indexRow++;


            if (id_hardware == 0)
            {
                report.Merge(indexRow, 1, indexRow, listTitle.Length);
                report.AddSingleValue("Период с " + startDate.ToShortDateString() + " по " + endDate.ToShortDateString() + "", indexRow, 1);
                indexRow++;

                report.Merge(indexRow, 1, indexRow, listTitle.Length);
                report.AddSingleValue("Условие: " + strType, indexRow, 1);
                indexRow++;
            }

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

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

            for (int i = 0; i < listTitle.Length; i++)
            {
                report.AddSingleValue(listTitle[i], indexRow, i + 1);
                report.SetBorders(indexRow, i + 1, indexRow, i + 1);
                report.SetCellAlignmentToCenter(indexRow, i + 1, indexRow, i + 1);
            }
            indexRow++;


            //EnumerableRowCollection<DataRow>
            var rowCollect = from hosp in dtReport.AsEnumerable()
                             group hosp by new { id_jHardware = hosp["id_jHardware"], id_Creator = hosp["id_Creator"], DateCreate = hosp["DateCreate"] } into grp
            orderby grp.Key.id_jHardware ascending, grp.Key.DateCreate ascending
                select new
            {
                id_jHardware = grp.Key.id_jHardware,
                id_Creator   = grp.Key.id_Creator,
                DateCreate   = grp.Key.DateCreate,
            };

            foreach (var rC in rowCollect)
            {
                DataRow[] row = dtReport.Select(string.Format("id_jHardware = {0} and id_Creator = {1} AND DateCreate = '{2}'", rC.id_jHardware, rC.id_Creator, rC.DateCreate));

                report.Merge(indexRow, 1, indexRow + row.Count() - 1, 1);
                report.Merge(indexRow, 2, indexRow + row.Count() - 1, 2);
                report.Merge(indexRow, 3, indexRow + row.Count() - 1, 3);
                report.Merge(indexRow, 8, indexRow + row.Count() - 1, 8);
                report.Merge(indexRow, 9, indexRow + row.Count() - 1, 9);
                report.AddSingleValue(row[0]["InventoryNumber"].ToString(), indexRow, 1);
                report.AddSingleValue(row[0]["TypeComponentsHardware"].ToString(), indexRow, 2);
                report.AddSingleValue(row[0]["nameOb"].ToString(), indexRow, 3);
                report.AddSingleValue(row[0]["DateCreate"].ToString(), indexRow, 8);
                report.AddSingleValue(row[0]["FIO"].ToString(), indexRow, 9);
                report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 9);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 2, indexRow, 2);
                report.SetCellAlignmentToCenter(indexRow, 3, indexRow, 3);
                report.SetCellAlignmentToCenter(indexRow, 8, indexRow, 8);
                report.SetCellAlignmentToCenter(indexRow, 9, indexRow, 9);

                foreach (DataRow r in row)
                {
                    report.AddSingleValue(r["DateCreateHardWare"].ToString(), indexRow, 4);
                    report.AddSingleValue(r["cName"].ToString(), indexRow, 5);
                    report.AddSingleValue(r["valueOld"].ToString(), indexRow, 6);
                    report.AddSingleValue(r["valueNew"].ToString(), indexRow, 7);

                    report.SetCellAlignmentToCenter(indexRow, 4, indexRow, 4);

                    if ((bool)r["isDeleteRow"])
                    {
                        report.SetCellColor(indexRow, 1, indexRow, listTitle.Length, Color.Green);
                    }
                    report.SetBorders(indexRow, 1, indexRow, listTitle.Length);
                    indexRow++;
                }
            }

            indexRow++;
            report.SetCellColor(indexRow, 1, indexRow, 1, Color.Green);
            report.AddSingleValue("Удалённые записи", indexRow, 2);

            /*
             * foreach (DataRow r in dtReport.Rows)
             * {
             *  report.AddSingleValue(r["InventoryNumber"].ToString(), indexRow, 1);
             *  report.AddSingleValue(r["TypeComponentsHardware"].ToString(), indexRow, 2);
             *  report.AddSingleValue(r["nameOb"].ToString(), indexRow, 3);
             *  report.AddSingleValue(r["cName"].ToString(), indexRow, 4);
             *  report.AddSingleValue(r["valueOld"].ToString(), indexRow, 5);
             *  report.AddSingleValue(r["valueNew"].ToString(), indexRow, 6);
             *  report.AddSingleValue(r["DateCreate"].ToString(), indexRow, 7);
             *  report.AddSingleValue(r["FIO"].ToString(), indexRow, 8);
             *  report.SetBorders(indexRow, 1, indexRow, listTitle.Length);
             *  indexRow++;
             * }
             */

            report.SetColumnAutoSize(startPos, 1, indexRow, listTitle.Length);
            report.Show();
        }
Example #4
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            Logging.StartFirstLevel(79);
            Logging.Comment("Произведена выгрузка отчета с превышения процента наценки");
            Logging.Comment($"Количество выгруженных записей: {dtResult.Rows.Count}");
            Logging.Comment($"Настройка процента наценки: {tbPrcn.Text}");
            Logging.StopFirstLevel();

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad("list-1");

            int rIndex   = 1;
            int maxMerge = 0;

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

            report.Merge(rIndex, 1, rIndex, maxMerge);
            report.AddSingleValue("Проверка превышения процента наценки", rIndex, 1);
            report.SetCellAlignmentToCenter(rIndex, 1, rIndex, 1);
            report.SetFontBold(rIndex, 1, rIndex, 1);
            report.SetFontSize(rIndex, 1, rIndex, 1, 14);
            rIndex++;

            report.Merge(rIndex, 1, rIndex, 2);
            report.Merge(rIndex, 5, rIndex, 7);
            report.AddSingleValue("Дата: " + date.ToShortDateString(), rIndex, 1);
            report.AddSingleValue("Выгрузил: " + UserSettings.User.FullUsername, rIndex, 3);
            report.SetCellAlignmentToRight(rIndex, 3, rIndex, 3);
            rIndex++;


            string shotName = "";

            if (Nwuram.Framework.Settings.Connection.ConnectionSettings.GetServer().ToLower().Contains("k21"))
            {
                shotName = "Косыгина 21";
            }
            else
            {
                shotName = "Хошимина 14";
            }

            report.Merge(rIndex, 1, rIndex, 2);
            report.Merge(rIndex, 3, rIndex, 4);
            report.Merge(rIndex, 5, rIndex, 7);
            report.AddSingleValue("Процент наценки: " + tbPrcn.Text, rIndex, 1);
            report.AddSingleValue("Магазин: " + shotName, rIndex, 3);
            report.AddSingleValue("Дата выгрузки: " + DateTime.Now.ToString(), rIndex, 5);
            report.SetCellAlignmentToRight(rIndex, 3, rIndex, 3);
            rIndex++;
            rIndex++;

            int cIndex = 0;

            foreach (DataGridViewColumn col in dgvData.Columns)
            {
                if (col.Visible)
                {
                    cIndex++;
                    report.AddSingleValue(col.HeaderText, rIndex, cIndex);
                }
            }
            report.SetBorders(rIndex, 1, rIndex, cIndex);
            report.SetCellAlignmentToCenter(rIndex, 1, rIndex, cIndex);
            report.SetWrapText(rIndex, 1, rIndex, cIndex);
            rIndex++;

            foreach (DataRowView row in dtResult.DefaultView)
            {
                cIndex = 0;
                foreach (DataGridViewColumn col in dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        cIndex++;
                        report.AddSingleValue(row[col.DataPropertyName].ToString(), rIndex, cIndex);
                    }
                }
                report.SetBorders(rIndex, 1, rIndex, cIndex);
                report.SetCellAlignmentToCenter(rIndex, 1, rIndex, cIndex);
                rIndex++;
            }

            report.SetColumnAutoSize(1, 1, rIndex, maxMerge);
            report.Show();
        }
Example #5
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;
            });
        }
Example #6
0
        private void buttonPrint_Click(object sender, EventArgs e)
        {
            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad();

            int indexRow = 1;

            int maxColumns = 0;

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

                    /*if (col.Name.Equals(cDeps.Name)) setWidthColumn(indexRow, maxColumns, 18, report);
                     * if (col.Name.Equals(cPost.Name)) setWidthColumn(indexRow, maxColumns, 18, report);
                     * if (col.Name.Equals(cFIO.Name)) setWidthColumn(indexRow, maxColumns, 20, report);
                     * if (col.Name.Equals(cPass.Name)) setWidthColumn(indexRow, maxColumns, 15, report);
                     * if (col.Name.Equals(cDatePrintPass.Name)) setWidthColumn(indexRow, maxColumns, 17, report);
                     * if (col.Name.Equals(cPhone.Name)) setWidthColumn(indexRow, maxColumns, 17, 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($"Отдел: {cmbDeps.Text}", indexRow, 1);
            //indexRow++;

            //report.Merge(indexRow, 1, indexRow, maxColumns);
            //report.AddSingleValue($"Должность: {cmbPost.Text}", indexRow, 1);
            //indexRow++;

            //report.Merge(indexRow, 1, indexRow, maxColumns);
            //report.AddSingleValue($"Место работы: {(rbOffice.Checked ? rbOffice.Text : rbUni.Text)}", indexRow, 1);
            //indexRow++;

            //report.Merge(indexRow, 1, indexRow, maxColumns);
            //report.AddSingleValue($"Статус сотрудника: {(rbWork.Checked ? rbWork.Text : rbUnemploy.Text)}", indexRow, 1);
            //indexRow++;

            //if (tbPostName.Text.Trim().Length != 0 || tbKadrName.Text.Trim().Length != 0)
            //{
            //    report.Merge(indexRow, 1, indexRow, maxColumns);
            //    report.AddSingleValue($"Фильтр: {(tbPostName.Text.Trim().Length != 0 ? $"Должность:{tbPostName.Text.Trim()} | " : "")} {(tbKadrName.Text.Trim().Length != 0 ? $"ФИО:{tbKadrName.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 indexCol = 0;
            foreach (DataGridViewColumn col in grdPrices.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 pricesTable.DefaultView)
            {
                indexCol = 1;
                report.SetWrapText(indexRow, indexCol, indexRow, maxColumns);
                foreach (DataGridViewColumn col in grdPrices.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++;
            }
            report.SetColumnAutoSize(6, 1, indexRow, maxColumns);
            report.Show();


            //if (grdPrices.DataSource != null)
            //{


            //    //Logging.StartFirstLevel(472);
            //    //Logging.Comment("Выгрузка данных по товарам группы");
            //    string[] filePath = (Application.StartupPath + "\\tmp").Split(new char[] { '\\' });

            //    grdPrices.Refresh();
            //    DataTable printTable = pricesTable.Copy();
            //    if (stFilter != null)
            //    {
            //        printTable.DefaultView.RowFilter = stFilter;
            //    }
            //    Print(printTable.DefaultView.ToTable(), filePath[filePath.Length - 1]);

            //}
        }
        private void createReport(bool isCart)
        {
            string nameFile = DateTime.Now.ToShortDateString() + " - " + (isCart ? "Нал." : "БезНал.");

            DataTable dtTmp = Config.hCntMain.getReportPayment(true, isCart);

            if (dtTmp == null || dtTmp.Rows.Count == 0)
            {
                MessageBox.Show("Данных для печати нет"); return;
            }
            ;

            var groupedData
                = from b in dtTmp.AsEnumerable()
                  group b by new { id_Department = b.Field <Int32>("id_Department") } into g
                select new
            {
                id_Department = g.Key.id_Department
                                //  netto = g.Sum(x => x.Field<decimal>("netto"))
            };

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad("Лист - 1");

            int indexRow = 1;

            report.Merge(indexRow, 1, indexRow, 6);
            report.AddSingleValue("Отчёт по выданным " + (isCart ? "Безнал." : "Нал.") + " ДС ", indexRow, 1);
            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            report.SetFontBold(indexRow, 1, indexRow, 1);
            indexRow++;
            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++;

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


            foreach (var grp in groupedData)
            {
                DataRow[] row = dtTmp.Select(string.Format("id_Department = {0}", grp.id_Department));
                report.Merge(indexRow, 1, indexRow, 6);
                report.AddSingleValue(row[0]["nameDeps"].ToString(), indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 6);
                report.SetBorders(indexRow, 1, indexRow, 6);
                indexRow++;

                foreach (DataRow r in row)
                {
                    report.AddSingleValue(r["Number"].ToString(), indexRow, 1);
                    report.AddSingleValue(r["Description"].ToString(), indexRow, 2);
                    report.AddSingleValue(r["FIO"].ToString(), indexRow, 3);
                    report.AddSingleValue(r["Summa"].ToString(), indexRow, 4);
                    report.AddSingleValue(r["DataSumma"].ToString(), indexRow, 5);
                    //report.AddSingleValue(r["Summa"].ToString(), indexRow, 6);

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

            report.SetColumnAutoSize(6, 1, indexRow - 1, 6);
            //report.Show();
            report.SaveToFile(@"Report\" + nameFile + ".xlsx");
        }
        private void createSZMoney(bool isCart)
        {
            Logging.StartFirstLevel(79);

            Logging.Comment("Запрос на выдачу " + (isCart ? "Безнал." : "Нал.") + " ДС за " + DateTime.Now.ToShortDateString());

            Logging.Comment("Операцию выполнил: ID:" + Nwuram.Framework.Settings.User.UserSettings.User.Id
                            + " ; ФИО:" + Nwuram.Framework.Settings.User.UserSettings.User.FullUsername);
            Logging.StopFirstLevel();

            DataTable dtTmp = Config.hCntMain.getReportPayment(false, isCart);

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

            var groupedData
                = from b in dtTmp.AsEnumerable()
                  group b by new { id_Department = b.Field <Int32>("id_Department") } into g
                select new
            {
                id_Department = g.Key.id_Department
                                //  netto = g.Sum(x => x.Field<decimal>("netto"))
            };

            for (int i = dtTmp.Rows.Count - 1; i >= 0; i--)
            {
                DataRow dr = dtTmp.Rows[i];
                if (dr["type"].ToString().Equals("2"))
                {
                    dr.Delete();
                }
            }
            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad("Лист - 1");

            int indexRow = 1;

            report.Merge(indexRow, 1, indexRow, 4);
            report.AddSingleValue("Запрос на выдачу " + (isCart ? "Безнал." : "Нал.") + " ДС за " + DateTime.Now.ToShortDateString(), indexRow, 1);
            report.SetCellAlignmentToJustify(indexRow, 1, indexRow, 1);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 1);
            report.SetFontSize(indexRow, 1, indexRow, 1, 16);
            report.SetFontBold(indexRow, 1, indexRow, 1);
            report.SetRowHeight(indexRow, 1, indexRow, 4, 40);
            indexRow++;
            indexRow++;


            report.AddSingleValue("№ СЗ", indexRow, 1);
            report.AddSingleValue("Описание", indexRow, 2);
            report.AddSingleValue("Должность", indexRow, 3);
            report.AddSingleValue("Сумма", indexRow, 4);
            report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 4);
            report.SetBorders(indexRow, 1, indexRow, 4);
            indexRow++;


            foreach (var grp in groupedData)
            {
                DataRow[] row = dtTmp.Select(string.Format("id_Department = {0}", grp.id_Department));
                report.Merge(indexRow, 1, indexRow, 4);
                report.AddSingleValue(row[0]["nameDeps"].ToString(), indexRow, 1);
                report.SetCellAlignmentToCenter(indexRow, 1, indexRow, 4);
                report.SetBorders(indexRow, 1, indexRow, 4);
                indexRow++;

                foreach (DataRow r in row)
                {
                    report.AddSingleValue(r["Number"].ToString(), indexRow, 1);
                    report.AddSingleValue(r["Description"].ToString(), indexRow, 2);
                    report.AddSingleValue(r["FIO"].ToString(), indexRow, 3);
                    report.AddSingleValue(r["Summa"].ToString(), indexRow, 4);

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

            report.SetColumnAutoSize(3, 1, indexRow - 1, 4);
            report.Show();
        }
Example #9
0
        private void btPrint_Click(object sender, EventArgs e)
        {
            Logging.StartFirstLevel(79);

            Logging.Comment("Выгрузка отчёта из справочника категорий");
            if (!string.IsNullOrWhiteSpace(tbName.Text))
            {
                Logging.Comment($"Фильтр по наименованию категорий: {tbName.Text}");
            }
            Logging.StopFirstLevel();

            Nwuram.Framework.ToExcelNew.ExcelUnLoad report = new Nwuram.Framework.ToExcelNew.ExcelUnLoad("list-1");

            int rIndex = 1;

            report.Merge(rIndex, 1, rIndex, 5);
            report.AddSingleValue("Справочник категорий", rIndex, 1);
            report.SetCellAlignmentToCenter(rIndex, 1, rIndex, 1);
            report.SetFontBold(rIndex, 1, rIndex, 1);
            report.SetFontSize(rIndex, 1, rIndex, 1, 14);
            rIndex++;

            report.Merge(rIndex, 3, rIndex, 5);
            report.AddSingleValue("Выгрузил: " + UserSettings.User.FullUsername, rIndex, 3);
            report.SetCellAlignmentToRight(rIndex, 3, rIndex, 3);
            rIndex++;


            report.Merge(rIndex, 1, rIndex, 2);
            report.Merge(rIndex, 3, rIndex, 5);
            report.AddSingleValue("Фильтры: " + tbName.Text, rIndex, 1);
            report.AddSingleValue("Дата выгрузки: " + DateTime.Now.ToString(), rIndex, 3);
            report.SetCellAlignmentToRight(rIndex, 3, rIndex, 3);
            rIndex++;
            rIndex++;



            int cIndex = 0;

            foreach (DataGridViewColumn col in dgvData.Columns)
            {
                if (col.Visible)
                {
                    cIndex++;
                    report.AddSingleValue(col.HeaderText, rIndex, cIndex);
                }
            }
            report.SetBorders(rIndex, 1, rIndex, cIndex);
            report.SetCellAlignmentToCenter(rIndex, 1, rIndex, cIndex);
            rIndex++;

            foreach (DataRowView row in dtData.DefaultView)
            {
                report.AddSingleValue(row["nameDep"].ToString(), rIndex, 1);
                report.AddSingleValue(row["cName"].ToString(), rIndex, 2);
                report.AddSingleValue(row["cNameParent"].ToString(), rIndex, 3);
                if (!(bool)row["isActive"])
                {
                    report.SetCellColor(rIndex, 1, rIndex, cIndex, panel1.BackColor);
                }

                report.SetBorders(rIndex, 1, rIndex, cIndex);
                report.SetCellAlignmentToCenter(rIndex, 1, rIndex, cIndex);
                rIndex++;
            }

            report.Merge(rIndex, 2, rIndex, 5);
            report.SetCellColor(rIndex, 1, rIndex, 1, panel1.BackColor);
            report.AddSingleValue("- не действующие", rIndex, 2);
            rIndex++;

            report.SetColumnAutoSize(1, 1, rIndex, 5);
            report.Show();
        }