Esempio n. 1
0
        private async void btPrint_Click(object sender, EventArgs e)
        {
            if (dtData == null || dtData.Rows.Count == 0 || dtData.DefaultView.Count == 0)
            {
                MessageBox.Show("Нет данных для формирования отчёта.", "Печать", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

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

            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 dgvData.Columns)
                {
                    if (col.Visible)
                    {
                        maxColumns++;
                        if (col.Name.Equals(cName.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 37, report);
                        }
                        if (col.Name.Equals(cUnit.Name))
                        {
                            setWidthColumn(indexRow, maxColumns, 17, report);
                        }
                    }
                }


                #region "Head"
                report.Merge(indexRow, 1, indexRow, maxColumns);
                report.SetWrapText(indexRow, 1, indexRow, 1);
                report.SetRowHeight(indexRow, 1, indexRow, 1, 45);
                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++;

                config.DoOnUIThread(() =>
                {
                    //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++;

                    //report.Merge(indexRow, 1, indexRow, maxColumns);
                    //report.AddSingleValue($"Тип договора: {cmbTypeDoc.Text}", indexRow, 1);
                    //indexRow++;


                    if (tbName.Text.Trim().Length != 0)
                    {
                        report.Merge(indexRow, 1, indexRow, maxColumns);
                        report.AddSingleValue($"Фильтр: {(tbName.Text.Trim().Length != 0 ? $"EAN:{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 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.SetCellAlignmentToJustify(indexRow, 1, indexRow, maxColumns);
                report.SetWrapText(indexRow, 1, indexRow, maxColumns);
                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++;
                        }
                    }

                    if (!(bool)row["isActive"])
                    {
                        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++;
                }

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

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

                report.Show();
                return(true);
            });
        }
Esempio n. 2
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. 3
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. 4
0
        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();
        }