Example #1
0
        private void UpdatePreview()
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                reportDocument.XamlData = tb_source.Text;

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                List <ReportData> listData = new List <ReportData>();

                ReportData data = new ReportData();


                listData.Add(data);


                XpsDocument xps = reportDocument.CreateXpsDocument(listData);
                fdViewer.Document = xps.GetFixedDocumentSequence();
                t_error.Text      = "";
            }
            catch (Exception ex)
            {
                t_error.Text = ex.Message + Environment.NewLine + ex.StackTrace;
            }
        }
Example #2
0
        public static void CreateDebtorReport(DocumentViewer documentViewer, ObservableCollection <Customer> Data)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"..\..\Assets\ReportTemplates\DebtorReport\DebtorReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"..\..\Assets\ReportTemplates\DebtorReport\");
                reader.Close();

                ReportData data = new ReportData();

                data.ReportDocumentValues.Add("PrintDate", DateTime.Now);

                DataTable table = new DataTable("DebtorReport");
                table.Columns.Add("ID", typeof(string));
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("Debt", typeof(string));
                table.Columns.Add("Phone", typeof(string));
                foreach (var item in Data)
                {
                    table.Rows.Add(new object[] { item.ID, item.Name, string.Format("Tháng này: {0}\nTháng trước: {1:#,###,##0} vnđ", item.DebtFormat, item.Tag), item.PhoneFormat });
                }
                data.DataTables.Add(table);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                WarningBox.Show("Thông báo...", "Xãy ra sự cố!", "Có vấn đề khi lập báo cáo với dữ liệu được tra!", false, ex.Message);
            }
        }
Example #3
0
        public static void CreateNumberReport(DocumentViewer documentViewer, ObservableCollection <Book> Data)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"..\..\Assets\ReportTemplates\NumberReport\NumberReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"..\..\Assets\ReportTemplates\NumberReport\");
                reader.Close();

                ReportData data = new ReportData();

                data.ReportDocumentValues.Add("PrintDate", DateTime.Now);

                DataTable table = new DataTable("NumberReport");
                table.Columns.Add("Id", typeof(string));
                table.Columns.Add("ItemInfo", typeof(string));
                table.Columns.Add("IDCode", typeof(string));
                table.Columns.Add("Number", typeof(string));
                foreach (var item in Data)
                {
                    table.Rows.Add(new object[] { item.ID, string.Format("Tên sách: {0}\nTác giả: {1}\nThể loại: {2}", item.Name, item.AuthorsShortFormat, item.GenresShortFormat), string.Format("9001{0:00000000}", item.ID), string.Format("Tháng này: {0} quyển\nTháng trước: {1} quyển", item.Number, item.Tag) });
                }
                data.DataTables.Add(table);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                WarningBox.Show("Thông báo...", "Xãy ra sự cố!", "Có vấn đề khi lập báo cáo với dữ liệu được tra!", false, ex.Message);
            }
        }
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\ComplexReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                List <ReportData> listData = new List <ReportData>();
                for (int i = 0; i < 5; i++) // generates five reports
                {
                    ReportData data = new ReportData();

                    // set constant document values
                    data.ReportDocumentValues.Add("PrintDate", dateTimeStart); // print date is now
                    data.ReportDocumentValues.Add("ReportNumber", (i + 1));    // report number

                    // sample table "Ean"
                    DataTable table = new DataTable("Ean");
                    table.Columns.Add("Position", typeof(string));
                    table.Columns.Add("Item", typeof(string));
                    table.Columns.Add("EAN", typeof(string));
                    table.Columns.Add("Count", typeof(int));
                    Random rnd   = new Random(1234 + i);
                    int    count = rnd.Next(20) * (rnd.Next(2) + 1);
                    for (int j = 1; j <= count; j++)
                    {
                        // randomly create some articles
                        table.Rows.Add(new object[] { j, "Item " + (j + (1000 * (i + 1))).ToString("0000"), "123456790123", rnd.Next(9) + 1 });
                    }
                    data.DataTables.Add(table);
                    listData.Add(data);
                }

                XpsDocument xps = reportDocument.CreateXpsDocument(listData);
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #5
0
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader   reader         = new StreamReader(new FileStream(@"Report\BorrowReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Report\");
                reader.Close();

                ReportData data = new ReportData();

                // set constant document values
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                // sample table "Ean"
                DataTable table = new DataTable("Ean");
                table.Columns.Add("wrenchbarcode", typeof(string));
                table.Columns.Add("borrowuser", typeof(string));
                table.Columns.Add("borrowoper", typeof(string));
                table.Columns.Add("borrowtime", typeof(string));
                table.Columns.Add("returnuser", typeof(string));
                table.Columns.Add("returnoper", typeof(string));
                table.Columns.Add("returntime", typeof(string));
                //table.Columns.Add("common", typeof(string));
                // Random rnd = new Random(1234);
                foreach (BorrowHistory bh in _borrowhistory)
                {
                    table.Rows.Add(new object [] { bh.wrenchbarcode, bh.borrowusername, bh.borrowoperator, bh.borrowdate, bh.returnuser, bh.returnoperator, bh.returndate });
                }
                //for (int i = 1; i <= 100; i++)
                //{
                //    // randomly create some articles
                //    table.Rows.Add(new object[] { i, "Item " + i.ToString("0000"), "123456790123", rnd.Next(9) + 1 ,"returnuser","returnoper","returntime","common"});
                //}
                data.DataTables.Add(table);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #6
0
        public void DocViewerLoaded(DocumentViewer documentViewer)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                reportDocument.ImageProcessing += reportDocument_ImageProcessing;
                reportDocument.ImageError      += reportDocument_ImageError;

                StreamReader reader =
                    new StreamReader(new FileStream(@"Templates\EndoscopyResults.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                //Clinic info
                if (_clinic != null)
                {
                    data.ReportDocumentValues.Add("ClinicName", _clinic.Name.ToUpper());
                    data.ReportDocumentValues.Add("ClinicAddress", _clinic.Address);
                    data.ReportDocumentValues.Add("ClinicPhone", _clinic.Phone);
                }

                //Patient info
                data.ReportDocumentValues.Add("PatientName", _patient.Name.ToUpper());
                data.ReportDocumentValues.Add("BirthDay", "Ngày sinh:  " + _patient.Birthday);
                data.ReportDocumentValues.Add("Address", _patient.Address);
                data.ReportDocumentValues.Add("Sex", "Giới tính:  " + _patient.Sex);
                data.ReportDocumentValues.Add("Diagnose", _session.Diagnose);
                data.ReportDocumentValues.Add("Type", _esRecord.EndoscopyType.Name);

                //Endoscopy results
                data.ReportDocumentValues.Add("Result", _esRecord.Result);

                //Note
                string tmp = "Ngày " + string.Format("{0:dd}", _session.Date) + " tháng " +
                             string.Format("{0:MM}", _session.Date)
                             + " năm " + String.Format("{0:yyyy}", _session.Date);
                data.ReportDocumentValues.Add("Date", tmp);
                data.ReportDocumentValues.Add("DoctorName", _session.DoctorName);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                IsBusyHidden = true;
                NotifyOfPropertyChange(() => IsBusyHidden);
            }
        }
        internal XpsDocument Generate(string path, List <DataTable> results)
        {
            Tracer.Verbose("ReportGenerator:Generate", "START");

            XpsDocument xpsResult = null;

            try
            {
                EventDispatcher.Instance.RaiseStatus("Generating document", StatusEventType.StartProgress);

                DateTime dateTimeStart = DateTime.Now;                 // start time measure here

                //create a new report
                ReportDocument reportDocument = new ReportDocument();

                //retreive the template from the resources
                Stream       stream = Assembly.GetCallingAssembly().GetManifestResourceStream(path);
                StreamReader reader = new StreamReader(stream);
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = PathHelper.ApplicationPath;
                stream.Close();

                ReportData rd = new ReportData();

                // set constant document values
                rd.ReportDocumentValues.Add("GenerationTime", dateTimeStart);                 // print date is now

                rd.ReportDocumentValues.Add("Server", "2008");
                rd.ReportDocumentValues.Add("DatabaseName", 1);
                rd.ReportDocumentValues.Add("AnalisysTime", 1);
                rd.ReportDocumentValues.Add("Company", 1);
                rd.ReportDocumentValues.Add("Author", 1);
                rd.ReportDocumentValues.Add("Version", 1);

                rd.DataTables.AddRange(results);

                xpsResult = reportDocument.CreateXpsDocument(rd);

                // show the elapsed time in window title
                EventDispatcher.Instance.RaiseStatus(string.Format("Report generated in {0} sec", (DateTime.Now - dateTimeStart).TotalSeconds),
                                                     StatusEventType.StopProgress);

                return(xpsResult);
            }
            catch (Exception all)
            {
                Tracer.Error("ReportGenerator.Generate", all);
                return(null);
            }
            finally
            {
                Tracer.Verbose("ReportGenerator:Generate", "END");
            }
        }
Example #8
0
        private void ShowReport()
        {
            ReportUIModel.IsBusyIndicatorHidden = false;
            try {
                Utils.EnsureCulture();
                var flowDocument =
                    (FlowDocument)
                    Application.LoadComponent(
                        new Uri(string.Format("Templates/{0}.{1}.xaml", _reportFileName, Settings.Default.Culture),
                                UriKind.Relative));

                var temp = new WindowBase(false, false, false);
                flowDocument.FontFamily    = temp.FontFamily;
                flowDocument.FlowDirection = temp.FlowDirection;

                var reportDocument = new ReportDocument {
                    XamlData             = XamlWriter.Save(flowDocument),
                    XpsCompressionOption = CompressionOption.SuperFast
                };

                var data = new ReportData();

                data.ReportDocumentValues.Add("ReportedOn",
                                              string.Format(ReportPreviewResources.ReportGeneratingDate,
                                                            DateTime.Now.ToLocalized()));

                data.ReportDocumentValues.Add("ReportedBy",
                                              string.Format(ReportPreviewResources.ReporterFormat,
                                                            AppContext.Instanse.User.UserName,
                                                            AppContext.Instanse.User.Name ??
                                                            ReportPreviewResources.NoName));

                data.ReportDocumentValues.Add("Slogan", ReportPreviewResources.Slogan);

                data.ReportDocumentValues.Add("ReportTitle", Settings.Default.ReportTitle);
                data.ReportDocumentValues.Add("ReportDescription", Settings.Default.ReportDescription);

                data.DataTables.Add(_items.ToDataTable());

                var xps = reportDocument.CreateXpsDocument(data);

                DispatcherHelper.CheckBeginInvokeOnUI(() => ReportUIModel.Document = xps.GetFixedDocumentSequence());
                /*} catch (Exception) {*/
            } finally {
                ReportUIModel.IsBusyIndicatorHidden = true;
            }
        }
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(delegate
            {
                try
                {
                    ReportDocument reportDocument   = new ReportDocument();
                    reportDocument.ImageProcessing += ReportDocumentImageProcessing;
                    reportDocument.ImageError      += ReportDocumentImageError;

                    StreamReader reader          = new StreamReader(new FileStream(@"Templates\ImageReport.xaml", FileMode.Open, FileAccess.Read));
                    reportDocument.XamlData      = reader.ReadToEnd();
                    reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                    reader.Close();

                    ReportData data = new ReportData();

                    // set constant document values
                    data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                    DateTime dateTimeStart = DateTime.Now;                    // start time measure here

                    XpsDocument xps         = reportDocument.CreateXpsDocument(data);
                    documentViewer.Document = xps.GetFixedDocumentSequence();

                    // show the elapsed time in window title
                    Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
                }
                catch (Exception ex)
                {
                    // show exception
                    MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                finally
                {
                    busyDecorator.IsBusyIndicatorHidden = true;
                }
            }));
        }
        private void WindowActivated(object sender, EventArgs e)
        {
            try
            {
                var reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\ExpenseReportTemplate.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Template\");
                reader.Close();

                var data = new ReportData();

                data.ReportDocumentValues.Add("Seller", this.expense.Seller);
                data.ReportDocumentValues.Add("Address", this.expense.Address);
                data.ReportDocumentValues.Add("TransactionDate", this.expense.Date.ToShortDateString());
                data.ReportDocumentValues.Add("InvoiceNumber", this.expense.InvoiceNumber);

                // table list
                var table = new DataTable("list");
                table.Columns.Add("No", typeof(string));
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("Quantity", typeof(int));
                table.Columns.Add("Price", typeof(float));
                table.Columns.Add("TotalPrice", typeof(float));

                for (var i = 0; i < this.expense.Items.Count; i++)
                {
                    var item = this.expense.Items[i];
                    table.Rows.Add(new object[] { i + 1, item.Name, item.Quantity, item.Price, item.Quantity * item.Price });
                }

                data.DataTables.Add(table);
                data.ReportDocumentValues.Add("GrandTotal", this.expense.Total);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                this.documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message + "\r\n\r\n" + error.GetType() + "\r\n" + error.StackTrace, error.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        private void WindowActivated(object sender, EventArgs e)
        {
            try
            {
                var reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\AccountReportTemplate.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Template\");
                reader.Close();

                var data = new ReportData();

                // table list
                var table = new DataTable("transactions");
                table.Columns.Add("Date", typeof(DateTime));
                table.Columns.Add("InvoiceNo", typeof(string));
                table.Columns.Add("Debit", typeof(string));
                table.Columns.Add("Credit", typeof(string));

                foreach (var transaction in this.transactions)
                {
                    table.Rows.Add(new object[] { transaction.Date, transaction.InvoiceNumber, transaction.Debit, transaction.Credit });
                }

                data.DataTables.Add(table);
                data.ReportDocumentValues.Add("CreditBalance", this.creditBalance);
                data.ReportDocumentValues.Add("DebitBalance", this.debitBalance);
                data.ReportDocumentValues.Add("Balance", this.creditBalance - this.debitBalance);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                this.documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message + "\r\n\r\n" + error.GetType() + "\r\n" + error.StackTrace, error.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #12
0
        private void UpdatePreview()
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                if (tb_source.Text.IsEmpty())
                {
                    reportDocument.XamlData      = HandleVars(File.ReadAllText(t_file.Text));
                    reportDocument.XamlImagePath = System.IO.Path.GetDirectoryName(t_file.Text);
                }
                else
                {
                    reportDocument.XamlData      = HandleVars(tb_source.Text);
                    reportDocument.XamlImagePath = Tools.GetLocalFile("");
                }

                DateTime          dateTimeStart = DateTime.Now;
                List <ReportData> listData      = new List <ReportData>();
                ReportData        data          = new ReportData();
                listData.Add(data);
                XpsDocument xps = reportDocument.CreateXpsDocument(listData);
                fdViewer.Document = xps.GetFixedDocumentSequence();
                t_error.Text      = "";
            }
            catch (Exception ex)
            {
                t_error.Text = ex.Message + Environment.NewLine + ex.StackTrace;
            }

            if (!bzoomed)
            {
                bzoomed = true;
                fdViewer.FitToWidth();
            }
        }
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                Run Run1 = new Run("Registro Médico No. ");
                Run Run2 = new Run("Fecha" + DateTime.Today.Date);

                Label lblRegistro = new Label();
                lblRegistro.Content = "99999";

                InlineUIContainer lInlineUiContainer = new InlineUIContainer();
                lInlineUiContainer.BaselineAlignment = BaselineAlignment.Bottom;
                lInlineUiContainer.Child             = lblRegistro;

                Paragraph lParagraph = new Paragraph();
                lParagraph.Inlines.Add(Run1);
                lParagraph.Inlines.Add(lInlineUiContainer);
                lParagraph.Inlines.Add(Run2);

                //FlowDocument lFlowDocument = new FlowDocument();
                //lFlowDocument.Blocks.Add(lParagraph);
                //this.Content = lFlowDocument;
                //PrintDialog printDlg = new PrintDialog();
                //IDocumentPaginatorSource idpSource = lFlowDocument;

                //printDlg.PrintDocument(idpSource.DocumentPaginator, "Hello WPF Printing.");



                ReportDocument reportDocument = new ReportDocument();
                reportDocument.ImageProcessing += reportDocument_ImageProcessing;
                reportDocument.ImageError      += reportDocument_ImageError;


                StreamReader reader = new StreamReader(new FileStream(@"Templates\ImageReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                // set constant document values
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                DateTime dateTimeStart = DateTime.Now;                    // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            if (Outgo == null)
                return;
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\OverpricingReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                DataAccess da = new DataAccess();

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("t1", typeof(string));
                dt.Columns.Add("t2", typeof(string));
                dt.Columns.Add("t3", typeof(string));
                dt.Columns.Add("t4", typeof(string));
                dt.Columns.Add("t5", typeof(string));
                dt.Columns.Add("t6", typeof(string));
                dt.Columns.Add("t7", typeof(string));
                dt.Columns.Add("t8", typeof(string));
                dt.Columns.Add("t9", typeof(string));
                dt.Columns.Add("t10", typeof(string));

                decimal sum1 = 0;
                decimal sum2 = 0;
                decimal sum3 = 0;

                // забиваем таблицу данными
                List<SpareInOverpricingView> LIST2 = da.OverpricingOfferingGet(ItemID);
                try
                {
                    string CompanyName = da.getProfileCurrent().CompanyName;
                    for (int i = 0; i < LIST2.Count; i++)
                    {
                        sum1 += LIST2[i].quantity.Value;
                        sum2 += LIST2[i].sumOld.Value;
                        sum3 += LIST2[i].sumNew.Value;

                        dt.Rows.Add(new object[] {
                            LIST2[i].SpareName,
                            LIST2[i].UnitName,
                            LIST2[i].quantity,
                            LIST2[i].purchasePrice,
                            LIST2[i].percentOld,
                            LIST2[i].priceOld,
                            LIST2[i].sumOld,
                            LIST2[i].percentNew,
                            LIST2[i].priceNew,
                            LIST2[i].sumNew
                        });
                    }
                }
                catch (Exception exc)
                {
                    Marvin.Instance.Log(exc.Message);
                    throw exc;
                }
                string strDate = Outgo.createdOn.Value.Day.ToString();
                string mnth = "";
                switch (Outgo.createdOn.Value.Month)
                {
                    case 1:
                        mnth = "января";
                        break;

                    case 2:
                        mnth = "февраля";
                        break;

                    case 3:
                        mnth = "марта";
                        break;

                    case 4:
                        mnth = "апреля";
                        break;

                    case 5:
                        mnth = "мая";
                        break;

                    case 6:
                        mnth = "июня";
                        break;

                    case 7:
                        mnth = "июля";
                        break;

                    case 8:
                        mnth = "августа";
                        break;

                    case 9:
                        mnth = "сентября";
                        break;

                    case 10:
                        mnth = "октября";
                        break;

                    case 11:
                        mnth = "ноября";
                        break;

                    case 12:
                        mnth = "декабря";
                        break;
                }
                strDate += " " + mnth + " " + Outgo.createdOn.Value.Year + " г.";
                data.ReportDocumentValues.Add("p1", Outgo.id);
                data.ReportDocumentValues.Add("p2", strDate); // print date is now
                data.ReportDocumentValues.Add("sum1", sum1);
                data.ReportDocumentValues.Add("sum2", sum2);
                data.ReportDocumentValues.Add("sum3", sum3);

                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                // show exception
                Marvin.Instance.Log(ex.Message);
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            if (Outgo == null)
            {
                return;
            }
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\InvoiceReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                decimal    asum = 0;
                DataAccess da   = new DataAccess();
                string     BCC  = da.getBasicCurrencyCode();

                //Income.currencyReference.Load();
                //string CCC = Income.currency.code;

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("Num", typeof(int));
                dt.Columns.Add("SpareName", typeof(string));
                dt.Columns.Add("UnitName", typeof(string));
                dt.Columns.Add("Q", typeof(int));
                dt.Columns.Add("P", typeof(double));
                dt.Columns.Add("VR", typeof(string));
                dt.Columns.Add("TS", typeof(double));

                // забиваем таблицу данными
                List <SpareInInvoiceView> LIST2 = da.GetSparesByInvoiceID(InvoiceId);
                try
                {
                    string CompanyName = da.getProfileCurrent().CompanyName;
                    for (int i = 0; i < LIST2.Count; i++)
                    {
                        asum += LIST2[i].TotalWithVat.Value;
                        dt.Rows.Add(new object[] {
                            i + 1,
                            (LIST2[i].SpareName + " (" + LIST2[i].SpareCodeShatem + ")"),
                            "шт.",
                            LIST2[i].quantity,
                            LIST2[i].price.Value,
                            LIST2[i].VatRateName,
                            LIST2[i].TotalWithVat
                        });
                    }
                }
                catch (Exception exc)
                {
                    Marvin.Instance.Log(exc.Message);
                    throw exc;
                }
                string str_ts = RSDN.RusCurrency.Str(asum, "BYR");

                //string str_vs = RSDN.RusCurrency.Str(vs, "BYR");
                // set constant document values
                //string strDate = Outgo.created_on.Value.GetDateTimeFormats('d')[3];
                string strDate = Outgo.InvoiceDate.Value.Day.ToString();
                string mnth    = "";
                switch (Outgo.InvoiceDate.Value.Month)
                {
                case 1:
                    mnth = "января";
                    break;

                case 2:
                    mnth = "февраля";
                    break;

                case 3:
                    mnth = "марта";
                    break;

                case 4:
                    mnth = "апреля";
                    break;

                case 5:
                    mnth = "мая";
                    break;

                case 6:
                    mnth = "июня";
                    break;

                case 7:
                    mnth = "июля";
                    break;

                case 8:
                    mnth = "августа";
                    break;

                case 9:
                    mnth = "сентября";
                    break;

                case 10:
                    mnth = "октября";
                    break;

                case 11:
                    mnth = "ноября";
                    break;

                case 12:
                    mnth = "декабря";
                    break;
                }
                strDate += " " + mnth + " " + Outgo.InvoiceDate.Value.Year + " г.";
                data.ReportDocumentValues.Add("ReportDate", strDate); // print date is now

                data.ReportDocumentValues.Add("TTS", asum);
                settings_profile       profile            = da.getProfileCurrent();
                ProfileBankAccountView ProfileBankAccount = da.getProfileBankAccountCurrent();
                string w1 = "не указано";
                string w2 = "не указано";
                string w3 = "не указано";

                if (ProfileBankAccount != null)
                {
                    w1 = ProfileBankAccount.BankAccount;;
                    w2 = ProfileBankAccount.BankName;
                    w3 = ProfileBankAccount.BankMFO;
                }

                //string p1 = profile.CompanyName + ", " + profile.AddressJur + ", УНП " + Regex.Replace(profile.UNN, " +", " ");
                //p1 = Regex.Replace(p1, " +", " ");

                // ПРАВИЛЬНЫЕ ПАРАМЕТРЫ
                invoice inv = Outgo;
                string  q1  = profile.CompanyName + ", " + profile.AddressJur + ", УНН:" + profile.UNN;
                data.ReportDocumentValues.Add("p1", q1);
                string q2 = w1;
                data.ReportDocumentValues.Add("p2", q2);
                string q3 = w2 + ", МФО:" + w3;
                data.ReportDocumentValues.Add("p3", q3);
                string q4 = profile.CompanyName;
                data.ReportDocumentValues.Add("p4", q4);
                string q5 = profile.LoadPoint;
                data.ReportDocumentValues.Add("p5", q5);
                string q6 = inv.AccountName + ", " + inv.AccountAddress + ", УНН:" + inv.AccountUNN;
                data.ReportDocumentValues.Add("p6", q6);
                string BankAccount = "р/с не указан";
                if (inv.BankAccountID != null)
                {
                    BankAccountView ba = da.BankAccountView(inv.BankAccountID.Value);
                    BankAccount = ba.BankAccount;
                }
                string q7 = BankAccount + ", " + inv.AccountBankName + ", " + inv.AccountBankMFO;
                data.ReportDocumentValues.Add("p7", q7);
                string q8 = inv.AccountName + ", " + inv.AccountAddress;
                data.ReportDocumentValues.Add("p8", q8);
                string q9 = inv.AccountAddress;
                data.ReportDocumentValues.Add("p9", q9);
                string q0 = str_ts;
                data.ReportDocumentValues.Add("p0", q0);
                string q10 = inv.InvoiceNumber.ToString();
                data.ReportDocumentValues.Add("p10", q10);
                string q11 = strDate;
                data.ReportDocumentValues.Add("p11", q11);

                // СТАРЫЕ ПАРАМЕТРЫ
                // Поставщик и его адрес:

                /*
                 * data.ReportDocumentValues.Add("param1", p1);
                 *
                 * // Номер инвойса
                 * string param2 = Outgo.id.ToString();
                 * data.ReportDocumentValues.Add("param2", param2);
                 *
                 * // Номер счета:
                 * string param3 = Outgo.AccountBankNum;
                 * data.ReportDocumentValues.Add("param3", param3);
                 *
                 * // дата
                 * string param4 = strDate;
                 * data.ReportDocumentValues.Add("param4", param4);
                 *
                 * // Банк:
                 * string param5 = "########";
                 * data.ReportDocumentValues.Add("param5", param5);
                 *
                 * // Грузоотправитель:
                 * string param6 = profile.CompanyName;
                 * data.ReportDocumentValues.Add("param6", param6);
                 *
                 * // Ст. отправления:
                 * string param7 = profile.AddressFact;
                 * data.ReportDocumentValues.Add("param7", param7);
                 *
                 * // Плательщик и его адрес:
                 * string param8 = Outgo.AccountName;
                 * data.ReportDocumentValues.Add("param8", param8);
                 *
                 * // Номер счета и банк:
                 * string param9 = Outgo.AccountBankNum + ", " + Outgo.AccountBankName;
                 * data.ReportDocumentValues.Add("param9", param9);
                 *
                 * // Грузополучатель:
                 * string param10 = Outgo.AccountName;
                 * data.ReportDocumentValues.Add("param10", param10);
                 *
                 * // Ст. назначения, число мест, вес:
                 * string param11 = "############";
                 * data.ReportDocumentValues.Add("param11", param11);
                 */

                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                Marvin.Instance.Log(ex.Message);

                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #16
0
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\ChartReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                // set constant document values
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                // sample table "Example1"
                DataTable table = new DataTable("Example1");
                table.Columns.Add("Year", typeof(string));
                table.Columns.Add("Value", typeof(decimal));
                Random rnd = new Random(1234);
                for (int i = 1990; i <= 2009; i++)
                {
                    // randomly create some values
                    table.Rows.Add(new object[] { i, rnd.Next(100000) + 10000 });
                }
                data.DataTables.Add(table);

                // sample table "Example2"
                table = new DataTable("Example2");
                table.Columns.Add("Year", typeof(string));
                table.Columns.Add("Value", typeof(decimal));
                int citizens = rnd.Next(100000);
                for (int i = 1990; i <= 2009; i++)
                {
                    // randomly create some values
                    table.Rows.Add(new object[] { i, citizens });
                    citizens += rnd.Next(10000);
                }
                data.DataTables.Add(table);

                // sample table "Example3"
                table = new DataTable("Example3");
                table.Columns.Add("Opinion", typeof(string));
                table.Columns.Add("Percent", typeof(decimal));
                table.Rows.Add(new object[] { "Yes", 36.2 });
                table.Rows.Add(new object[] { "No", 21.5 });
                table.Rows.Add(new object[] { "Unsure", 100 - 36.2 - 21.5 });
                data.DataTables.Add(table);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);

                // concat XPS files
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        public void DocViewerLoaded(DocumentViewer documentViewer)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                reportDocument.ImageProcessing += reportDocument_ImageProcessing;
                reportDocument.ImageError      += reportDocument_ImageError;

                StreamReader reader =
                    new StreamReader(new FileStream(@"Templates\Prescription.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                //Clinic info
                if (_clinic != null)
                {
                    data.ReportDocumentValues.Add("ClinicName", _clinic.Name.ToUpper());
                    data.ReportDocumentValues.Add("ClinicAddress", _clinic.Address);
                    data.ReportDocumentValues.Add("ClinicPhone", _clinic.Phone);
                }

                //Patient info
                data.ReportDocumentValues.Add("PatientName", _patient.Name.ToUpper());
                data.ReportDocumentValues.Add("BirthDay", "Ngày sinh:  " + _patient.Birthday);
                data.ReportDocumentValues.Add("Address", _patient.Address);
                data.ReportDocumentValues.Add("Sex", "Giới tính:  " + _patient.Sex);
                data.ReportDocumentValues.Add("Diagnose", _session.Diagnose);

                //Prescription
                DataTable table = new DataTable("Prescription");
                table.Columns.Add("Count", typeof(int));
                table.Columns.Add("BrandName", typeof(string));
                table.Columns.Add("Quantity");
                table.Columns.Add("Type", typeof(string));
                table.Columns.Add("DrugNote", typeof(string));

                var drugs =
                    _esClinicContext.Drugs.Include("Product").ToList().Where(d => d.SessionId == _session.SessionId);
                int count = 0;
                foreach (var drug in drugs)
                {
                    count++;
                    table.Rows.Add(count, drug.Product.BrandName, drug.Quantity, drug.Product.Type, drug.Note);
                }
                data.DataTables.Add(table);

                //Note
                data.ReportDocumentValues.Add("Note", _session.Note);
                data.ReportDocumentValues.Add("ReExamDate", string.Format("{0:dd/MM/yyyy}", _session.ReExamDate));
                string tmp = "Ngày " + string.Format("{0:dd}", _session.Date) + " tháng " +
                             string.Format("{0:MM}", _session.Date)
                             + " năm " + String.Format("{0:yyyy}", _session.Date);
                data.ReportDocumentValues.Add("Date", tmp);
                data.ReportDocumentValues.Add("DoctorName", _session.DoctorName);

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                IsBusyHidden = true;
                NotifyOfPropertyChange(() => IsBusyHidden);
            }
        }
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader   reader         = new StreamReader(new FileStream(@"Templates\DynamicReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                DataTable  tableHeader = null;
                DataTable  tableData   = null;
                object[]   obj         = null;
                ReportData data        = new ReportData();

                // REPORT 1 DATA
                tableHeader = new DataTable("Header");
                tableData   = new DataTable("Data");


                tableHeader.Columns.Add();
                tableHeader.Rows.Add(new object[] { "Service" });
                tableHeader.Rows.Add(new object[] { "Amount" });
                tableHeader.Rows.Add(new object[] { "Price" });
                tableData.Columns.Add();
                tableData.Columns.Add();
                tableData.Columns.Add();
                obj = new object[3];
                for (int i = 0; i < 15; i++)
                {
                    obj[0] = String.Format("Service oferted. Nº{0}", i);
                    obj[1] = i * 2;
                    obj[2] = String.Format("{0} €", i);
                    tableData.Rows.Add(obj);
                }

                data.DataTables.Add(tableData);
                data.DataTables.Add(tableHeader);


                // REPORT 2 DATA
                tableHeader = new DataTable("Header2");
                tableData   = new DataTable("Data2");


                tableHeader.Columns.Add();
                tableHeader.Rows.Add(new object[] { "Service" });
                tableHeader.Rows.Add(new object[] { "Amount" });
                tableData.Columns.Add();
                tableData.Columns.Add();
                obj = new object[2];
                for (int i = 0; i < 15; i++)
                {
                    obj[0] = String.Format("Service offered. Nº{0}", i);
                    obj[1] = i;
                    tableData.Rows.Add(obj);
                }

                data.DataTables.Add(tableData);
                data.DataTables.Add(tableHeader);


                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #19
0
        private void BuildReportBySale()
        {
            ReportDocument reportDocument = new ReportDocument();

            StreamReader reader = new StreamReader(new FileStream(@"Templates\SalesCheckReport.xaml", FileMode.Open, FileAccess.Read));

            reportDocument.XamlData      = reader.ReadToEnd();
            reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
            reader.Close();

            ReportData data = new ReportData();
            decimal    ts   = 0;
            decimal    vs   = 0;
            decimal    asum = 0;
            DataAccess da   = new DataAccess();
            string     BCC  = da.getBasicCurrencyCode();

            // Таблица ТОВАРЫ В НАКЛАДНОЙ
            DataTable dt = new DataTable("mtable");

            // описываем столбцы таблицы
            dt.Columns.Add("SpareName", typeof(string));
            dt.Columns.Add("UnitName", typeof(string));
            dt.Columns.Add("Quantity", typeof(string));
            dt.Columns.Add("Price", typeof(string));
            dt.Columns.Add("Amount", typeof(string));
            dt.Columns.Add("VAT", typeof(string));
            dt.Columns.Add("VATAmount", typeof(string));
            dt.Columns.Add("Total", typeof(string));

            // забиваем таблицу данными

            List <ReportOutgo> listx = new List <ReportOutgo>();

            listx = da.GetReportOutgoes(sale);
            List <ReportItem> list = new List <ReportItem>();

            foreach (ReportOutgo s in listx)
            {
                if (list.FirstOrDefault(x => x.SpareID == s.SpareID) == null)
                {
                    ReportItem ri = new ReportItem();
                    ri.SpareName = s.SpareName;
                    ri.UnitName  = s.UnitName;
                    ri.Quantity  = s.quantity;
                    ri.total_sum = s.total_sum;
                    ri.VatRate   = s.VatRate.Value;
                    ri.VAT       = s.VatName;
                    ri.SpareID   = s.SpareID;
                    ri.Price     = CurrencyHelper.GetPrice("BYR", s.PriceOutBasic.Value);

                    list.Add(ri);
                }
                else
                {
                    list.FirstOrDefault(x => x.SpareID == s.SpareID).Quantity += s.quantity;
                }
            }
            if (list.Count == 0)
            {
                return;
            }

            //SpareOutgoId = list[0].OutgoID;
            //Outgo = da.SpareOutgoGet(SpareOutgoId);
            decimal TotalAmount = 0;
            string  CompanyName = da.getProfileCurrent().CompanyName;

            for (int i = 0; i < list.Count; i++)
            {
                //decimal Total = list[i].total_sum;
                //decimal VatSum = Total * list[i].VatRate / 100;
                //decimal Sum = Total - VatSum;
                //decimal Price = Sum / list[i].Quantity;
                TotalAmount += list[i].Quantity * list[i].Price;

                //ts += Total;
                //vs += VatSum;
                //asum += Sum;

                dt.Rows.Add(new object[] {
                    list[i].SpareName,
                    list[i].UnitName,
                    list[i].Quantity.ToString("0.##"),
                    list[i].Price.ToString("0.##"),
                    (list[i].Quantity * list[i].Price).ToString("0.##"),
                    list[i].VAT,
                    0,
                    0
                });
            }
            string str_ts = RSDN.RusCurrency.Str(ts, "BYR");
            string str_vs = RSDN.RusCurrency.Str(vs, "BYR");

            // set constant document values
            //string strDate = Outgo.created_on.Value.GetDateTimeFormats('d')[3];
            DateTime date    = sale.SaleDate;
            string   strDate = date.Day.ToString();
            string   mnth    = "";

            switch (date.Month)
            {
            case 1:
                mnth = "января";
                break;

            case 2:
                mnth = "февраля";
                break;

            case 3:
                mnth = "марта";
                break;

            case 4:
                mnth = "апреля";
                break;

            case 5:
                mnth = "мая";
                break;

            case 6:
                mnth = "июня";
                break;

            case 7:
                mnth = "июля";
                break;

            case 8:
                mnth = "августа";
                break;

            case 9:
                mnth = "сентября";
                break;

            case 10:
                mnth = "октября";
                break;

            case 11:
                mnth = "ноября";
                break;

            case 12:
                mnth = "декабря";
                break;
            }
            strDate += " " + mnth + " " + date.Year + " г.";

            data.ReportDocumentValues.Add("ReportDate", strDate); // print date is now

            //data.ReportDocumentValues.Add("IncomeNumber", Income.id);
            data.ReportDocumentValues.Add("VATAmountSumStr", str_vs);
            data.ReportDocumentValues.Add("TotalSumStr", str_ts);
            data.ReportDocumentValues.Add("AmountSum", asum.ToString("0.##"));
            data.ReportDocumentValues.Add("TotalAmount", TotalAmount.ToString("0.##"));
            data.ReportDocumentValues.Add("VATAmountSum", vs.ToString("0.##"));
            data.ReportDocumentValues.Add("TotalSum", ts.ToString("0.##"));
            settings_profile profile = da.getProfileCurrent();
            string           p1      = profile.CompanyName;// +", " + profile.AddressJur;

            p1 = Regex.Replace(p1, " +", " ");
            data.ReportDocumentValues.Add("param1", p1);
            data.ReportDocumentValues.Add("param5", profile.CompanyHead);
            data.ReportDocumentValues.Add("param6", p1 = Regex.Replace(profile.UNN, " +", " "));

            data.DataTables.Add(dt);

            DateTime dateTimeStart = DateTime.Now; // start time measure here

            XpsDocument xps = reportDocument.CreateXpsDocument(data);

            documentViewer.Document = xps.GetFixedDocumentSequence();
        }
Example #20
0
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(delegate
            {
                try
                {
                    ReportDocument reportDocument = new ReportDocument();

                    StreamReader reader          = new StreamReader(new FileStream(@"Templates\BarcodeReport.xaml", FileMode.Open, FileAccess.Read));
                    reportDocument.XamlData      = reader.ReadToEnd();
                    reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                    reader.Close();

                    ReportData data = new ReportData();

                    // set constant document values
                    data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                    // sample table "Ean"
                    DataTable table = new DataTable("Ean");
                    table.Columns.Add("Position", typeof(string));
                    table.Columns.Add("Item", typeof(string));
                    table.Columns.Add("EAN", typeof(string));
                    table.Columns.Add("Count", typeof(int));
                    Random rnd = new Random(1234);
                    for (int i = 1; i <= 100; i++)
                    {
                        // randomly create some items
                        StringBuilder sb = new StringBuilder();
                        for (int j = 1; j <= 13; j++)
                        {
                            sb.Append(rnd.Next(10));
                        }
                        table.Rows.Add(new object[] { i, "Item " + i.ToString("0000"), sb.ToString(), rnd.Next(9) + 1 });
                    }
                    data.DataTables.Add(table);

                    DateTime dateTimeStart = DateTime.Now; // start time measure here

                    XpsDocument xps         = reportDocument.CreateXpsDocument(data);
                    documentViewer.Document = xps.GetFixedDocumentSequence();

                    // show the elapsed time in window title
                    Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
                }
                catch (Exception ex)
                {
                    // show exception
                    MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                finally
                {
                    busyDecorator.IsBusyIndicatorHidden = true;
                }
            }));
        }
Example #21
0
        private void Window_Activated(object sender, EventArgs e)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\SpareSalesByCodePeriodReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                DataAccess da   = new DataAccess();
                string     BCC  = da.getBasicCurrencyCode();

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("Num", typeof(int));
                dt.Columns.Add("WarehouseName", typeof(string));
                dt.Columns.Add("OutgoNum", typeof(string));
                dt.Columns.Add("AccountName", typeof(string));
                dt.Columns.Add("OutgoDate", typeof(string));
                dt.Columns.Add("Q", typeof(int));
                dt.Columns.Add("P", typeof(double));
                dt.Columns.Add("VAT", typeof(string));
                dt.Columns.Add("T", typeof(double));

                // забиваем таблицу данными
                List <SpareInSpareOutgoView> LIST2 = da.GetSpareInSpareOutgoByCodePeriod(Spare.id, dateFrom, dateTo, WarehouseID);
                decimal asum = 0;
                try
                {
                    for (int i = 0; i < LIST2.Count; i++)
                    {
                        asum += LIST2[i].total_sum;
                        string      AN      = LIST2[i].AccountName;
                        string      od      = LIST2[i].OutgoDate.Value.ToShortDateString();
                        string      on      = "нет";
                        int         OutgoID = LIST2[i].spare_outgo_id;
                        spare_outgo so      = da.SpareOutgoGet(OutgoID);
                        if (so != null)
                        {
                            on = so.IDN.ToString();
                        }
                        dt.Rows.Add(new object[] {
                            i + 1,
                            LIST2[i].WarehouseName,
                            on,
                            AN,
                            od,
                            LIST2[i].quantity,
                            LIST2[i].purchase_price,
                            LIST2[i].VatRateName,
                            LIST2[i].total_sum
                        });
                    }
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                string str_ts  = RSDN.RusCurrency.Str(asum, "BYR");
                string strDate = dateFrom.Day.ToString();
                string mnth    = "";
                switch (dateFrom.Month)
                {
                case 1:
                    mnth = "января";
                    break;

                case 2:
                    mnth = "февраля";
                    break;

                case 3:
                    mnth = "марта";
                    break;

                case 4:
                    mnth = "апреля";
                    break;

                case 5:
                    mnth = "мая";
                    break;

                case 6:
                    mnth = "июня";
                    break;

                case 7:
                    mnth = "июля";
                    break;

                case 8:
                    mnth = "августа";
                    break;

                case 9:
                    mnth = "сентября";
                    break;

                case 10:
                    mnth = "октября";
                    break;

                case 11:
                    mnth = "ноября";
                    break;

                case 12:
                    mnth = "декабря";
                    break;
                }
                strDate += " " + mnth + " " + dateFrom.Year + " г.";

                data.ReportDocumentValues.Add("ReportDate1", strDate); // print date is now

                // =======================
                strDate = dateTo.Day.ToString();
                mnth    = "";
                switch (dateTo.Month)
                {
                case 1:
                    mnth = "января";
                    break;

                case 2:
                    mnth = "февраля";
                    break;

                case 3:
                    mnth = "марта";
                    break;

                case 4:
                    mnth = "апреля";
                    break;

                case 5:
                    mnth = "мая";
                    break;

                case 6:
                    mnth = "июня";
                    break;

                case 7:
                    mnth = "июля";
                    break;

                case 8:
                    mnth = "августа";
                    break;

                case 9:
                    mnth = "сентября";
                    break;

                case 10:
                    mnth = "октября";
                    break;

                case 11:
                    mnth = "ноября";
                    break;

                case 12:
                    mnth = "декабря";
                    break;
                }
                strDate += " " + mnth + " " + dateTo.Year + " г.";
                data.ReportDocumentValues.Add("ReportDate2", strDate); // print date is now

                data.ReportDocumentValues.Add("SpareName", Spare.name);
                data.ReportDocumentValues.Add("SpareCodeShatem", Spare.codeShatem);
                data.ReportDocumentValues.Add("SpareCode", Spare.code);
                data.ReportDocumentValues.Add("asum", asum);
                data.DataTables.Add(dt);

                DateTime    dateTimeStart = DateTime.Now; // start time measure here
                XpsDocument xps           = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #22
0
        /// <summary>
        /// Window has been activated
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event details</param>
        private void Window_Activated(object sender, EventArgs e)
        {
            if (!_firstActivated)
            {
                return;
            }

            _firstActivated = false;

            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\SimpleReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                // set constant document values
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now


                //*************PRUEBAS**************
                Run Run1 = new Run("Registro Médico No. ");
                Run Run2 = new Run("Fecha" + DateTime.Today.Date);

                Label lblRegistro = new Label();
                lblRegistro.Content = "99999";

                InlineUIContainer lInlineUiContainer = new InlineUIContainer();
                lInlineUiContainer.BaselineAlignment = BaselineAlignment.Bottom;
                lInlineUiContainer.Child             = lblRegistro;

                Paragraph lParagraph = new Paragraph();
                lParagraph.Inlines.Add(Run1);
                lParagraph.Inlines.Add(lInlineUiContainer);
                lParagraph.Inlines.Add(Run2);
                //***********************************
                data.ReportDocumentValues.Add("label", lParagraph); // print date is now


                // sample table "Ean"
                DataTable table = new DataTable("Ean");
                table.Columns.Add("Position", typeof(string));
                table.Columns.Add("Item", typeof(string));
                table.Columns.Add("EAN", typeof(string));
                table.Columns.Add("Count", typeof(int));
                Random rnd = new Random(1234);
                for (int i = 1; i <= 100; i++)
                {
                    // randomly create some articles
                    table.Rows.Add(new object[] { i, "Item " + i.ToString("0000"), "123456790123", rnd.Next(9) + 1 });
                }
                data.DataTables.Add(table);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                Title += " - generated in " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #23
0
        private void Window_Activated(object sender, EventArgs e)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader   reader         = new StreamReader(new FileStream(@"Templates\RequestReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                DataAccess da   = new DataAccess();

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("t1", typeof(string));
                dt.Columns.Add("t2", typeof(string));
                dt.Columns.Add("t3", typeof(string));
                dt.Columns.Add("t4", typeof(string));
                dt.Columns.Add("t5", typeof(string));
                dt.Columns.Add("t6", typeof(string));
                dt.Columns.Add("t7", typeof(string));
                dt.Columns.Add("t8", typeof(string));

                decimal sum1 = 0;

                // забиваем таблицу данными
                if (items == null)
                {
                    items = da.GetSparesDemand();
                }
                int maxLength = 40;
                try
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        string nm = items[i].name;
                        nm = nm.Substring(0, Math.Min(nm.Length, maxLength));
                        if (items[i].name.Length > maxLength)
                        {
                            nm += "...";
                        }
                        decimal r1 = items[i].q_demand.Value;
                        decimal r2 = (decimal)items[i].QRest.Value;
                        decimal r  = (r1 - r2);
                        sum1 += r;
                        dt.Rows.Add(new object[] {
                            (i + 1).ToString(),
                            nm,
                            items[i].BrandName,
                            items[i].codeShatem,
                            items[i].code,
                            items[i].q_demand,
                            items[i].QRest,
                            r
                        });
                    }
                }
                catch (Exception exc)
                {
                    Marvin.Instance.Log(exc.Message);
                    throw exc;
                }
                string strDate = DateTime.Now.Day.ToString();
                string mnth    = "";
                switch (DateTime.Now.Month)
                {
                case 1:
                    mnth = "января";
                    break;

                case 2:
                    mnth = "февраля";
                    break;

                case 3:
                    mnth = "марта";
                    break;

                case 4:
                    mnth = "апреля";
                    break;

                case 5:
                    mnth = "мая";
                    break;

                case 6:
                    mnth = "июня";
                    break;

                case 7:
                    mnth = "июля";
                    break;

                case 8:
                    mnth = "августа";
                    break;

                case 9:
                    mnth = "сентября";
                    break;

                case 10:
                    mnth = "октября";
                    break;

                case 11:
                    mnth = "ноября";
                    break;

                case 12:
                    mnth = "декабря";
                    break;
                }
                strDate += " " + mnth + " " + DateTime.Now.Year + " г.";

                data.ReportDocumentValues.Add("p1", strDate); // print date is now
                data.ReportDocumentValues.Add("sum1", sum1);

                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                Marvin.Instance.Log(ex.Message);

                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #24
0
        public static void printDoc(string TemplateName, DataSet ReportDatatables, String ReportName, Boolean ShowPreview = false, string ReportDisc = null)
        {
            //DocumentViewer docview1,
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader   reader         = new StreamReader(new FileStream(@"Templates\" + TemplateName, FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                // Add tables to report Data

                foreach (DataTable DT in ReportDatatables.Tables)
                {
                    //if (DT.Rows.Count < 10)
                    //{
                    //    DataRow abc = null;
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //}
                    data.DataTables.Add(DT);
                }
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now
                dhAppPreference obj = new dhAppPreference();
                dsGeneral.dtAppPreferenceDataTable dt = iFacede.GetAppPreference(Globalized.ObjDbName, obj);
                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here
                data.ReportDocumentValues.Add("ReportDisc", ReportDisc);
                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                // chek have to show or not
                if (!ShowPreview)
                {
                    PrintDialog dlg = new PrintDialog();
                    dlg.PrintDocument(xps.GetFixedDocumentSequence().DocumentPaginator, ReportName);
                }
                else
                {
                    PrintPreview objPre = new PrintPreview();
                    objPre.docview1.Document = xps.GetFixedDocumentSequence();
                    Window window = new Window
                    {
                        Title   = "Print Preview",
                        Content = objPre,
                        Height  = 800, // just added to have a smaller control (Window)
                        Width   = 750
                    };

                    window.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\DailySalesReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                DataAccess da   = new DataAccess();
                string     BCC  = da.getBasicCurrencyCode();

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("Num", typeof(int));
                dt.Columns.Add("SpareName", typeof(string));
                dt.Columns.Add("WarehouseName", typeof(string));
                dt.Columns.Add("SpareCodeShatem", typeof(string));
                dt.Columns.Add("SpareCode", typeof(string));
                dt.Columns.Add("Q", typeof(int));
                dt.Columns.Add("P", typeof(double));
                dt.Columns.Add("VAT", typeof(string));
                dt.Columns.Add("T", typeof(double));
                dt.Columns.Add("SaleDate", typeof(string));

                // забиваем таблицу данными
                List <SpareInSpareOutgoView> LIST2 = warehouseID > 0 ? da.GetSpareInSpareOutgoByPeriod(date, dateTo, warehouseID) : da.GetSpareInSpareOutgoByPeriod(date, dateTo);
                decimal asum = 0;
                try
                {
                    for (int i = 0; i < LIST2.Count; i++)
                    {
                        asum += LIST2[i].total_sum;
                        dt.Rows.Add(new object[] {
                            i + 1,
                            LIST2[i].SpareName,
                            LIST2[i].WarehouseName,
                            LIST2[i].codeShatem,
                            LIST2[i].code,
                            LIST2[i].quantity,
                            LIST2[i].purchase_price,
                            LIST2[i].VatRateName,
                            LIST2[i].total_sum,
                            LIST2[i].OutgoDate.Value.ToString("dd.MM.yyyy")
                        });
                    }
                }
                catch (Exception exc)
                {
                    Marvin.Instance.Log(exc.Message);
                    throw exc;
                }
                string str_ts = RSDN.RusCurrency.Str(asum, "BYR");

                string strDate = "";
                if (date == dateTo)
                {
                    strDate = date.ToString("dd.MM.yyyy");
                }
                else
                {
                    string strDateFrom = date.ToString("dd.MM.yyyy");
                    string strDateTo   = dateTo.ToString("dd.MM.yyyy");
                    strDate = strDateFrom + " - " + strDateTo;
                }
                data.ReportDocumentValues.Add("ReportDate", strDate); // print date is now
                data.ReportDocumentValues.Add("asum", asum);
                data.DataTables.Add(dt);

                DateTime    dateTimeStart = DateTime.Now; // start time measure here
                XpsDocument xps           = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                // show exception
                Marvin.Instance.Log(ex.Message);
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            if (Outgo == null)
            {
                return;
            }
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\SpareOutgoTTNWithAppendixReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                decimal    ts   = 0;
                decimal    vs   = 0;
                decimal    asum = 0;
                DataAccess da   = new DataAccess();
                string     BCC  = da.getBasicCurrencyCode();

                //Income.currencyReference.Load();
                //string CCC = Income.currency.code;

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("mtable");

                // описываем столбцы таблицы
                dt.Columns.Add("SpareName", typeof(string));
                dt.Columns.Add("UnitName", typeof(string));
                dt.Columns.Add("Quantity", typeof(string));
                dt.Columns.Add("Price", typeof(string));
                dt.Columns.Add("Amount", typeof(string));
                dt.Columns.Add("VAT", typeof(string));
                dt.Columns.Add("VATAmount", typeof(string));
                dt.Columns.Add("Total", typeof(string));

                // забиваем таблицу данными
                List <ReportOutgo> list = new List <ReportOutgo>();
                list = da.GetReportOutgoes(SpareOutgoId);
                try
                {
                    string CompanyName = da.getProfileCurrent().CompanyName;
                    for (int i = 0; i < list.Count; i++)
                    {
                        decimal Total  = list[i].total_sum;
                        decimal VatSum = Total * list[i].VatRate.Value / 100;
                        decimal Sum    = Total - VatSum;
                        decimal Price  = Sum / list[i].quantity;

                        ts   += Total;
                        vs   += VatSum;
                        asum += Sum;

                        dt.Rows.Add(new object[] {
                            list[i].SpareName,
                            list[i].UnitName,
                            list[i].quantity.ToString("0.##"),
                            Price.ToString("0.##"),
                            Sum.ToString("0.##"),
                            list[i].VatName,
                            VatSum.ToString("0.##"),
                            Total.ToString("0.##")
                        });
                    }
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                string str_ts = RSDN.RusCurrency.Str(ts, "BYR");
                string str_vs = RSDN.RusCurrency.Str(vs, "BYR");

                // set constant document values
                //string strDate = Outgo.created_on.Value.GetDateTimeFormats('d')[3];
                string strDate = Outgo.created_on.Value.Day.ToString();
                string mnth    = "";
                switch (Outgo.created_on.Value.Month)
                {
                case 1:
                    mnth = "января";
                    break;

                case 2:
                    mnth = "февраля";
                    break;

                case 3:
                    mnth = "марта";
                    break;

                case 4:
                    mnth = "апреля";
                    break;

                case 5:
                    mnth = "мая";
                    break;

                case 6:
                    mnth = "июня";
                    break;

                case 7:
                    mnth = "июля";
                    break;

                case 8:
                    mnth = "августа";
                    break;

                case 9:
                    mnth = "сентября";
                    break;

                case 10:
                    mnth = "октября";
                    break;

                case 11:
                    mnth = "ноября";
                    break;

                case 12:
                    mnth = "декабря";
                    break;
                }
                strDate += " " + mnth + " " + Outgo.created_on.Value.Year + " г.";

                data.ReportDocumentValues.Add("ReportDate", strDate); // print date is now

                //data.ReportDocumentValues.Add("IncomeNumber", Income.id);
                data.ReportDocumentValues.Add("VATAmountSumStr", str_vs);
                data.ReportDocumentValues.Add("TotalSumStr", str_ts);
                data.ReportDocumentValues.Add("AmountSum", asum.ToString("0.##"));
                data.ReportDocumentValues.Add("VATAmountSum", vs.ToString("0.##"));
                data.ReportDocumentValues.Add("TotalSum", ts.ToString("0.##"));
                data.ReportDocumentValues.Add("accepter", Outgo.accepter);
                data.ReportDocumentValues.Add("address", Outgo.address);
                SpareOutgoView sov = da.GetSpareOutgoView(Outgo.id);
                data.ReportDocumentValues.Add("customer", sov.AccountName);
                data.ReportDocumentValues.Add("deliverer", Outgo.deliverer);
                data.ReportDocumentValues.Add("driver", Outgo.driver);
                data.ReportDocumentValues.Add("trailer", Outgo.trailer);
                data.ReportDocumentValues.Add("tripsheet", Outgo.tripsheet);
                data.ReportDocumentValues.Add("truck", Outgo.truck);
                data.ReportDocumentValues.Add("truckowner", Outgo.truckowner);
                Outgo.currencyReference.Load();
                data.ReportDocumentValues.Add("CurrencyName", Outgo.currency.name);
                settings_profile profile = da.getProfileCurrent();
                string           p1      = profile.CompanyName + ", " + profile.AddressJur;
                p1 = Regex.Replace(p1, " +", " ");
                data.ReportDocumentValues.Add("param1", p1);
                string param2a = sov.AccountName + ", " + Outgo.address;
                data.ReportDocumentValues.Add("param2a", param2a);
                data.ReportDocumentValues.Add("param2", Outgo.unloading);
                data.ReportDocumentValues.Add("param3", Outgo.basement);
                data.ReportDocumentValues.Add("param4", Outgo.description);
                data.ReportDocumentValues.Add("param5", profile.CompanyHead);
                data.ReportDocumentValues.Add("param6", p1 = Regex.Replace(profile.UNN, " +", " "));
                data.ReportDocumentValues.Add("param7", Outgo.unn);
                string par21 = sov.AccountName + ", " + Outgo.address;
                data.ReportDocumentValues.Add("param2_1", par21);
                data.ReportDocumentValues.Add("param2_2", Outgo.unloading);
                data.ReportDocumentValues.Add("param2_3", Outgo.description);
                data.ReportDocumentValues.Add("param2_4", profile.LoadPoint);
                data.ReportDocumentValues.Add("warrant", Outgo.warrant);
                data.ReportDocumentValues.Add("Num", Outgo.IDN);
                string p1a = Outgo.deliverer;
                data.ReportDocumentValues.Add("param1a", p1a);

                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #27
0
        private void Window_Activated(object sender, EventArgs e)
        {
            if (Income == null)
            {
                return;
            }
            try
            {
                ReportDocument reportDocument = new ReportDocument();

                StreamReader reader = new StreamReader(new FileStream(@"Templates\OfferingMovementReport.xaml", FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();

                // set constant document values
                data.ReportDocumentValues.Add("IncomeDate", Income.si_date.GetDateTimeFormats('d')[3]); // print date is now
                data.ReportDocumentValues.Add("IncomeNumber", Income.num);

                decimal    ts  = 0;
                decimal    _S  = 0;
                decimal    _MS = 0;
                decimal    _VS = 0;
                DataAccess da  = new DataAccess();
                string     BCC = da.getBasicCurrencyCode();
                Income.currencyReference.Load();
                string CCC = Income.currency.code;

                // Таблица ТОВАРЫ В НАКЛАДНОЙ
                DataTable dt = new DataTable("OfferingsInMovement");

                // описываем столбцы таблицы
                dt.Columns.Add("Number", typeof(int));
                dt.Columns.Add("SpareName", typeof(string));
                dt.Columns.Add("SpareCodeShatem", typeof(string));
                dt.Columns.Add("SpareCode", typeof(string));
                dt.Columns.Add("UnitName", typeof(string));
                dt.Columns.Add("Quantity", typeof(string));
                dt.Columns.Add("Price", typeof(string));
                dt.Columns.Add("Markup", typeof(string));
                dt.Columns.Add("VAT", typeof(string));
                dt.Columns.Add("Sum", typeof(string));
                dt.Columns.Add("MarkupBasic", typeof(string));
                dt.Columns.Add("VATBasic", typeof(string));
                dt.Columns.Add("PriceOut", typeof(string));
                dt.Columns.Add("Amount", typeof(string));

                // забиваем таблицу данными
                List <ReportIncome> list = new List <ReportIncome>();
                list = da.GetReportIncomes(SpareIncomeID);
                try
                {
                    string CompanyName = da.getProfileCurrent().CompanyName;
                    for (int i = 0; i < list.Count; i++)
                    {
                        decimal Q        = list[i].QIn;
                        decimal P        = list[i].PIn.Value;
                        decimal S        = P * Q;
                        decimal M        = list[i].Markup;
                        decimal V        = list[i].VatRate;
                        decimal T        = list[i].S.Value;
                        decimal MS       = S * M / 100;
                        decimal VS       = S * V / 100;
                        decimal PriceOut = T / Q;

                        _MS += MS;
                        _VS += VS;
                        _S  += S;
                        ts  += T;

                        dt.Rows.Add(
                            new object[] {
                            i + 1,
                            list[i].SpareName,
                            list[i].codeShatem,
                            list[i].code,
                            list[i].UnitName,
                            Q.ToString("0.##"),
                            P.ToString("0.##"),
                            M.ToString("0.##"),
                            V.ToString("0.##"),
                            S.ToString("0.##"),
                            MS.ToString("0.##"),
                            VS.ToString("0.##"),
                            PriceOut.ToString("0.##"),
                            T.ToString("0.##")
                        });
                    }
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                string sts = RSDN.RusCurrency.Str(ts, CCC);
                data.ReportDocumentValues.Add("StringSum", sts);
                settings_profile profile = da.getProfileCurrent();
                data.ReportDocumentValues.Add("TS", _S.ToString("0.##"));
                data.ReportDocumentValues.Add("TMS", _MS.ToString("0.##"));
                data.ReportDocumentValues.Add("TVS", _VS.ToString("0.##"));
                data.ReportDocumentValues.Add("TTS", ts.ToString("0.##"));
                data.ReportDocumentValues.Add("param1", profile.CompanyHead);
                data.ReportDocumentValues.Add("param2", profile.CompanyName);
                if (Income.base_doc_date.HasValue)
                {
                    data.ReportDocumentValues.Add("BaseDocDate", Income.base_doc_date.Value.GetDateTimeFormats('d')[3]);
                }
                data.ReportDocumentValues.Add("BaseDoc", Income.base_doc);
                string AccName = "";
                if (Income.account == null)
                {
                    Income.accountReference.Load();
                }
                if (Income.account != null)
                {
                    AccName = Income.account.name;
                }
                data.ReportDocumentValues.Add("AccountName", AccName);
                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here

                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                documentViewer.Document = xps.GetFixedDocumentSequence();

                // show the elapsed time in window title
                //Title += " - создано за " + (DateTime.Now - dateTimeStart).TotalMilliseconds + " миллисекунд";
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }