void SetFieldValue(XmlNode node, PatternFieldType type, object value) { var element = (XmlElement)node; if (type == PatternFieldType.FDate) // && node.Attributes ["office:date-value"] != null) { node.Attributes["office:string-value"].Value = value != null ? ((DateTime)value).ToLongDateString() : String.Empty; } //node.Attributes ["office:date-value"].Value = field.value != DBNull.Value ? XmlConvert.ToString ((DateTime)field.value, XmlDateTimeSerializationMode.Unspecified) : ""; else if (type == PatternFieldType.FCurrency) { decimal valueDec = value != null ? (decimal)value : Decimal.Zero; string fieldName = node.Attributes["text:name"].Value; if (fieldName.EndsWith(".Число")) { ((XmlElement)node).SetAttribute("value-type", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", "currency"); ((XmlElement)node).SetAttribute("value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", XmlConvert.ToString(valueDec)); string curr = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencySymbol; ((XmlElement)node).SetAttribute("currency", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", curr); } if (fieldName.EndsWith(".Пропись")) { string val = RusCurrency.Str((int)valueDec, true, "рубль", "рубля", "рублей", "", "", ""); node.Attributes["office:string-value"].Value = val; } } else if (type == PatternFieldType.FNumber) { element.SetAttribute("value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", value?.ToString()); } else { element.SetAttribute("string-value", "urn:oasis:names:tc:opendocument:xmlns:office:1.0", value?.ToString()); //value != null ? value.ToString () : String.Empty); } }
public override void CreatePackage(string fileName) { var document = DocumentModel.Load(DocumentTemplate.ExtractDoc("EntrantContract")); // Подготовка стилей var underlinedText = new CharacterFormat { UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single }; var underlinedBoldText = new CharacterFormat { UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single, Bold = true }; var boldText = new CharacterFormat { Bold = true }; // Готовим текст string yearPrice = string.Format("{0} {1}", _contract.YearPrice, RusCurrency.Str((double)_contract.YearPrice)); string fullPrice = string.Format("{0} {1}", _contract.FullPrice, RusCurrency.Str((double)_contract.FullPrice)); string shhets = _contract.ContragentType.Id == 1 ? "2" : "3"; // Вставляем текст на закладки document.InsertToBookmark("Number", _contract.Number, underlinedBoldText); document.InsertToBookmark("Date", ((DateTime)_contract.Date).ToString("«dd» MMMM yyyy г.")); document.InsertToBookmark("YearPrice", yearPrice, underlinedBoldText); document.InsertToBookmark("FullPrice", fullPrice, underlinedBoldText); document.InsertToBookmark("YearPrice1", yearPrice, underlinedBoldText); document.InsertToBookmark("SheetCount", shhets); document.InsertToBookmark("AgentInfo", GetAgentInfo()); document.InsertToBookmark("EntrantInfo", GetEntrantInfo()); document.InsertToBookmark("EntrantName", _contract.Entrant.FullName, boldText); document.InsertToBookmark("AgentName", _contract.PayerName, boldText); document.InsertToBookmark("CompetitiveGroup", string.Format("{0} {1}, {2}, {3} форма обучения", _contract.Entrant.Claim.FirstDirection.Code, _contract.Entrant.Claim.FirstDirection.Name, _contract.Entrant.Claim.GetCompetitiveGroupByPriority(1).EducationLevel.Name, _contract.Entrant.Claim.EducationForm.Name), boldText); string educationLevel = _contract.Entrant.Claim.EducationLevel.Id == 1 ? "высшего образования" : "среднего профессионального образования"; string diplomaType = _contract.Entrant.Claim.EducationLevel.Id == 1 ? "диплом о высшем образовании" : "диплом о среднем профессиональном образовании"; document.InsertToBookmark("DiplomaType", diplomaType, underlinedText); document.InsertToBookmark("EducationLevel", educationLevel, underlinedText); document.InsertToBookmark("TrainingTime", _contract.TrainingPeriod.AsPeriod(), underlinedText); document.Save(fileName); }
public override void CreatePackage(string fileName) { var document = DocumentModel.Load(DocumentTemplate.ExtractDoc("ContractIndividualPlanAgreement")); // Подготовка стилей var underlinedText = new CharacterFormat { UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single }; var underlinedBoldText = new CharacterFormat { UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single, Bold = true }; var boldText = new CharacterFormat { Bold = true }; // Готовим текст string yearPrice = string.Format("{0} {1}", _agreement.YearPrice, RusCurrency.Str((double)_agreement.YearPrice)); string fullPrice = string.Format("{0} {1}", _agreement.FullPrice, RusCurrency.Str((double)_agreement.FullPrice)); // Вставляем текст на закладки document.InsertToBookmark("Number", _agreement.Number, underlinedBoldText); document.InsertToBookmark("Date", ((DateTime)_agreement.Date).ToString("«dd» MMMM yyyy г.")); document.InsertToBookmark("YearPrice", yearPrice, underlinedBoldText); document.InsertToBookmark("FullPrice", fullPrice, underlinedBoldText); document.InsertToBookmark("YearPrice1", yearPrice, underlinedBoldText); document.InsertToBookmark("AgentInfo", GetAgentInfo()); document.InsertToBookmark("EntrantInfo", GetEntrantInfo()); document.InsertToBookmark("EntrantName", _agreement.EntrantContract.Entrant.FullName, boldText); document.InsertToBookmark("AgentName", _agreement.EntrantContract.PayerName, boldText); document.InsertToBookmark("TrainingPeriod", _agreement.TrainingPeriod.AsPeriod(), underlinedText); document.InsertToBookmark("FullTrainingPeriod", _agreement.EntrantContract.TrainingPeriod.AsPeriod(), underlinedText); document.InsertToBookmark("ContractNumber1", _agreement.EntrantContract.Number, underlinedBoldText); document.InsertToBookmark("ContractDate1", ((DateTime)_agreement.EntrantContract.Date).ToString("dd.MM.yyyy г."), underlinedBoldText); document.InsertToBookmark("ContractNumber2", _agreement.EntrantContract.Number, underlinedText); document.InsertToBookmark("ContractDate2", ((DateTime)_agreement.EntrantContract.Date).ToString("dd.MM.yyyy г."), underlinedText); document.InsertToBookmark("ContractNumber3", _agreement.EntrantContract.Number, underlinedText); document.InsertToBookmark("ContractDate3", ((DateTime)_agreement.EntrantContract.Date).ToString("dd.MM.yyyy г."), underlinedText); document.InsertToBookmark("ContractNumber4", _agreement.EntrantContract.Number, underlinedText); document.InsertToBookmark("ContractDate4", ((DateTime)_agreement.EntrantContract.Date).ToString("dd.MM.yyyy г."), underlinedText); document.Save(fileName); }
static public string CurrencyToText(decimal value, short currency = 810) { string cur = "RUR"; switch (currency) { case 840: cur = "USD"; break; case 978: cur = "EUR"; break; default: cur = "RUR"; break; } return(RusCurrency.Str(Convert.ToDouble(value), cur)); }
public override void CreatePackage(string fileName) { var document = DocumentModel.Load(DocumentTemplate.ExtractDoc("ExaminationStatementMiddleEducation")); // Подготовка стилей var underlinedText = new CharacterFormat { FontName = "Times New Roman", Size = 12, UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single }; var underlinedBoldText = new CharacterFormat { FontName = "Times New Roman", Size = 12, UnderlineColor = Color.Black, UnderlineStyle = UnderlineType.Single, Bold = true }; document.InsertToBookmark("ClaimNumber", _claim.Number, underlinedText); document.InsertToBookmark("CurrentUser", string.Format("{0} {1}.{2}.", Session.CurrentUser.LastName, Session.CurrentUser.FirstName[0], Session.CurrentUser.Patronymic[0])); document.InsertToBookmark("Date", DateTime.Now.ToString("«dd» MMMM yyyy г."), underlinedText); document.InsertToBookmark("EntrantName", _claim.Person.FullName); string middleMark = string.Format("{0}({1} балла)", _claim.MiddleMark, RusCurrency.Str(_claim.MiddleMark, true, "целый", "целых", "целых", "сотый", "сотых", "сотых")); document.InsertToBookmark("MiddleMark", middleMark); document.InsertToBookmark("ProtocolInfo", string.Format("{0} №{1}", ((DateTime)_claim.SchoolCertificateDocuments.First().EntranceExaminationsCheckProtocol.Date).ToString("dd.MM.yyyy г."), _claim.SchoolCertificateDocuments.First().EntranceExaminationsCheckProtocol.Number), underlinedBoldText); document.Save(fileName, SaveOptions.DocxDefault); }
protected override void BuildDoc() { var row1 = new TableRow(); var row2 = new TableRow(); var headerTable = new Table { Columns = { new TableColumn { Width = new GridLength(300, GridUnitType.Pixel) }, new TableColumn { Width = new GridLength(300, GridUnitType.Pixel) }, new TableColumn { Width = new GridLength(400, GridUnitType.Pixel) }, }, RowGroups = { new TableRowGroup { Rows = { row1,row2 } } } }; row1.Cells.Add(new TableCell(new Paragraph(new Run( "К положению о порядке формирования цен на лекарственные средства и изделия медицинского назначения\n" + "Цены реестра соответствуют\n" + "Гос. реестру 17 изд. 5 доп.")) { FontSize = 8, Style = BlockStyle, }) { RowSpan = 2 }); row1.Cells.Add(new TableCell()); row1.Cells.Add(new TableCell(new Paragraph(new Run(settings.FullName)) { TextAlignment = TextAlignment.Right, FontSize = 14, Style = BlockStyle, })); row2.Cells.Add(new TableCell()); row2.Cells.Add(new TableCell(new Paragraph(new Run("УТВЕРЖДАЮ\n" + $"Зав.аптекой _____________________{settings.Director}")) { TextAlignment = TextAlignment.Right, FontSize = 8, Style = BlockStyle, })); doc.Blocks.Add(headerTable); var header = Header(String.Format("РЕЕСТР №{0} от {1:d}\n" + "розничных цен на лекарственные средства и изделия медицинского назначения,\n" + "полученные от {4}-по счету (накладной) №{2} от {3:d}", docSettings.RegistryId, docSettings.Date, waybill.ProviderDocumentId, waybill.DocumentDate, waybill.SupplierName)); header.TextAlignment = TextAlignment.Center; var columns = new[] { new PrintColumn("№ пп", 27), new PrintColumn("Наименование и краткая характеристика товара", 170, colSpan: 2), new PrintColumn(null, 30), new PrintColumn("Серия товара", 84), new PrintColumn("Срок годности", 60), new PrintColumn("Наименование", 100) { HeaderStyle = new Style(typeof(TableCell), TableHeaderStyle) { Setters = { new Setter(TableCell.FontSizeProperty, 8d), } }, CellStyle = new Style(typeof(TableCell), CellStyle) { Setters = { new Setter(TableCell.FontSizeProperty, 8d), } } }, new PrintColumn("Цена без НДС, руб", 50), new PrintColumn("Цена с НДС, руб", 50), new PrintColumn("Цена ГР, руб", 50), new PrintColumn("Опт. надб. %", 32), new PrintColumn("Отпуск. цена пост - ка без НДС, руб", 50), new PrintColumn("НДС пост-ка, руб", 40), new PrintColumn("Отпуск. цена пост-ка с НДС, руб", 50), new PrintColumn("Розн. торг. надб. %", 33), new PrintColumn("Розн. торг. надб. руб", 40), new PrintColumn("Розн. цена. за ед., руб", 50), new PrintColumn("Кол-во", 36), new PrintColumn("Розн. сумма, руб", 50), }; var columnGrops = new[] { new ColumnGroup("Предприятие - изготовитель", 4, 6) }; var rows = lines.Select((l, i) => new object[] { ++i, l.Product, l.ActualVitallyImportant ? "ЖВ" : "", l.SerialNumber, l.Period, $"{l.Producer} {l.Country}", l.ProducerCost?.ToString("0.00"), l.ProducerCostWithTax?.ToString("0.00"), l.RegistryCost?.ToString("0.00"), l.SupplierPriceMarkup, l.SupplierCostWithoutNds?.ToString("0.00"), l.TaxPerUnit, l.SupplierCost?.ToString("0.00"), l.RetailMarkup, l.RetailMarkupInRubles?.ToString("0.00"), l.RetailCost?.ToString("0.00"), l.Quantity, l.RetailSum?.ToString("0.00"), }); BuildTable(rows, columns, columnGrops); var retailsSum = lines.Sum(l => l.RetailSum); var block = Block("Продажная сумма: " + (retailsSum != null ? RusCurrency.Str((double)retailsSum) : "")); block.FontSize = 14; block.Inlines.Add(new Figure(new Paragraph(new Run(retailsSum != null ? retailsSum.Value.ToString("0.00") : ""))) { FontWeight = FontWeights.Bold, HorizontalAnchor = FigureHorizontalAnchor.ContentRight, Padding = new Thickness(0), Margin = new Thickness(0) }); var sum = waybill.DisplayedSum; block = Block("Сумма поставки: " + (sum != 0 ? RusCurrency.Str((double)sum) : "")); block.FontSize = 14; block.Inlines.Add(new Figure(new Paragraph(new Run(sum != 0 ? sum.ToString("0.00") : ""))) { FontWeight = FontWeights.Bold, HorizontalAnchor = FigureHorizontalAnchor.ContentRight, Padding = new Thickness(0), Margin = new Thickness(0) }); if (docSettings.Type == RegistryDocumentSettings.SignerType.Acceptor) { var signBlock = Block("Товар принял:\n" + $"_{docSettings.Acceptor}____/ /\n"); signBlock.FontSize = 8; } else { var signBlock = Block("Члены комиссии:\n" + $"_{docSettings.CommitteeMember1}____/ /\n" + $"_{docSettings.CommitteeMember2}____/ /\n" + $"_{docSettings.CommitteeMember3}____/ /"); signBlock.FontSize = 8; } }
public void PrintPayments() { string target = "Сведения о платежах для договора №" + CurrentCredit.Number + ".doc"; try { _richTextBox.LoadFile(Storage.PaymentsTemplateFile, RichTextBoxStreamType.RichText); } catch (IOException) { MessageBox.Show("Не удалось найти файл шаблона или он занят другим процессом!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Replace("#dognomer#", CurrentCredit.Number.ToString()); Replace("#dogdata#", CurrentCredit.Data.ToShortDateString()); Replace("#pokfio#", CurrentCredit.ClientFIO); Replace("#pokadres#", CurrentCredit.ClientAdr); Replace("#pokdok#", CurrentCredit.ClientDoc); Replace("#poktel#", CurrentCredit.ClientPhone); Replace("#alltovarsumma#", CurrentCredit.Total.ToString() + " (" + RusCurrency.Str(Convert.ToDouble(CurrentCredit.Total)) + ")");// Replace("#pradd#", CurrentCredit.AddPercent.ToString()); Replace("#prmin#", CurrentCredit.DiscPercent.ToString()); Replace("#firstsumma#", CurrentCredit.FirstPayment.ToString() + " (" + RusCurrency.Str(Convert.ToDouble(CurrentCredit.FirstPayment)) + ")"); // Replace("#summalost#", (CurrentCredit.Total - CurrentCredit.FirstPayment).ToString() + " (" + RusCurrency.Str(Convert.ToDouble(CurrentCredit.Total - CurrentCredit.FirstPayment)) + ")"); // Replace("#prgod#", CurrentCredit.PercentYear.ToString()); var payments = _paymentRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id); //tablePayments Replace("#ivsumma#", payments.Sum(p => p.PaymentAmount).ToString()); Replace("#ivproch#", payments.Sum(p => p.SumPercent).ToString()); Replace("#ivpeni#", payments.Sum(p => p.SumPenalty).ToString()); Replace("#ivitog#", (payments.Sum(p => p.PaymentAmount) + payments.Sum(p => p.SumPercent) + payments.Sum(p => p.SumPenalty)) .ToString()); Replace("#lost#", (CurrentCredit.Total - CurrentCredit.FirstPayment - payments.Sum(p => p.PaymentAmount)).ToString() + " (" + RusCurrency.Str(Convert.ToDouble((CurrentCredit.Total - CurrentCredit.FirstPayment - payments.Sum(p => p.PaymentAmount)))) + ")"); var schedule = _scheduleRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id && p.DatePayment < DateTime.Now).ToList(); decimal penalty = 0; while (true) { if (schedule.Count == 0) { break; } int days = (DateTime.Now - schedule.Last().DatePayment).Days; decimal sum = schedule.Sum(s => s.PaymentAmount); penalty += sum / 100 / 100 * 5 * days; schedule.Remove(schedule.Last()); } penalty -= payments.Sum(p => p.SumPenalty); Replace("#curpeni#", penalty.ToString() + " (" + RusCurrency.Str(Convert.ToDouble(penalty)) + ")"); Replace("#curdata#", DateTime.Today.ToShortDateString()); _richTextBox.SaveFile(target); StringBuilder sb = new StringBuilder(); foreach (var pay in payments) { sb.Append(@"{\rtf1\ansi\deff0 "); sb.Append(@"\trowd\qr"); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx1916 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx3851 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx5771 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx7706 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx9627 "); sb.Append(" " + pay.DatePayment.ToShortDateString() + @"\cell"); sb.Append(" " + pay.PaymentAmount + @"\cell"); sb.Append(" " + pay.SumPercent + @"\cell"); sb.Append(" " + pay.SumPenalty + @"\cell"); sb.Append(" " + (pay.PaymentAmount + pay.SumPercent + pay.SumPenalty).ToString() + @"\cell"); sb.Append(@"}"); sb.Append(@"\row "); } string str = File.ReadAllText(target); str = str.Replace("#tablePayments#", sb.ToString()); File.WriteAllText(target, str); MessageBox.Show("Формирование отчёта MS Word (.doc) по платежам завершено!", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void PrintSchedule() { string target = "График платежей для договора №" + CurrentCredit.Number + ".doc"; try { _richTextBox.LoadFile(Storage.ScheduleTemplateFile, RichTextBoxStreamType.RichText); } catch (IOException) { MessageBox.Show("Не удалось найти файл шаблона или он занят другим процессом!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Replace("#nomer#", CurrentCredit.Number.ToString()); Replace("#data#", CurrentCredit.Data.ToShortDateString()); Replace("#fio#", CurrentCredit.ClientFIO); Replace("#adres#", CurrentCredit.ClientAdr); Replace("#docum#", CurrentCredit.ClientDoc); //tableProducts string final = string.Empty; if (CurrentCredit.AddPercent != 0 && CurrentCredit.DiscPercent != 0) { final = "Цена товара(ов) с учетом скидки в размере " + CurrentCredit.DiscPercent + "% и надбавки в размере " + CurrentCredit.AddPercent + "% составит " + CurrentCredit.Total + "руб."; } else if (CurrentCredit.AddPercent == 0 && CurrentCredit.DiscPercent != 0) { final = "Цена товара(ов) с учетом скидки в размере " + CurrentCredit.DiscPercent + "% составит " + CurrentCredit.Total + "руб."; } else if (CurrentCredit.AddPercent != 0 && CurrentCredit.DiscPercent == 0) { final = "Цена товара(ов) с учетом надбавки в размере " + CurrentCredit.AddPercent + "% составит " + CurrentCredit.Total + "руб."; } else { final = ""; } Replace("#withadddisc#", final); var soldProducts = _soldProductsRepository.GetSoldProducts().Where(p => p.CreditId == CurrentCredit.Id); Replace("#titog#", soldProducts.Sum(p => p.Total).ToString()); Replace("#firstsumma#", CurrentCredit.FirstPayment.ToString()); Replace("#lastsumma#", (CurrentCredit.Total - CurrentCredit.FirstPayment).ToString()); var payments = _scheduleRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id); //tableSchedule Replace("#itogvznos#", payments.Sum(p => p.PaymentAmount).ToString()); Replace("#itogpr#", payments.Sum(p => p.SumPercent).ToString()); Replace("#itogsumma#", payments.Sum(p => p.SumTotal).ToString()); Replace("#prodav#", CurrentCredit.Consult); Replace("#curdata#", DateTime.Today.ToShortDateString()); _richTextBox.SaveFile(target); StringBuilder sb = new StringBuilder(); foreach (var prod in soldProducts) { sb.Append(@"{\rtf1\ansi\deff0 "); sb.Append(@"\trowd"); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx6485 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx9562 "); sb.Append(ToRtf(prod.Name + @"\cell")); sb.Append(" " + prod.Total.ToString() + " (" + ToRtf(RusCurrency.Str(Convert.ToDouble(prod.Total)) + @")\cell")); sb.Append(@"}"); sb.Append(@"\row "); } string str = File.ReadAllText(target); str = str.Replace("#tableProducts#", sb.ToString()); File.WriteAllText(target, str); var schedule = _scheduleRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id); sb = new StringBuilder(); foreach (var pay in schedule) { sb.Append(@"{\rtf1\ansi\deff0 "); sb.Append(@"\trowd\qr"); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx1650 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx3310 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx4972 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx6632 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx8293 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx9955 "); sb.Append(" " + pay.DatePayment.ToShortDateString() + @"\cell"); sb.Append(" " + pay.Rest + @"\cell"); sb.Append(" " + pay.PaymentAmount + @"\cell"); sb.Append(" " + pay.SumPercent + @"\cell"); sb.Append(" " + pay.SumTotal + @"\cell"); sb.Append(" " + ToRtf(pay.Comment + @"\cell")); sb.Append(@"}"); sb.Append(@"\row "); } str = File.ReadAllText(target); str = str.Replace("#tableSchedule#", sb.ToString()); File.WriteAllText(target, str); MessageBox.Show("Формирование отчёта MS Word (.doc) по графику платежей завершено!", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void PrintAgreement() { string target = "Договор №" + CurrentCredit.Number + ".doc"; try { _richTextBox.LoadFile(Storage.AgreementTemplateFile, RichTextBoxStreamType.RichText); } catch (IOException) { MessageBox.Show("Не удалось найти файл шаблона или он занят другим процессом!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Replace("#nomer#", CurrentCredit.Number.ToString()); Replace("#gorod#", _mainInfo.City); Replace("#data#", CurrentCredit.Data.ToShortDateString()); Replace("#nameOrg#", _mainInfo.Name); Replace("#ruk#", _mainInfo.Chief); Replace("#osn#", _mainInfo.Document); Replace("#nameKlient#", CurrentCredit.ClientFIO); Replace("#docum#", CurrentCredit.ClientDoc); //tableProducts string final = string.Empty; if (CurrentCredit.AddPercent != 0 && CurrentCredit.DiscPercent != 0) { final = "Цена товара(ов) с учетом скидки в размере " + CurrentCredit.DiscPercent + "% и надбавки в размере " + CurrentCredit.AddPercent + "% составит " + CurrentCredit.Total + "руб."; } else if (CurrentCredit.AddPercent == 0 && CurrentCredit.DiscPercent != 0) { final = "Цена товара(ов) с учетом скидки в размере " + CurrentCredit.DiscPercent + "% составит " + CurrentCredit.Total + "руб."; } else if (CurrentCredit.AddPercent != 0 && CurrentCredit.DiscPercent == 0) { final = "Цена товара(ов) с учетом надбавки в размере " + CurrentCredit.AddPercent + "% составит " + CurrentCredit.Total + "руб."; } else { final = ""; } Replace("#withadddisc#", final); Replace("#firstsumma#", CurrentCredit.FirstPayment.ToString() + " (" + RusCurrency.Str(Convert.ToDouble(CurrentCredit.FirstPayment)) + ")"); Replace("#summalost#", (CurrentCredit.Total - CurrentCredit.FirstPayment).ToString() + " (" + RusCurrency.Str(Convert.ToDouble(CurrentCredit.Total - CurrentCredit.FirstPayment)) + ")"); Replace("#adres#", _mainInfo.OfficeAddress); Replace("#prgod#", CurrentCredit.PercentYear.ToString()); Replace("#peni#", _base.PercentPenalty.ToString()); //tableSchedule var payments = _scheduleRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id); Replace("#itogvznos#", payments.Sum(p => p.PaymentAmount).ToString()); Replace("#itogpr#", payments.Sum(p => p.SumPercent).ToString()); Replace("#itogsumma#", payments.Sum(p => p.SumTotal).ToString()); Replace("#orgName#", _mainInfo.Name); Replace("#inn#", _mainInfo.INN); Replace("#street#", _mainInfo.UridAddress); Replace("#bank#", _mainInfo.Bank); Replace("#orgtel#", _mainInfo.Phone); Replace("#klientName#", CurrentCredit.ClientFIO); Replace("#pokadres#", CurrentCredit.ClientAdr); Replace("#poktel#", CurrentCredit.ClientPhone); _richTextBox.SaveFile(target); var soldProducts = _soldProductsRepository.GetSoldProducts().Where(p => p.CreditId == CurrentCredit.Id); StringBuilder sb = new StringBuilder(); foreach (var prod in soldProducts) { sb.Append(@"{\rtf1\ansi\deff0 "); sb.Append(@"\trowd"); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx6485 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx9562 "); sb.Append(ToRtf(prod.Name + @"\cell")); sb.Append(" " + prod.Total.ToString() + " (" + ToRtf(RusCurrency.Str(Convert.ToDouble(prod.Total)) + @")\cell")); sb.Append(@"}"); sb.Append(@"\row "); } string str = File.ReadAllText(target); str = str.Replace("#tableProducts#", sb.ToString()); File.WriteAllText(target, str); var schedule = _scheduleRepository.GetPayments().Where(p => p.CreditId == CurrentCredit.Id); sb = new StringBuilder(); foreach (var pay in schedule) { sb.Append(@"{\rtf1\ansi\deff0 "); sb.Append(@"\trowd\qr"); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx1650 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx3310 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx4972 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx6632 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx8293 "); sb.Append(@"\clbrdrt\brdrs\clbrdrl\brdrs\clbrdrb\brdrs\clbrdrr\brdrs\cellx9955 "); sb.Append(" " + pay.DatePayment.ToShortDateString() + @"\cell"); sb.Append(" " + pay.Rest + @"\cell"); sb.Append(" " + pay.PaymentAmount + @"\cell"); sb.Append(" " + pay.SumPercent + @"\cell"); sb.Append(" " + pay.SumTotal + @"\cell"); sb.Append(" " + ToRtf(pay.Comment + @"\cell")); sb.Append(@"}"); sb.Append(@"\row "); } str = File.ReadAllText(target); str = str.Replace("#tableSchedule#", sb.ToString()); File.WriteAllText(target, str); MessageBox.Show("Формирование отчёта MS Word (.doc) по договору завершено!", "Готово", MessageBoxButtons.OK, MessageBoxIcon.Information); }
protected override void BuildDoc() { var h1 = Header($"{settings.FullName}\nАкт прихода товара №{docSettings.DocId} от {docSettings.DocumentDate:d}"); var h2 = Header($@"по накладной {waybill.ProviderDocumentId} от {waybill.DocumentDate:d} поставщик: {waybill.SupplierName} получатель: {settings.FullName}"); h1.TextAlignment = h2.TextAlignment = TextAlignment.Center; ((Run)h1.Inlines.FirstInline).FontWeight = FontWeights.Bold; var columns = new[] { new PrintColumn("№ пп", 28), new PrintColumn("Наименование", 356), new PrintColumn("Кол-во", 34), new PrintColumn("Серия\nСрок", 81), new PrintColumn("ЖНВЛП", 16), new PrintColumn("Заводской штрихкод", 75), new PrintColumn("НДС", 34), new PrintColumn("Цена", 50), new PrintColumn("Сумма", 50), new PrintColumn("Цена", 50), new PrintColumn("Сумма", 50), new PrintColumn("Сертификат", 180), }; var columnGrops = new[] { new ColumnGroup("Оптовое звено", 7, 8), new ColumnGroup("Розничное звено", 9, 10) }; var rows = lines.Select((l, i) => new object[] { ++i, $"{l.Product}\n{l.Producer} {l.Country}", l.Quantity, $"{l.SerialNumber}\n{l.Period}", l.ActualVitallyImportant ? "+" : "", l.EAN13, l.Nds, l.SupplierCost, l.Amount, l.RetailCost, l.RetailSum, $"{l.Certificates}", }); var retailSum = lines.Sum(l => l.RetailSum); var sum = lines.Sum(l => l.Amount); var table = BuildTable(rows, columns, columnGrops); foreach (var row in table.RowGroups[0].Rows.Skip(2)) { row.Cells[0].TextAlignment = row.Cells[2].TextAlignment = row.Cells[4].TextAlignment = row.Cells[6].TextAlignment = TextAlignment.Center; } table.RowGroups[0].Rows.Add(new TableRow { Cells = { new TableCell(new Paragraph(new Run("Итого: ")) { KeepTogether = true }) { Style = CellStyle, ColumnSpan = 7 }, new TableCell(new Paragraph(new Run(sum.ToString())) { KeepTogether = true }) { Style = CellStyle, ColumnSpan = 2, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }, new TableCell(new Paragraph(new Run(retailSum.ToString())) { KeepTogether = true }) { Style = CellStyle, ColumnSpan = 2, FontWeight = FontWeights.Bold, TextAlignment = TextAlignment.Right }, new TableCell(new Paragraph(new Run()) { KeepTogether = true }) { Style = CellStyle, } } }); var grid = new Grid().Cell(0, 0, new Label { FontSize = 12, Content = "По ценам закупочным:", }).Cell(0, 1, new Label { FontSize = 12, HorizontalAlignment = HorizontalAlignment.Right, Content = sum?.ToString("0.00"), }).Cell(0, 2, new Label { FontSize = 12, Content = RusCurrency.Str((double)sum), }).Cell(1, 0, new Label { FontSize = 12, Content = "По ценам розничным:", }).Cell(1, 1, new Label { FontSize = 12, HorizontalAlignment = HorizontalAlignment.Right, Content = retailSum?.ToString("0.00"), }).Cell(1, 2, new Label { FontSize = 12, Content = RusCurrency.Str((double)retailSum), }).Cell(2, 0, new Label { FontSize = 12, Content = "Сумма розничной наценки:", }).Cell(2, 1, new Label { FontSize = 12, HorizontalAlignment = HorizontalAlignment.Right, Content = (retailSum - sum)?.ToString("0.00"), }).Cell(2, 2, new Label { FontSize = 12, Content = RusCurrency.Str((double)(retailSum - sum)), }); doc.Blocks.Add(new BlockUIContainer(grid)); var captionGrid = new Grid(); captionGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); captionGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); var caption = new Grid().Cell(0, 0, new Label { FontSize = 12, Content = "Принял", }).Cell(0, 1, new Label { FontSize = 12, Content = $"{docSettings.Person1Position} {docSettings.Person1Name}", }).Cell(0, 2, new Label { FontSize = 12, Content = "______________________________", }).Cell(1, 0, new Label { FontSize = 12, Content = "Товар получен полностью", }).Cell(1, 1, new Label { FontSize = 12, Content = $"{docSettings.Person2Position} {docSettings.Person2Name}", }).Cell(1, 2, new Label { FontSize = 12, Content = "______________________________", }).Cell(2, 0, new Label { FontSize = 12, Content = "Кол-во и цены проверены", }).Cell(2, 1, new Label { FontSize = 12, Content = $"{docSettings.Person3Position} {docSettings.Person3Name}", }).Cell(2, 2, new Label { FontSize = 12, Content = "______________________________", }); captionGrid.Cell(0, 1, caption).HorizontalAlignment = HorizontalAlignment.Right; doc.Blocks.Add(new BlockUIContainer(captionGrid)); }
public string Convert(decimal fromValue) { return(RusCurrency.Str(fromValue, "RUR", false)); }
static public string RusCurrencyToString(double value, bool male, string seniorOne, string seniorTwo, string seniorFive, string juniorOne, string juniorTwo, string juniorFive) { return(RusCurrency.Str(value, male, seniorOne, seniorTwo, seniorFive, juniorOne, juniorTwo, juniorFive)); }
static public string RusCurrencyToString(double value, string currency) { return(RusCurrency.Str(value, currency.Trim())); }
//static public string RusCurrencyToString(double value) //{ // return RusCurrency.Str(value); //} static public string RusCurrencyToText(decimal value) { return(RusCurrency.Str(Convert.ToDouble(value))); }
protected override void BuildDoc() { Header($"\n Наименование организации: {settings.FullName}\n" + " Отдел:______________________________________________\n"); TwoColumns(); var left = Header("Требование №________________________\n" + "от \"_____\" _______________20__г\n" + "кому: ___________________________________\n" + "Основание отпуска________________________\n"); left.TextAlignment = TextAlignment.Center; Header($"Накладная № {docSettings.ProviderDocumentId} {waybill.SupplierName}\n" + $"от {docSettings.DocumentDate:d}\n" + $"Через кого {docSettings.OperatedBy}\n" + "Доверенность № _______от \"______\" ________20__г\n"); var columns = new[] { new PrintColumn("№ пп", 27), new PrintColumn("Наименование и краткая характеристика товара", 170, colSpan: 2), new PrintColumn("", 30), new PrintColumn("Серия товара", 50), new PrintColumn("Сертификат", 66), new PrintColumn("Срок годности", 60), new PrintColumn("Наименование", 124), new PrintColumn("Цена без НДС, руб", 56), new PrintColumn("Затребован.колич.", 56), new PrintColumn("Опт. надб. %", 32), new PrintColumn("Отпуск. цена пост-ка без НДС, руб", 56), new PrintColumn("НДС пост-ка, руб", 40), new PrintColumn("Отпуск. цена пост-ка с НДС, руб", 56), new PrintColumn("Розн. торг. надб. %", 33), new PrintColumn("Розн. цена. за ед., руб", 56), new PrintColumn("Кол-во", 36), new PrintColumn("Розн. сумма, руб", 56), }; var columnGrops = new[] { new ColumnGroup("Предприятие - изготовитель", 5, 6) }; var rows = lines.Select((l, i) => new object[] { ++i, l.Product, l.ActualVitallyImportant ? "ЖВ" : "", l.SerialNumber, l.Certificates, l.Period, $"{l.Producer} {l.Country}", l.ProducerCost, l.Quantity, l.SupplierPriceMarkup, l.SupplierCostWithoutNds, l.SupplierCost - l.SupplierCostWithoutNds, l.SupplierCost, l.RetailMarkup, l.RetailCost, l.Quantity, l.RetailSum }); BuildTable(rows, columns, columnGrops); var retailSum = lines.Sum(l => l.RetailSum); var block = Block("Продажная сумма: " + RusCurrency.Str((double)retailSum)); block.Inlines.Add(new Figure(new Paragraph(new Run(retailSum.ToString()))) { FontWeight = FontWeights.Bold, HorizontalAnchor = FigureHorizontalAnchor.ContentRight, Padding = new Thickness(0), Margin = new Thickness(0) }); var sum = waybill.DisplayedSum; block = Block("Сумма поставки: " + RusCurrency.Str((double)sum)); block.Inlines.Add(new Figure(new Paragraph(new Run(sum.ToString()))) { FontWeight = FontWeights.Bold, HorizontalAnchor = FigureHorizontalAnchor.ContentRight, Padding = new Thickness(0), Margin = new Thickness(0) }); TwoColumns(); Block($"Затребовал: {docSettings.ReqestedBy}\n\n" + "место печати подпись _________________\n\n" + "\" ____\" _______________20__г\n"); Block($"Отпустил: Сдал (выдал)________________{docSettings.SentBy}\n\n" + $"Получил:Принял(получил)______________{docSettings.GotBy}\n\n" + $"Руководитель учреждения_____________{settings.Director}\n\n" + $"Главный (старший)бухгалтер ________________{settings.Accountant}\n"); }