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(); } }
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; }
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); }
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 RefreshWindow() { // загрузить список запчастей в таблицу //LoadSpares(); da = new DataAccess(); if (!da.getProfileCurrent().BasicCurrencyCode.Contains("BYR")) tabItemOverpricing.Visibility = System.Windows.Visibility.Collapsed; else tabItemOverpricing.Visibility = System.Windows.Visibility.Visible; }
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); } }
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(); }
private void Window_Activated(object sender, EventArgs e) { if (Outgo == null) return; try { ReportDocument reportDocument = new ReportDocument(); StreamReader reader = new StreamReader(new FileStream(@"Templates\OverpricingReport.xaml", FileMode.Open, FileAccess.Read)); reportDocument.XamlData = reader.ReadToEnd(); reportDocument.XamlImagePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Templates\"); reader.Close(); ReportData data = new ReportData(); DataAccess da = new DataAccess(); // Таблица ТОВАРЫ В НАКЛАДНОЙ DataTable dt = new DataTable("mtable"); // описываем столбцы таблицы dt.Columns.Add("t1", typeof(string)); dt.Columns.Add("t2", typeof(string)); dt.Columns.Add("t3", typeof(string)); dt.Columns.Add("t4", typeof(string)); dt.Columns.Add("t5", typeof(string)); dt.Columns.Add("t6", typeof(string)); dt.Columns.Add("t7", typeof(string)); dt.Columns.Add("t8", typeof(string)); dt.Columns.Add("t9", typeof(string)); dt.Columns.Add("t10", typeof(string)); decimal sum1 = 0; decimal sum2 = 0; decimal sum3 = 0; // забиваем таблицу данными List<SpareInOverpricingView> LIST2 = da.OverpricingOfferingGet(ItemID); try { string CompanyName = da.getProfileCurrent().CompanyName; for (int i = 0; i < LIST2.Count; i++) { sum1 += LIST2[i].quantity.Value; sum2 += LIST2[i].sumOld.Value; sum3 += LIST2[i].sumNew.Value; dt.Rows.Add(new object[] { LIST2[i].SpareName, LIST2[i].UnitName, LIST2[i].quantity, LIST2[i].purchasePrice, LIST2[i].percentOld, LIST2[i].priceOld, LIST2[i].sumOld, LIST2[i].percentNew, LIST2[i].priceNew, LIST2[i].sumNew }); } } catch (Exception exc) { Marvin.Instance.Log(exc.Message); throw exc; } string strDate = Outgo.createdOn.Value.Day.ToString(); string mnth = ""; switch (Outgo.createdOn.Value.Month) { case 1: mnth = "января"; break; case 2: mnth = "февраля"; break; case 3: mnth = "марта"; break; case 4: mnth = "апреля"; break; case 5: mnth = "мая"; break; case 6: mnth = "июня"; break; case 7: mnth = "июля"; break; case 8: mnth = "августа"; break; case 9: mnth = "сентября"; break; case 10: mnth = "октября"; break; case 11: mnth = "ноября"; break; case 12: mnth = "декабря"; break; } strDate += " " + mnth + " " + Outgo.createdOn.Value.Year + " г."; data.ReportDocumentValues.Add("p1", Outgo.id); data.ReportDocumentValues.Add("p2", strDate); // print date is now data.ReportDocumentValues.Add("sum1", sum1); data.ReportDocumentValues.Add("sum2", sum2); data.ReportDocumentValues.Add("sum3", sum3); data.DataTables.Add(dt); DateTime dateTimeStart = DateTime.Now; // start time measure here XpsDocument xps = reportDocument.CreateXpsDocument(data); documentViewer.Document = xps.GetFixedDocumentSequence(); } catch (Exception ex) { // show exception Marvin.Instance.Log(ex.Message); MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop); } }
private void Window_Activated(object sender, EventArgs e) { if (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); } }