예제 #1
0
        private void LoadCurrentProfile()
        {
            if (profile == null)
            {
                profile = da.getProfileCurrent();
            }
            profile.DefaultIncomeCurrencyCode = profile.DefaultIncomeCurrencyCode.Replace(" ", String.Empty);
            edtAddress.Text = profile.AddressFact;
            edtName.Text    = profile.CompanyName;

            //edtDefaultIsCashless.IsChecked = profile.DefaultIsCashless == 1 ? true : false;
            edtUNN.Text = profile.UNN;
            LoadCurrencies();
            CurrencyCodeOld                       = edtBasicCurrency.SelectedItem.ToString();
            CurrencyCodeOld_IncomeDef             = profile.DefaultIncomeCurrencyCode;
            edtDefaultIncomeCurrency.SelectedItem = profile.DefaultIncomeCurrencyCode;

            edtAccountant.Text  = profile.SeniorAccountant;
            edtCompanyHead.Text = profile.CompanyHead;
            edtJAddress.Text    = profile.AddressJur;
            edtLoadPoint.Text   = profile.LoadPoint;
            edtOKPO.Text        = profile.OKPO;

            edtDefaultSearchField.SelectedIndex     = profile.DefSearchFieldIndex.HasValue ? profile.DefSearchFieldIndex.Value : 0;
            edtSearchTypeInMainWindow.SelectedIndex = profile.UseScanner.HasValue ? profile.UseScanner.Value : 0;

            //edtBankAccount.Text = profile.BankAccount;
            // edtBankAddress.Text = profile.BankAddress;
            // edtBankMFO.Text = profile.BankMFO;
            // edtBankName.Text = profile.BankName;
        }
예제 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            settings_profile settings = da.getProfileCurrent();

            if (settings.DefaultUserID > 0)
            {
                Marvin.Instance.CurrentUser = da.AdminUnitGet(settings.DefaultUserID);
            }
            else
            {
                LoginView v1 = new LoginView();
                v1.ShowDialog();
                if (!v1.Res)
                {
                    App.Current.Shutdown();

                    //Close();
                    return;
                }
            }
            this.Title += " - " + Marvin.Instance.CurrentUser.name;

            // check currencies up-to-date
            if (!da.AreCurrenciesUpToDate())
            {
                CurrenciesInput v = new CurrenciesInput(DateTime.Now);
                v.ShowDialog();
            }
        }
예제 #3
0
        private void TryLogin()
        {
            int        UserID = (int)edtUser.SelectedValue;
            admin_unit user   = items.FirstOrDefault(x => x.id == UserID);

            if (edtPassword.Password == user.password)
            {
                Res = true;
                Marvin.Instance.CurrentUser = user;
                if (edtRememberUser.IsChecked == true)
                {
                    DataAccess       db       = new DataAccess();
                    settings_profile settings = db.getProfileCurrent();
                    settings.DefaultUserID = user.id;
                    db.ProfileEdit(settings);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Неправильная комбинация логина и пароля!");
                edtPassword.Password = "";
                edtPassword.Focus();
            }
        }
예제 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LoadSpares();
            DataAccess       db = new DataAccess();
            settings_profile sp = db.getProfileCurrent();

            cbSimpleIncome.IsChecked  = sp.SimpleInput.HasValue ? (sp.SimpleInput.Value == 1 ? true : false) : false;
            cbSctrictSearch.IsChecked = sp.StrictSearch.HasValue ? (sp.StrictSearch.Value == 1 ? true : false) : false;
        }
예제 #5
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DataAccess       db = new DataAccess();
            settings_profile sp = db.getProfileCurrent();

            //cbSimpleIncome.IsChecked = sp.SimpleInput.HasValue ? (sp.SimpleInput.Value == 1 ? true : false) : false;
            sp.SimpleInput  = cbSimpleIncome.IsChecked.HasValue ? (cbSimpleIncome.IsChecked.Value ? 1 : 0) : 0;
            sp.StrictSearch = cbSctrictSearch.IsChecked.HasValue ? (cbSctrictSearch.IsChecked.Value ? 1 : 0) : 0;
            db.ProfileEdit(sp);
        }
예제 #6
0
        private void LogOut()
        {
            MessageBoxResult res = MessageBox.Show("Программа будет закрыта. Вы уверены?", "Выход", MessageBoxButton.YesNo);

            if (res == MessageBoxResult.Yes)
            {
                settings_profile settings = da.getProfileCurrent();
                settings.DefaultUserID = 0;
                da.ProfileEdit(settings);
                App.Current.Shutdown();
            }
        }
예제 #7
0
        private void LoadComboboxCurrency()
        {
            List <currency> items = da.GetCurrency();

            foreach (currency i in items)
            {
                edtCurrency.Items.Add(i.code);
            }

            //edtCurrency.SelectedIndex = 0;
            settings_profile profile = da.getProfileCurrent();

            edtCurrency.SelectedItem = profile.DefaultIncomeCurrencyCode.Replace(" ", String.Empty);
        }
        private void Window_Activated(object sender, EventArgs e)
        {
            if (Outgo == null)
            {
                return;
            }
            try
            {
                ReportDocument reportDocument = new ReportDocument();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                data.DataTables.Add(dt);

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

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

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

                ReportData data = new ReportData();

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

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

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

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

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

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

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

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

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

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