Ejemplo n.º 1
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

                String appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

                var reader =
                    new StreamReader(new FileStream(appStartPath + @"\LPReport\ReportTemplate\StandardTemplate.xaml", FileMode.Open,
                                                    FileAccess.Read));
                reportDocument.XamlData = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory,appStartPath + @"\LPReport\ReportTemplate");
                reader.Close();

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                List<LPConstraint> constraint = _model.GetConstraint;
                string strConstraints = constraint.Aggregate("",
                                                             (current, variable) =>
                                                             current +
                                                             String.Format("{0}{1}", variable.ToString(),
                                                                           Environment.NewLine));

                data.ReportDocumentValues.Add("ModelGoal", _model.GoalKind.ToString() + " : " + _model.Objective);
                // print date is now
                data.ReportDocumentValues.Add("ModelConstraints", strConstraints); // print date is now

                IModelSolver solver = new MicrosoftSolverFoundation(_model);
                solver.TrySolve();

                string result = solver.GetResult();

                result = result.Substring(result.IndexOf("===Solution Details===", System.StringComparison.Ordinal));

                data.ReportDocumentValues.Add("ReportSec", result);

                //TABLE Goes Here

                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 += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception)
            {
            }
        }
        /// <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);
            }
        }
        /// <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();
                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);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Previews the report.
        /// </summary>
        /// <param name="reportDocument">The report document.</param>
        /// <param name="data">The data.</param>
        public void PreviewReport(ReportDocument reportDocument, ReportData data, Action <int, int> PageGeneratedCallBack = null)
        {
            XpsDocument xps = reportDocument.CreateXpsDocument(data, PageGeneratedCallBack);

            DocumentViewer.Document = xps.GetFixedDocumentSequence();
        }
Ejemplo n.º 5
0
        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);
            }
        }
        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);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Previews the report.
 /// </summary>
 /// <param name="reportDocument">The report document.</param>
 /// <param name="data">The data.</param>
 public void PreviewReport(ReportDocument reportDocument, IEnumerable <ReportData> data)
 {
     XpsDocument xps = reportDocument.CreateXpsDocument(data);
     //DocumentViewer.Document = xps.GetFixedDocumentSequence();
 }
        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);
            }
        }
Ejemplo n.º 9
0
        private void Window_Activated(object sender, EventArgs e)
        {
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader reader = new StreamReader(new FileStream(@"Templates\RevisionReport.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("t4", typeof(string));
                dt.Columns.Add("t5", typeof(string));
                dt.Columns.Add("t6", typeof(string));
                dt.Columns.Add("t7", typeof(string));

                // забиваем таблицу данными
                if (items == null)
                {
                    items = da.GetSpares();
                }
                try
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        dt.Rows.Add(new object[] {
                                    (i+1).ToString(),
                                    items[i].name,
                                    items[i].code,
                                    items[i].codeShatem,
                                    items[i].QRest,
                                    items[i].q_rest
                                });
                    }
                }
                catch (Exception exc)
                {
                    Marvin.Instance.Log(exc.Message);
                    throw exc;
                }
                string strDate = d.Day.ToString();
                string mnth = "";
                switch (d.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 + " " + d.Year + " г.";

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

                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);
            }
        }
Ejemplo n.º 10
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

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

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                int numbOfCars = _data.Count - 1;
                int passengers = _data.Sum(carDetailsRow => carDetailsRow.GetPassengers);
                int casualties = _accidentdata.Sum(i => _data[i].GetPassengers);

                string reportSum = string.Format(
                    "There were {0} cars in the road with total of {1} Passengers.\nUnfortunately there were {2} accidents in the road with {3} casualties",
                    numbOfCars, passengers, _accidentdata.Count - 1, casualties) + Environment.NewLine;

                string accident = "";

                foreach (int i in _accidentdata)
                {
                    accident +=
                        string.Format("Car : [{0}] - Passengers : {1}", _data[i].CarName, _data[i].GetPassengers) +
                        Environment.NewLine;
                }

                data.ReportDocumentValues.Add("ReportSummary", reportSum);
                data.ReportDocumentValues.Add("Accidents", accident);

                //TABLE Goes Here

                var table = new DataTable("HighwayTable");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("carModel", typeof (string));
                table.Columns.Add("tripStartTime", typeof (string));
                table.Columns.Add("tripDuration", typeof (string));
                table.Columns.Add("tripEndTime", typeof (string));
                table.Columns.Add("tripStatus", typeof (string));
                table.Columns.Add("carCapacity", typeof (string));

                int counter = 1;

                foreach (CarDetailsRow element in _data)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                                       {
                                           counter, element.CarName, element.TripStartTime.ToString("T"),
                                           element.TripDuration + " Min",
                                           element.TripEndTime.ToString("T"), element.TripStatus,
                                           Helper.CarCapacity(element.CarType).ToString(CultureInfo.InvariantCulture)
                                       });
                    counter++;
                }
                table.Rows.Add(new object[] {"Total", "---", "---", "---", "---", "---", "---"});

                data.DataTables.Add(table);

                // Chart - Car by Capacity

                int totalC1 = 0;
                int totalC2 = 0;
                int totalC3 = 0;
                int totalC4 = 0;
                int totalC40 = 0;

                foreach (CarDetailsRow detailsRow in _data)
                {
                    if (detailsRow.CarType == CarType.C1)
                        totalC1++;
                    else if (detailsRow.CarType == CarType.C2)
                        totalC2++;
                    else if (detailsRow.CarType == CarType.C3)
                        totalC3++;

                    else if (detailsRow.CarType == CarType.C4)
                        totalC4++;

                    else if (detailsRow.CarType == CarType.C40)
                        totalC40++;
                }

                var mtable = new DataTable("CarsChart");
                mtable.Columns.Add("Number of Cars", typeof (string));
                mtable.Columns.Add("Passengers", typeof (int));
                mtable.Rows.Add(new object[] {"1 Passenger", totalC1});
                mtable.Rows.Add(new object[] {"2 Passengers", totalC2});
                mtable.Rows.Add(new object[] {"3 Passengers", totalC3});
                mtable.Rows.Add(new object[] {"4 Passengers", totalC4});
                mtable.Rows.Add(new object[] {"40 Passengers", totalC40});
                data.DataTables.Add(mtable);

                //

                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 += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception exp)
            {
            }
        }
        /// <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);
            }
        }
 /// <summary>
 /// Previews the report.
 /// </summary>
 /// <param name="reportDocument">The report document.</param>
 /// <param name="data">The data.</param>
 public void PreviewReport(ReportDocument reportDocument, IEnumerable<ReportData> data)
 {
     XpsDocument xps = reportDocument.CreateXpsDocument(data);
     //DocumentViewer.Document = xps.GetFixedDocumentSequence();
 }
        /// <summary>
        /// Previews the report.
        /// </summary>
        /// <param name="reportDocument">The report document.</param>
        /// <param name="data">The data.</param>
        public void PreviewReport(ReportDocument reportDocument, ReportData data, Action<int,int> PageGeneratedCallBack = null)
        {
            XpsDocument xps = reportDocument.CreateXpsDocument(data, PageGeneratedCallBack);
            DocumentViewer.Document = xps.GetFixedDocumentSequence();

        }
        /// <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;
                }
            }));
        }
Ejemplo n.º 15
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

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

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                var table = new DataTable("CustomersTable");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("ArrivalTime", typeof (string));
                table.Columns.Add("rArrivalNumber", typeof (string));
                table.Columns.Add("ServiceTime", typeof (string));
                table.Columns.Add("WaitTime", typeof (string));
                table.Columns.Add("ServiceProvider", typeof (string));
                table.Columns.Add("DepartureTime", typeof (string));
                table.Columns.Add("AState", typeof (string));
                table.Columns.Add("DState", typeof (string));
                int counter = 1;
                foreach (ICustomer element in _customerData)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                                       {
                                           counter, element.ArrivalTime, element.ArrivalTimeNumber, element.ServiceTime,
                                           element.WaitTime,
                                           element.ServiceProvider.ToString(), element.DepartureTime,
                                           element.OnArrivalSystemState.ToString(), element.AfterDepartureState
                                       });
                    counter++;
                }
                table.Rows.Add(new object[] {"Total", "---", "---", "---", "---", "---"});

                data.DataTables.Add(table);

                table = new DataTable("CustomersTableNL");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("FirstName", typeof (string));
                table.Columns.Add("LastName", typeof (string));
                table.Columns.Add("ArrivalTime", typeof (string));
                table.Columns.Add("ServiceTime", typeof (string));
                table.Columns.Add("WaitTime", typeof (string));
                table.Columns.Add("DepartureTime", typeof (string));
                table.Columns.Add("ServiceProvider", typeof (string));
                counter = 1;
                foreach (ICustomer element in _customerData)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                                       {
                                           counter, element.FirstName, element.LastName, element.ArrivalTime,
                                           element.ServiceTime,
                                           element.WaitTime, element.DepartureTime,
                                           element.ServiceProvider.ToString()
                                       });
                    counter++;
                }
                table.Rows.Add(new object[] {"Total", "---", "---", "---", "---", "---"});

                data.DataTables.Add(table);

                table = new DataTable("CarhopsTable");
                table.Columns.Add("objective", typeof (string));
                table.Columns.Add("able", typeof (string));
                table.Columns.Add("baker", typeof (string));
                table.Columns.Add("charlie", typeof (string));

                table.Rows.Add(new object[] {"---", "---", "---", "---"});

                table.Rows.Add(new object[]
                                   {
                                       "Total Number of Customers",
                                       _carhopses[0].TotalNumberOfCustomer,
                                       _carhopses[1].TotalNumberOfCustomer,
                                       _carhopses[2].TotalNumberOfCustomer
                                   });

                table.Rows.Add(new object[]
                                   {
                                       "Total Minutes of Work",
                                       _carhopses[0].UtilizationTime,
                                       _carhopses[1].UtilizationTime,
                                       _carhopses[2].UtilizationTime
                                   });

                data.DataTables.Add(table);
                //Drawing Charts

                var mtable = new DataTable("CUtilizationTableP");
                mtable.Columns.Add("Carhop", typeof (string));
                mtable.Columns.Add("Utilization Time", typeof (int));
                mtable.Rows.Add(new object[] {_carhopses[0].ToString(), _carhopses[0].UtilizationTime});
                mtable.Rows.Add(new object[] {_carhopses[1].ToString(), _carhopses[1].UtilizationTime});
                mtable.Rows.Add(new object[] {_carhopses[2].ToString(), _carhopses[2].UtilizationTime});
                data.DataTables.Add(mtable);

                mtable = new DataTable("CUtilizationTable");
                mtable.Columns.Add("Carhop", typeof (string));
                mtable.Columns.Add("Utilization Time", typeof (int));
                mtable.Rows.Add(new object[] {_carhopses[0].ToString(), _carhopses[0].UtilizationTime});
                mtable.Rows.Add(new object[] {_carhopses[1].ToString(), _carhopses[1].UtilizationTime});
                mtable.Rows.Add(new object[] {_carhopses[2].ToString(), _carhopses[2].UtilizationTime});
                data.DataTables.Add(mtable);

                mtable = new DataTable("CUtilizationCNTable");
                mtable.Columns.Add("Carhop", typeof (string));
                mtable.Columns.Add("Total Number of Customers", typeof (int));
                mtable.Rows.Add(new object[] {_carhopses[0].ToString(), _carhopses[0].TotalNumberOfCustomer});
                mtable.Rows.Add(new object[] {_carhopses[1].ToString(), _carhopses[1].TotalNumberOfCustomer});
                mtable.Rows.Add(new object[] {_carhopses[2].ToString(), _carhopses[2].TotalNumberOfCustomer});
                data.DataTables.Add(mtable);

                mtable = new DataTable("CUtilizationCNTableP");
                mtable.Columns.Add("Carhop", typeof (string));
                mtable.Columns.Add("Total Number of Customers", typeof (int));
                mtable.Rows.Add(new object[] {_carhopses[0].ToString(), _carhopses[0].TotalNumberOfCustomer});
                mtable.Rows.Add(new object[] {_carhopses[1].ToString(), _carhopses[1].TotalNumberOfCustomer});
                mtable.Rows.Add(new object[] {_carhopses[2].ToString(), _carhopses[2].TotalNumberOfCustomer});
                data.DataTables.Add(mtable);

                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 += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(string.Format("{0}\r\n\r\n{1}\r\n{2}", ex.Message, ex.GetType(), 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);
            }
        }
Ejemplo n.º 17
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

                var reader = new StreamReader(new FileStream(@"Templates\ReportTemplate.xaml", FileMode.Open,
                                                             FileAccess.Read));
                reportDocument.XamlData = reader.ReadToEnd();

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

                var data = new ReportData();

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

                data.ReportDocumentValues.Add("ReportSummary", _reportList.GetReportSummery);

                var table = new DataTable("Table1");
                table.Columns.Add("c1", typeof (string));
                table.Columns.Add("c2", typeof (string));
                table.Columns.Add("c3", typeof (string));

                table.Rows.Add(new object[]
                                   {
                                       _reportList.GetInformation,
                                       _reportList.GetLength.ToString(CultureInfo.InvariantCulture),
                                       _reportList.InnerData.ConvertToString()
                                   });

                data.DataTables.Add(table);

                // CHI TEST
                List<Tuple<int, float, int, float>> testTable = UniformityTests.ChiSquare(10, _reportList);

                table = new DataTable("Table2");
                table.Columns.Add("c1", typeof (string));
                table.Columns.Add("c2", typeof (string));
                table.Columns.Add("c3", typeof (string));
                table.Columns.Add("c4", typeof (string));
                float sum = 0f;
                foreach (var tuple in testTable)
                {
                    table.Rows.Add(new object[]
                                       {
                                           tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4
                                       });
                    sum += tuple.Item4;
                }

                table.Rows.Add(new object[] {"Total", "--", "--", sum.ToString(CultureInfo.InvariantCulture)});

                data.DataTables.Add(table);
                string result = UniformityTests.IsUniformWithChiSquare(testTable)
                                    ? "There isn't enough evidence to reject the hypothesis!"
                                    : "The hypothesis is rejected!";
                data.ReportDocumentValues.Add("ChiSquareResult", String.Format("Chi-Square Test Result : {0}", result));

                //END CHI TEST

                // KS TEST

                List<Tuple<int, float, float, float, float, float>> kStestTable = UniformityTests.KSTest(_reportList);

                table = new DataTable("Table3");
                table.Columns.Add("c1", typeof (string));
                table.Columns.Add("c2", typeof (string));
                table.Columns.Add("c3", typeof (string));
                table.Columns.Add("c4", typeof (string));
                table.Columns.Add("c5", typeof (string));
                table.Columns.Add("c6", typeof (string));
                float maxDPlus = 0f;
                float maxDNegetive = 0f;
                foreach (var tuple in kStestTable)
                {
                    if (tuple.Item5 > maxDPlus)
                        maxDPlus = tuple.Item5;
                    if (tuple.Item6 > maxDNegetive)
                        maxDNegetive = tuple.Item6;
                    table.Rows.Add(new object[]
                                       {
                                           tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4,
                                           tuple.Item5, tuple.Item6
                                       });
                }

                table.Rows.Add(new object[] {"Max", "--", "--", "--", maxDPlus, maxDNegetive});

                data.DataTables.Add(table);

                result = UniformityTests.IsUniformWithKS(kStestTable)
                             ? "There isn't enough evidence to reject the hypothesis!"
                             : "The hypothesis is rejected!";
                data.ReportDocumentValues.Add("KSResult",
                                              String.Format("KS Test Result : Max[D+,D-] = {0}\n{1}",
                                                            Math.Max(maxDPlus, maxDNegetive), result));

                //END TEST

                // POKER

                List<Tuple<int, int, int, float>> pokertestTable = IndependentTest.PokerTest(_reportList);

                table = new DataTable("Table4");
                table.Columns.Add("c1", typeof (string));
                table.Columns.Add("c2", typeof (string));
                table.Columns.Add("c3", typeof (string));
                table.Columns.Add("c4", typeof (string));

                int sumA = 0;
                int sumB = 0;
                float sumC = 0;
                foreach (var tuple in pokertestTable)
                {
                    sumA += tuple.Item2;
                    sumB += tuple.Item3;
                    sumC += tuple.Item4;

                    table.Rows.Add(new object[]
                                       {
                                           tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4
                                       });
                }

                table.Rows.Add(new object[] {"Total", sumA, sumB, sumC});

                data.DataTables.Add(table);

                //END POKER
                var mtable = new DataTable("Chart1");
                mtable.Columns.Add("Multiplier", typeof (string));
                mtable.Columns.Add("Length of Sequence", typeof (int));
                foreach (var item in _analysisOverMultiplier)
                {
                    mtable.Rows.Add(new object[] {item.Item1, item.Item2});
                }

                data.DataTables.Add(mtable);

                mtable = new DataTable("Chart2");
                mtable.Columns.Add("Increment", typeof (string));
                mtable.Columns.Add("Length of Sequence", typeof (int));
                foreach (var item in _analysisOverIncrement)
                {
                    mtable.Rows.Add(new object[] {item.Item1, item.Item2});
                }

                data.DataTables.Add(mtable);

                mtable = new DataTable("Chart3");
                mtable.Columns.Add("Seed", typeof (string));
                mtable.Columns.Add("Length of Sequence", typeof (int));
                foreach (var item in _analysisOverSeed)
                {
                    mtable.Rows.Add(new object[] {item.Item1, item.Item2});
                }

                data.DataTables.Add(mtable);

                DateTime dateTimeStart = DateTime.Now;

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

                Title += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}\r\n\r\n{1}\r\n{2}", ex.Message, ex.GetType(), 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\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);
            }
        }
Ejemplo n.º 19
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

                String appStartPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

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

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                //TABLE Goes Here

                var table = new DataTable("TableZero");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("sDate", typeof (string));
                table.Columns.Add("eDate", typeof (string));
                table.Columns.Add("simulDuration", typeof (string));
                table.Columns.Add("totalBoxes", typeof (string));
                table.Columns.Add("avrageBoxTime", typeof (string));

                int counter = 1;

                var totalAverage = new TimeSpan(0);
                int totalBoxes = 0;

                foreach (SimulationResult element in _data)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                        {
                            counter, element.SimulationStartDate.ToString(CultureInfo.InvariantCulture),
                            element.LastBoxDeparture.ToString(CultureInfo.InvariantCulture),
                            (element.LastBoxDeparture - element.SimulationStartDate).ToString(),
                            element.BoxResult.Count.ToString(CultureInfo.InvariantCulture),
                            Math.Round(element.GetAverageBoxInSystemTime.TotalMinutes) + " - Minutes"
                        });
                    counter++;
                    totalAverage += element.GetAverageBoxInSystemTime;
                    totalBoxes += element.BoxResult.Count;
                }
                table.Rows.Add(new object[]
                    {
                        "Total", "---", "---", "---", totalBoxes.ToString(),
                        Math.Round(totalAverage.TotalMinutes/_data.Count) + " - Minutes Per Box"
                    });

                data.DataTables.Add(table);

                // Table 1

                table = new DataTable("TableOne");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("ATotalService", typeof (string));
                table.Columns.Add("BTotalService", typeof (string));
                table.Columns.Add("CTotalService", typeof (string));
                table.Columns.Add("InspectorTotalService", typeof (string));
                table.Columns.Add("TotalServiceTime", typeof (string));

                counter = 1;

                var averageA = new TimeSpan(0);
                var averageB = new TimeSpan(0);
                var averageC = new TimeSpan(0);
                var averageInspector = new TimeSpan(0);
                var averagetotal = new TimeSpan(0);

                var totalServiceEachRun = new List<TimeSpan>();

                foreach (SimulationResult element in _data)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                        {
                            counter, element.StationATotalService, element.StationBTotalService,
                            element.StationCTotalService,
                            element.Inspector1TotalService + element.Inspector2TotalService,
                            element.TotalService
                        });
                    counter++;
                    averageA += element.StationATotalService;
                    averageB += element.StationBTotalService;
                    averageC += element.StationCTotalService;
                    averageInspector += element.Inspector1TotalService + element.Inspector2TotalService;
                    averagetotal += element.TotalService;

                    totalServiceEachRun.Add(element.TotalService);
                }
                table.Rows.Add(new object[]
                    {
                        "Average", Math.Round(averageA.TotalMinutes/_data.Count) + " - Minutes",
                        Math.Round(averageB.TotalMinutes/_data.Count) + " - Minutes",
                        Math.Round(averageC.TotalMinutes/_data.Count) + " - Minutes",
                        Math.Round(averageInspector.TotalMinutes/_data.Count) + " - Minutes",
                        TimeSpan.FromMinutes(Math.Round(averagetotal.TotalMinutes/_data.Count))
                    });

                data.DataTables.Add(table);

                // Table 2

                table = new DataTable("TableTwo");
                table.Columns.Add("NoRunBox", typeof (string));
                table.Columns.Add("ArDate", typeof (string));
                table.Columns.Add("DeDate", typeof (string));
                table.Columns.Add("SSSA", typeof (string));
                table.Columns.Add("SESA", typeof (string));
                table.Columns.Add("SSSB", typeof (string));
                table.Columns.Add("SESB", typeof (string));
                table.Columns.Add("SSSC", typeof (string));
                table.Columns.Add("SESC", typeof (string));
                table.Columns.Add("TotalServiceTime", typeof (string));

                counter = 1;

                foreach (SimulationResult element in _data)
                {
                    int boxCounter = 1;
                    foreach (Box box in element.BoxResult)
                    {
                        table.Rows.Add(new object[]
                            {
                                counter + "." + boxCounter,
                                box.ArrivalTime.TimeOfDay.ToString(),
                                box.DepartureTime.TimeOfDay.ToString(),
                                box.StationAServiceStartTime.TimeOfDay.ToString(),
                                box.StationAServiceEndTime.TimeOfDay.ToString(),
                                box.StationBServiceStartTime.TimeOfDay.ToString(),
                                box.StationBServiceEndTime.TimeOfDay.ToString(),
                                box.StationCServiceStartTime.TimeOfDay.ToString(),
                                box.StationCServiceEndTime.TimeOfDay.ToString(),
                                box.GetTotalServiceTime(true).ToString()
                            });

                        boxCounter++;
                    }

                    if (counter != 10)
                    {
                        table.Rows.Add(new object[]
                            {
                                "--", "--", "--", "--", "--", "--", "--", "--", "--", "--"
                            });
                        table.Rows.Add(new object[]
                            {
                                "", ">>", "", "R", "U", "N", "", (counter + 1).ToString()
                            });
                        table.Rows.Add(new object[]
                            {
                                "--", "--", "--", "--", "--", "--", "--", "--", "--", "--"
                            });
                    }

                    counter++;
                }

                data.DataTables.Add(table);

                // CHART One
                var chartTable = new DataTable("ChartOne");
                chartTable.Columns.Add("Run", typeof (string));
                chartTable.Columns.Add("TotalBoxes", typeof (int));

                counter = 1;
                foreach (SimulationResult element in _data)
                {
                    chartTable.Rows.Add(new object[] {counter, element.BoxResult.Count});
                    counter++;
                }

                data.DataTables.Add(chartTable);

                // CHART Two
                chartTable = new DataTable("ChartTwo");
                chartTable.Columns.Add("Run", typeof (string));
                chartTable.Columns.Add("AverageServicetime", typeof (double));

                counter = 1;
                foreach (TimeSpan element in totalServiceEachRun)
                {
                    chartTable.Rows.Add(new object[] {counter, element.TotalMinutes});
                    counter++;
                }

                data.DataTables.Add(chartTable);

                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 += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception exp)
            {
                Debug.WriteLine(exp.Message);
            }
        }
Ejemplo n.º 20
0
        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);
            }
        }
Ejemplo n.º 21
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\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);
            }
        }
Ejemplo n.º 22
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            //Sort Data!
            _data.Sort();

            try
            {
                var reportDocument = new ReportDocument();

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

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                //TABLE Goes Here

                var table = new DataTable("BoxesTable");
                table.Columns.Add("no", typeof (string));
                table.Columns.Add("Arrive", typeof (string));
                table.Columns.Add("ServiceStart", typeof (string));
                table.Columns.Add("ServiceDuration", typeof (string));
                table.Columns.Add("WaitingTime", typeof (string));
                table.Columns.Add("Priority", typeof (string));
                table.Columns.Add("Departure", typeof (string));

                int counter = 1;
                var totalServices = new TimeSpan();

                foreach (BoxItem element in _data.BoxItems)
                {
                    // Add Element To the Table
                    table.Rows.Add(new object[]
                                       {
                                           counter, element.ArrivalDate.ToString("T"),
                                           element.ServiceStartDate.ToString("T"),
                                           element.TotalServiceTime,
                                           element.InQueuetime.TotalMinutes.ToString() + " Min",
                                           element.Priority,
                                           element.DepartureTime.ToString("T")
                                       });
                    counter++;
                    totalServices = totalServices.Add(element.TotalServiceTime);
                }
                table.Rows.Add(new object[]
                                   {
                                       "Total", "---", "---", totalServices.TotalHours.ToString() + " Hours", "---",
                                       "---",
                                       "---"
                                   });

                data.DataTables.Add(table);

                // CHART
                var mtable = new DataTable("QueueStateTable");
                mtable.Columns.Add("DateTime", typeof (string));
                mtable.Columns.Add("InQueueBoxes", typeof (int));

                foreach (QueueState item in _data.QueueStates)
                {
                    mtable.Rows.Add(new object[] {item.Time.ToString("T"), item.InQueues.Count});
                }

                data.DataTables.Add(mtable);

                mtable = new DataTable("AwaitingChart");
                mtable.Columns.Add("Box in Queue", typeof (string));
                mtable.Columns.Add("Total Minutes", typeof (int));

                mtable.Rows.Add(new object[] {"More than 1 Box", _data.AwaitingBoxMoreThan1.TotalMinutes.ToString()});
                mtable.Rows.Add(new object[] {"More than 2 Boxes", _data.AwaitingBoxMoreThan2.TotalMinutes.ToString()});

                double p1 = (float) _data.AwaitingBoxMoreThan1.TotalMinutes/totalServices.TotalMinutes;
                double p2 = (float) _data.AwaitingBoxMoreThan2.TotalMinutes/totalServices.TotalMinutes;

                string strReportSum =
                    string.Format(
                        "Total Simulation time : {0}\nTotal time; More than 1 Box in queue {1} - % {2}\nTotal time; More than 2 Boxes in queue {3} - % {4}.",
                        TimeSpanInWords(totalServices), _data.AwaitingBoxMoreThan1.ToString("T"), p1,
                        _data.AwaitingBoxMoreThan2.ToString(),
                        p2);

                strReportSum += Environment.NewLine;

                data.ReportDocumentValues.Add("AwaitingChartReportSummary", strReportSum); // print date is now

                data.DataTables.Add(mtable);

                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 += string.Format(" - Generated in {0}ms", (DateTime.Now - dateTimeStart).TotalMilliseconds);
            }
            catch (Exception exp)
            {
            }
        }
Ejemplo n.º 23
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(@"..\..\..\..\..\..\Projects\FireMonitor\Modules\SKDModule\Reports\T13.xaml", FileMode.Open, FileAccess.Read));
				StreamReader reader = new StreamReader(new FileStream(@"..\..\Templates\Test.xaml", FileMode.Open, FileAccess.Read));
				reportDocument.XamlData = reader.ReadToEnd();
				reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
				reader.Close();

				var table = new DataTable();
				using (var sr = new StringReader(tableData))
					table.ReadXml(sr);

				//const int RecordOnPage = 3;
				//var data = new List<ReportData>();
				//ReportData reportData = null;
				//int countOnPage = RecordOnPage;
				//for (int i = 0; i < table.Rows.Count; i++)
				//{
				//    if (reportData == null)
				//    {
				//        reportData = new ReportData();
				//        SetDocumentValues(reportData);
				//        reportData.DataTables.Add(table.Clone());
				//        if (data.Count == 0)
				//        {
				//            reportData.Groups.Add("Header");
				//            countOnPage = RecordOnPage - 1;
				//        }
				//        else if (i + RecordOnPage == table.Rows.Count)
				//            countOnPage = RecordOnPage - 1;
				//        else if (i + RecordOnPage > table.Rows.Count)
				//            reportData.Groups.Add("Footer");
				//        else
				//            countOnPage = RecordOnPage;
				//        data.Add(reportData);
				//    }
				//    reportData.DataTables[0].Rows.Add(table.Rows[i].ItemArray);
				//    if (reportData.DataTables[0].Rows.Count == countOnPage)
				//        reportData = null;
				//}
				ReportData data = new ReportData();
				data.Groups.Add("Header");
				data.Groups.Add("Footer");
				SetDocumentValues(data);
				data.DataTables.Add(table);

				DateTime dateTimeStart = DateTime.Now; // start time measure here
				XpsDocument xps = reportDocument.CreateXpsDocument(data);
				Title += " - xps " + (DateTime.Now - dateTimeStart).TotalMilliseconds + "ms";
				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);
			}
		}
Ejemplo n.º 24
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();
        }
              /// <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);
            }


        }
Ejemplo n.º 26
0
        private void BuildReportByOutgo()
        {
            if (Outgo == null)
                return;
            try
            {
                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();

                //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));
                decimal TotalAmount = 0;

                // забиваем таблицу данными
                List<ReportOutgo> list = new List<ReportOutgo>();
                list = da.GetReportOutgoes(SpareOutgoId);

                List<SpareInSpareOutgoView> LIST2 = da.SpareInSpareOutgoViewGet(SpareOutgoId);
                try
                {
                    string CompanyName = da.getProfileCurrent().CompanyName;
                    for (int i = 0; i < LIST2.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;
                        TotalAmount += list[i].quantity * list[i].PriceOut.Value;

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

                        dt.Rows.Add(new object[] {
                            list[i].SpareName,
                            list[i].UnitName,
                            list[i].quantity.ToString("0.##"),
                            list[i].PriceOut.Value.ToString("0.##"),
                            (list[i].PriceOut.Value*list[i].quantity).ToString("0.##"),
                            list[i].VatName,
                            0,
                            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("TotalAmount", TotalAmount.ToString("0.##"));
                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 p2 = sov.AccountName + ", " + Outgo.address;
                data.ReportDocumentValues.Add("param2", p2);
                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);
                data.ReportDocumentValues.Add("warrant", Outgo.warrant);

                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);
            }
        }
Ejemplo n.º 27
0
        private void WindowActivated(object sender, EventArgs e)
        {
            if (!_firstActivated) return;

            _firstActivated = false;

            try
            {
                var reportDocument = new ReportDocument();

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

                var data = new ReportData();
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now

                int bearing1Life = 0;
                int bearing2Life = 0;
                int bearing3Life = 0;
                int bearing1Waste = 0;
                int bearing2Waste = 0;
                int bearing3Waste = 0;

                var table = new DataTable("Bearing1Table");
                FillDataTable(ref table, 0, out bearing1Life, out bearing1Waste);

                data.DataTables.Add(table);
                table = new DataTable("Bearing2Table");
                FillDataTable(ref table, 1, out bearing2Life, out bearing2Waste);
                data.DataTables.Add(table);

                table = new DataTable("Bearing3Table");
                FillDataTable(ref table, 2, out bearing3Life, out bearing3Waste);
                data.DataTables.Add(table);

                //fCumulativeLifetime

                var mtable = new DataTable("BearingsLife3DChart");
                mtable.Columns.Add("Bearing", typeof(string));
                mtable.Columns.Add("Total LifeSpan", typeof(int));
                mtable.Rows.Add(new object[] { "Bearing 1", bearing1Life });
                mtable.Rows.Add(new object[] { "Bearing 2", bearing2Life });
                mtable.Rows.Add(new object[] { "Bearing 3", bearing3Life });
                data.DataTables.Add(mtable);

                data.DataTables.Add(table);
                table = new DataTable("fCumulativeLifetime");
                table.Columns.Add("no", typeof(string));
                table.Columns.Add("CumulativeLifetime", typeof (string));
                table.Columns.Add("WastedTime", typeof (string));
                table.Rows.Add(new object[] { "Bearing 1", bearing1Life, bearing1Waste });
                table.Rows.Add(new object[] { "Bearing 2", bearing2Life, bearing2Waste });
                table.Rows.Add(new object[] { "Bearing 3", bearing3Life, bearing3Waste });

                data.DataTables.Add(table);

                mtable = new DataTable("BearingsWastes3DChart");
                mtable.Columns.Add("Bearing", typeof(string));
                mtable.Columns.Add("Waste Time", typeof(int));
                mtable.Rows.Add(new object[] { "Bearing 1", bearing1Waste });
                mtable.Rows.Add(new object[] { "Bearing 2", bearing2Waste });
                mtable.Rows.Add(new object[] { "Bearing 3", bearing3Waste });
                data.DataTables.Add(mtable);

                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 += string.Format(" - Generated in {0}ms", (_time + (DateTime.Now - dateTimeStart)).TotalMilliseconds);
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(string.Format("{0}\r\n\r\n{1}\r\n{2}", ex.Message, ex.GetType(), ex.StackTrace),
                                ex.GetType().ToString(),
                                MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        public StockAdministrationViewModel(ISession session, IProductService productService, IStockService stockService)
        {
            _session = session;
            _productService = productService;
            _stockService = stockService;

            #region Maintance - Products

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                                {
                                    IsBusy = true;

                                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                    {
                                        View = new EditorView(_session);
                                        var _viewModel = new EditorViewModel<Product>(_session);
                                        _viewModel.ItemRemoved += (sender, e) =>
                                            {
                                                _session.Delete<Data.Models.Stock>(s => s.ProductId == e.Item.Id);
                                                _session.CommitChanges();
                                            };
                                        _viewModel.NewItemSaved += (sender, e) =>
                                            {
                                                _session.Add<Data.Models.Stock>(new Data.Models.Stock()
                                                            {
                                                                Id = Guid.NewGuid(),
                                                                ProductId = e.Item.Id,
                                                                Units = 0
                                                            });
                                                _session.CommitChanges();
                                            };
                                        View.DataContext = _viewModel;

                                        IsBusy = false;
                                    }, DispatcherPriority.Background);
                                },
                Category = "Maintance",
                Title = "Products"
            });

            #endregion

            #region Maintance - Tax

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {
                                                                             View = new EditorView(_session);
                                                                             View.DataContext =
                                                                                 new EditorViewModel<Tax>(_session);

                                                                             IsBusy = false;
                                    }, DispatcherPriority.Background);
                },
                Category = "Maintance",
                Title = "Tax"
            });

            #endregion

            #region Maintance - Categories

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {
                                                                             View = new EditorView(_session);
                                                                             View.DataContext =
                                                                                 new EditorViewModel<Category>(_session);

                                                                             IsBusy = false;
                                    }, DispatcherPriority.Background);
                },
                Category = "Maintance",
                Title = "Categories"
            });

            #endregion

            #region Maintance - Stock Maintance

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {

                                                                             View = new StockMaintanceView_Main();
                                                                             View.DataContext =
                                                                                 new StockMaintanceViewModel(
                                                                                     _productService, _stockService);

                                                                             IsBusy = false;
                                    }, DispatcherPriority.Background);
                },
                Category = "Maintance",
                Title = "Stock Maintance"
            });

            #endregion

            #region Reports - Products

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {

                                                                             ReportDocument reportDocument =
                                                                                 new ReportDocument();

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

                                                                             ReportData reportData = new ReportData();
                                                                             DataTable table = new DataTable("Products");
                                                                             table.Columns.Add("Reference",
                                                                                               typeof (string));
                                                                             table.Columns.Add("Name", typeof (string));
                                                                             table.Columns.Add("BuyPrice",
                                                                                               typeof (double));
                                                                             table.Columns.Add("SellPrice",
                                                                                               typeof (double));

                                                                             foreach (
                                                                                 var product in
                                                                                     _productService.GetProducts())
                                                                             {
                                                                                 table.Rows.Add(new object[]
                                                                                                    {
                                                                                                        product.Reference,
                                                                                                        product.Name,
                                                                                                        product.BuyPrice,
                                                                                                        product.SellPrice
                                                                                                    });
                                                                             }
                                                                             reportData.DataTables.Add(table);

                                                                             XpsDocument xps =
                                                                                 reportDocument.CreateXpsDocument(
                                                                                     reportData);

                                                                             View = new SimpleReportView(xps);

                                                                             IsBusy = false;
                                                                         }, DispatcherPriority.SystemIdle);
                },
                Category = "Reports",
                Title = "Products"
            });

            #endregion

            #region Reports - Current Inventory

            Actions.Add(new AdministrationActionViewModel()
            {
                Action = (p) =>
                {
                    IsBusy = true;
                    Dispatcher.CurrentDispatcher.BeginInvoke((Action)delegate
                                                                         {
                                                                             ReportDocument reportDocument =
                                                                                 new ReportDocument();

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

                                                                             ReportData reportData = new ReportData();
                                                                             DataTable table = new DataTable("Products");
                                                                             table.Columns.Add("Reference",
                                                                                               typeof (string));
                                                                             table.Columns.Add("Name", typeof (string));
                                                                             table.Columns.Add("Units", typeof (double));

                                                                             foreach (
                                                                                 var product in
                                                                                     _productService.GetProducts())
                                                                             {
                                                                                 Data.Models.Stock stock =
                                                                                     _stockService.GetStockByProductId(
                                                                                         product.Id);
                                                                                 table.Rows.Add(new object[]
                                                                                                    {
                                                                                                        product.Reference,
                                                                                                        product.Name,
                                                                                                        stock.Units
                                                                                                    });
                                                                             }
                                                                             reportData.DataTables.Add(table);

                                                                             XpsDocument xps =
                                                                                 reportDocument.CreateXpsDocument(
                                                                                     reportData);

                                                                             View = new SimpleReportView(xps);

                                                                             IsBusy = false;
                                                                         }, DispatcherPriority.SystemIdle);
                },
                Category = "Reports",
                Title = "Current Inventory"
            });

            #endregion
        }