private void OpenTemplate() { word = new WordService(fPath + "\\" + FILE_NAME, false); word.FindReplace("[orderNumber]", waitingList.orderNumber); word.FindReplace("[orderDate]", waitingList.orderDate); word.FindReplace("[lotCode]", waitingList.lotCode + " (" + waitingList.sourceNumber + ")"); word.FindReplace("[lotCode]", waitingList.lotCode); // Fill table var iCount = 1; string[] sCompany; foreach (var item in waitingList.waitingListTable) { if (iCount != 1) { word.AddTableRow(1); word.AddTableRow(2); } word.SetCell(1, iCount + 1, 1, iCount.ToString()); // Number word.SetCell(1, iCount + 1, 2, item.company); // Companies word.SetCell(1, iCount + 1, 3, item.bankReq); // Requisites word.SetCell(1, iCount + 1, 4, item.location); // Location sCompany = item.company.Split('\n'); word.SetCell(2, iCount, 1, iCount + ") " + sCompany[1]); iCount++; } }
// Paste info to file private int FillFileWithData() { try { word.FindReplace("[brokerName]", invoice.brokerName); word.FindReplace("[brokerIIK]", invoice.brokerIIK); word.FindReplace("[brokerKbe]", invoice.brokerKbe); word.FindReplace("[brokerBIN]", invoice.brokerBIN); word.FindReplace("[brokerBankName]", invoice.brokerBankName); word.FindReplace("[brokerBIK]", invoice.brokerBIK); word.FindReplace("[payCode]", invoice.payCode); word.FindReplace("[invoiceNumber]", invoice.invoiceNumber); word.FindReplace("[invoiceDate]", invoice.invoiceDate); word.FindReplace("[supplierName]", invoice.supplierName); word.FindReplace("[supplierBIN]", invoice.supplierBIN); word.FindReplace("[supplierAddress]", invoice.supplierAddress); word.FindReplace("[buyerName]", invoice.buyerName); word.FindReplace("[buyerBIN]", invoice.buyerBIN); word.FindReplace("[buyerAddress]", invoice.buyerAddress); word.FindReplace("[contractNum]", invoice.contractNumber); word.FindReplace("[contractDate]", invoice.contractDate); var tSum = Convert.ToDecimal(invoice.invoiceSum); var tBSum = Convert.ToDecimal(invoice.invoiceBrokerSum); var aSum = Convert.ToDecimal(invoice.invoiceSum) + Convert.ToDecimal(invoice.invoiceBrokerSum); if (type != 1) { word.SetCell(3, 2, 1, "1"); word.SetCell(3, 2, 3, "Брокерские услуги"); word.SetCell(3, 2, 5, "услуга"); word.SetCell(3, 2, 6, Math.Round(tSum, 0) + ",00"); word.SetCell(3, 2, 7, Math.Round(tSum, 0) + ",00"); word.FindReplace("[count]", "1"); aSum = tSum; } else { word.AddTableRow(3); word.SetCell(3, 2, 1, "1"); word.SetCell(3, 2, 3, "Гарантийное обеспечение за участие в аукционе №" + invoice.auctionNumber); word.SetCell(3, 2, 6, Math.Round(tSum, 0) + ",00"); word.SetCell(3, 2, 7, Math.Round(tSum, 0) + ",00"); word.SetCell(3, 3, 1, "2"); word.SetCell(3, 3, 3, "Открытие и ведение счета на товарной бирже"); word.SetCell(3, 3, 4, "1"); word.SetCell(3, 3, 5, "тг."); word.SetCell(3, 3, 6, Math.Round(tBSum, 0) + ",00"); word.SetCell(3, 3, 7, Math.Round(tBSum, 0) + ",00"); word.FindReplace("[count]", "2"); } word.FindReplace("[invoiceSum]", Math.Round(aSum, 0) + ",00"); word.FindReplace("[invoiceSum]", Math.Round(aSum, 0) + ",00"); word.FindReplace("[ndsSum]", Math.Round((aSum * 12 / 112), 2).ToString()); } catch (Exception ex) { Debug.WriteLine(ex.Message); return(0); } return(1); }
private static string FillTemplateFile() { word = new WordService(orderFileName, false); try { // Header word.FindReplace("[orderNumber]", orderInfo.Auction.Number); word.FindReplace("[customer]", orderInfo.Auction.Customer); word.FindReplace("[broker]", (orderInfo.Auction.Broker.Code == "ALTK" ? "Альта и К" : orderInfo.Auction.Broker.Code == "ALTA" ? "Альтаир-Нур" : "Корунд-777")); word.FindReplace("[type]", orderInfo.Auction.Type); word.FindReplace("[auctionDate]", orderInfo.Auction.Date.ToShortDateString()); // Table int rowCount = 2; decimal fullSum = 0; foreach (var item in orderInfo.Auction.Lots) { if (rowCount > 2) { word.AddTableRow(1); } word.SetCell(1, rowCount, 1, "1"); word.SetCell(1, rowCount, 2, item.Name); word.SetCell(1, rowCount, 3, Math.Round(item.Quantity, 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(1, rowCount, 4, item.Unit); word.SetCell(1, rowCount, 5, Math.Round(item.Price, 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(1, rowCount, 6, Math.Round((item.Quantity * item.Price), 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(1, rowCount, 7, Math.Round(item.Step, 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(1, rowCount, 8, item.DeliveryPlace); word.SetCell(1, rowCount, 9, item.PaymentTerm); word.SetCell(1, rowCount, 10, Math.Round(item.Warranty, 1).ToString(CultureInfo.InvariantCulture)); word.SetCell(1, rowCount, 11, Math.Round(item.LocalContent, 0).ToString(CultureInfo.InvariantCulture)); fullSum += Math.Round((item.Quantity * item.Price), 2); rowCount++; } word.SetCell(1, rowCount + 1, 6, fullSum.ToString()); // Footer (requisites) word.FindReplace("[executorName]", orderInfo.Initiator); word.SaveAsPDF(orderFileName); word.CloseDocument(true); word.CloseWord(true); Service.DeleteFile(orderFileName); return(orderFileName.Replace(".docx", ".pdf")); } catch (Exception) { return(null); } }
public static bool FillMembers(string templateFileName, List <SupplierOrder> members) { if (string.IsNullOrEmpty(templateFileName) || members == null || members.Count < 1) { return(false); } var word = new WordService(templateFileName, false); if (word == null) { return(false); } try { int rowCount = 2; foreach (var item in members) { if (rowCount > 2) { word.AddTableRow(1); } word.SetCell(1, rowCount, 1, (rowCount - 1).ToString()); word.SetCell(1, rowCount, 2, item.Name != null ? item.Name : ""); word.SetCell(1, rowCount, 3, item.BrokerName != null ? item.BrokerName : ""); } } catch { return(false); } finally { if (word.IsOpenDocument()) { word.CloseDocument(); } if (word.IsOpenWord()) { word.CloseWord(false); } } return(true); }
private static void FillApplicantsTable(WordService word, List <SupplierOrder> applicants, int tableNumber) { int iCount = 1; int rowCount = 2; foreach (var item in applicants) { if (iCount > 2) { word.AddTableRow(tableNumber); } word.SetCell(tableNumber, rowCount, 1, iCount.ToString()); word.SetCell(tableNumber, rowCount, 2, item.Name != null ? item.Name : ""); iCount += 1; rowCount += 1; } }
private static void FillTemplate(int mode) { // Open template file for filling word = new WordService(fileName, false); switch (mode) { case 1: // Single // Fill file with data word.FindReplace("[brokerName]", order.Auction.SupplierOrders[0].BrokerName); word.SetCell(1, 2, 1, order.Auction.SupplierOrders[0].BrokerCode); word.SetCell(1, 2, 2, order.Auction.SupplierOrders[0].Code); word.SetCell(1, 2, 3, order.Auction.Lots[0].Number); word.SetCell(1, 2, 4, (Math.Round(sum, 2)).ToString()); word.FindReplace("[curDate]", DateTime.Now.ToShortDateString()); break; case 2: // Multi word.FindReplace("[brokerName]", broker); int iRow = 2; foreach (var item in moneyTransferList) { word.SetCell(1, iRow, 1, item.fromCompany); word.SetCell(1, iRow, 2, item.toCompany); word.SetCell(1, iRow, 3, item.lotNumber); word.SetCell(1, iRow, 4, (Math.Round(sum, 2)).ToString()); word.AddTableRow(1); iRow++; } word.FindReplace("[curDate]", DateTime.Now.ToShortDateString()); break; } // Close file & save word.CloseDocument(true); word.CloseWord(true); }
private void OpenTemplate() { word = new WordService(fPath + "\\" + FILE_NAME, false); word.FindReplace("[brokerName]", moneyTransferList[0].brokerName); var iCount = 1; foreach (var item in moneyTransferList) { if (iCount != 1) { word.AddTableRow(1); } word.SetCell(1, iCount + 1, 1, item.fromCompany); word.SetCell(1, iCount + 1, 2, item.toCompany); word.SetCell(1, iCount + 1, 3, item.lotNumber); word.SetCell(1, iCount + 1, 4, item.sum); iCount++; } }
private static void FillInvoice(bool isWarranty, InvoicePrint invoicePrint, string invoiceNumber, InvoiceEx invoiceEx = null) { string[] currencyType = new string[2]; word = new WordService(fileName, false); try { word.FindReplace("[brokerName]", order.Auction.SupplierOrders[0].BrokerName); word.FindReplace("[brokerKbe]", order.Auction.SupplierOrders[0].BrokerKbe); word.FindReplace("[brokerBIN]", order.Auction.SupplierOrders[0].BrokerBIN); word.FindReplace("[brokerBankName]", order.Auction.SupplierOrders[0].BrokerBankName); word.FindReplace("[brokerBIK]", order.Auction.SupplierOrders[0].BrokerBIK); word.FindReplace("[payCode]", isWarranty ? "171" : "859"); word.FindReplace("[invoiceNumber]", invoiceNumber); word.FindReplace("[invoiceDate]", isWarranty ? DateTime.Now.ToShortDateString() : order.Auction.Date.ToShortDateString()); word.FindReplace("[supplierName]", order.Auction.SupplierOrders[0].BrokerName); word.FindReplace("[supplierBIN]", order.Auction.SupplierOrders[0].BrokerBIN); word.FindReplace("[supplierAddress]", order.Auction.SupplierOrders[0].BrokerAddress); word.FindReplace("[buyerName]", order.Auction.SupplierOrders[0].Name); word.FindReplace("[buyerBIN]", order.Auction.SupplierOrders[0].BIN); word.FindReplace("[buyerAddress]", order.Auction.SupplierOrders[0].Address); word.FindReplace("[contractNum]", "№" + order.Auction.SupplierOrders[0].ContractNum); word.FindReplace("[contractDate]", order.Auction.SupplierOrders[0].ContractDate.ToShortDateString()); word.SetCell(3, 2, 1, "1"); if (isWarranty) { word.SetCell(3, 2, 3, "Гарантийное обеспечение за участие в аукционе №" + order.Auction.Number + " от " + order.Auction.Date.ToShortDateString()); } else { word.SetCell(3, 2, 3, "Брокерские услуги за участие в аукционе №" + order.Auction.Number + " от " + order.Auction.Date.ToShortDateString()); } if (order.Auction.SiteId == 4) { word.AddTableRow(3); word.SetCell(3, 3, 1, "2"); word.SetCell(3, 3, 3, "Открытие и ведение счета на товарной бирже"); word.SetCell(3, 3, 4, "1"); word.SetCell(3, 3, 5, "шт."); word.SetCell(3, 3, 6, invoiceEx.Services[1].Price.ToString()); word.SetCell(3, 3, 7, invoiceEx.Services[1].Аmount.ToString()); } word.SetCell(3, 2, 6, invoicePrint.Price); word.SetCell(3, 2, 7, invoicePrint.Аmount); word.FindReplace("[count]", order.Auction.SiteId == 4 ? "2" : "1"); if (order.Auction.SiteId == 4) { if (order.Auction.SupplierOrders[0].BIN == "141040012412") { invoicePrint.Total = (invoiceEx.Services[0].Аmount + invoiceEx.Services[1].Аmount).ToString(); } else { invoicePrint.Total = (invoiceEx.Services[0].Аmount + invoiceEx.Services[1].Аmount).ToString() + ",00"; } if (order.Auction.SupplierOrders[0].BrokerName.ToUpper().Contains("АЛТЫН")) { invoicePrint.TotalTax = ""; } else { invoicePrint.TotalTax = ((invoiceEx.Services[0].Аmount + invoiceEx.Services[1].Аmount) * 12 / 112).ToString(); } } word.FindReplace("[invoiceSum]", invoicePrint.Total); word.FindReplace("[ndsSum]", invoicePrint.TotalTax); word.FindReplace("[invoiceSum]", invoicePrint.Total); if (invoicePrint.АmountInWords.Contains("тиын")) { word.FindReplace("[currency]", "KZT"); currencyType[0] = " тенге"; currencyType[1] = " тиын"; if (order.Auction.SupplierOrders[0].BrokerName.ToUpper().Contains("КОРУНД")) { word.FindReplace("[brokerIIK]", order.Auction.SupplierOrders[0].BrokerIIK); } else { word.FindReplace("[brokerIIK]", order.Auction.SupplierOrders[0].BrokerIIK); } } else if (invoicePrint.АmountInWords.Contains("копеек")) { word.FindReplace("[currency]", "RUB"); currencyType[0] = " рублей"; currencyType[1] = " копеек"; if (order.Auction.SupplierOrders[0].BrokerName.ToUpper().Contains("КОРУНД")) { word.FindReplace("[brokerIIK]", "KZ739261802171874002"); } else { word.FindReplace("[brokerIIK]", order.Auction.SupplierOrders[0].BrokerIIK); } } else if (invoicePrint.АmountInWords.Contains("центов")) { word.FindReplace("[currency]", "USD"); currencyType[0] = " долларов"; currencyType[1] = " центов"; if (order.Auction.SupplierOrders[0].BrokerName.ToUpper().Contains("КОРУНД")) { word.FindReplace("[brokerIIK]", "KZ039261802171874001"); } else { word.FindReplace("[brokerIIK]", order.Auction.SupplierOrders[0].BrokerIIK); } } if (order.Auction.SiteId == 4) { invoicePrint.АmountInWords = "Всего к оплате: " + ConvertNumberToWord(Convert.ToInt32(invoiceEx.Services[0].Аmount + invoiceEx.Services[1].Аmount)) + currencyType[0] + ",00" + currencyType[1]; } word.FindReplace("[amountInWords]", invoicePrint.АmountInWords); } catch (Exception ex) { Debug.WriteLine("Err:" + ex); } word.SaveAsPDF(fileName); word.CloseDocument(true); word.CloseWord(true); }
private static void FillDocument() { // Variables decimal fullDebet = reconcilationReport.Sum(r => r.debit); decimal fullCredit = reconcilationReport.Sum(r => r.credit); // Open office word = new WordService(fileName, false); // Fill document word.FindReplace("[startDate]", startDate.ToShortDateString()); word.FindReplace("[endDate]", endDate.ToShortDateString()); word.FindReplace("[broker]", broker.Name); word.FindReplace("[client]", supplier.Name); word.FindReplace("[broker]", broker.Name); word.FindReplace("[client]", supplier.Name); word.FindReplace("[broker]", broker.Name); word.FindReplace("[client]", supplier.Name); word.FindReplace("[startDate]", startDate.ToShortDateString()); word.FindReplace("[startDate]", startDate.ToShortDateString()); int iRow = 4; string debit = "", credit = "", fDebit = "", fCredit = ""; foreach (var item in reconcilationReport) { word.AddTableRow(1, iRow); debit = $"{item.debit:C}"; credit = $"{item.credit:C}"; word.SetCell(1, iRow, 1, item.docDate); word.SetCell(1, iRow, 2, item.docName); word.SetCell(1, iRow, 3, debit.Substring(0, debit.Length - 2)); word.SetCell(1, iRow, 4, credit.Substring(0, credit.Length - 2)); iRow++; } iRow += 3; if (fullDebet > fullCredit) { string fullSum = $"{(fullDebet - fullCredit):C}"; fullSum = fullSum.Substring(0, fullSum.Length - 2); word.SetCell(1, iRow, 2, fullSum); word.FindReplace("[status]", "в пользу " + broker.Name + " " + fullSum); } else { string fullSum = $"{(fullCredit - fullDebet):C}"; fullSum = fullSum.Substring(0, fullSum.Length - 2); word.SetCell(1, iRow, 3, fullSum); word.FindReplace("[status]", "в пользу " + supplier.Name + " " + fullSum); } fDebit = $"{fullDebet:C}"; fCredit = $"{fullCredit:C}"; word.FindReplace("[fullDebet]", fDebit.Substring(0, fDebit.Length - 2)); word.FindReplace("[fullCredit]", fCredit.Substring(0, fCredit.Length - 2)); word.FindReplace("[endDate]", endDate.ToShortDateString()); word.FindReplace("[endDate]", endDate.ToShortDateString()); word.FindReplace("[broker]", broker.Name); word.FindReplace("[endDate]", endDate.ToShortDateString()); word.FindReplace("[broker]", broker.Name); word.FindReplace("[client]", supplier.Name); word.FindReplace("[brokerBin]", broker.Requisites); word.FindReplace("[clientBin]", supplier.BIN); // Close office word.CloseDocument(true); word.CloseWord(true); }
private static void FillTemplate(string procuratoryFileName, Order order, List <Lot> prices = null, int[] tableNumbers = null, string orderApplicant = null) { WordService word = new WordService(procuratoryFileName, false); try { word.SetCell(1, 2, 2, DateTime.Now.ToShortDateString()); word.SetCell(1, 4, 2, order.Auction.Date.ToShortDateString()); word.SetCell(1, 5, 2, "Заявка № " + order.Auction.Number); word.SetCell(1, 6, 2, order.Auction.SupplierOrders[0].BrokerName.Replace("Товарищество с ограниченной ответственностью", "ТОО")); word.SetCell(1, 7, 2, order.Auction.SupplierOrders[0].BrokerCode); word.SetCell(1, 8, 2, order.Auction.SupplierOrders[0].Name); word.SetCell(1, 9, 2, order.Auction.SupplierOrders[0].Code); int rCount = 0, iCount = 1; foreach (var item in order.Auction.Lots) { word.SetCell(1, 11 + rCount, 3, "Цена лота (стартовая - " + Math.Round(item.Sum, 2).ToString() + ")"); word.SetCell(1, 12 + rCount, 1, item.Number); word.SetCell(1, 12 + rCount, 2, "Лот №" + iCount); if (prices != null && prices.Any(p => p.Id == item.Id)) { word.SetCell(1, 12 + rCount, 3, prices.First(p => p.Id == item.Id).Sum.ToString()); word.SetItalicInCell(1, 12 + rCount, 3, 0); word.SetTextColorInCell(1, 12 + rCount, 3); } else { word.SetItalicInCell(1, 12 + rCount, 3, 1); word.SetCell(1, 12 + rCount, 3, "Введите пожалуйста сумму с учетом понижения"); } iCount++; rCount += 2; if (rCount > 16) { word.AddTableRow(1, rCount - 1); word.AddTableRow(1, rCount - 1); } } } catch (Exception) { } try { word.FindReplace("[commissionDateIn]", DateTime.Now.ToShortDateString()); word.FindReplace("[commissionTimeIn]", "11:00"); word.FindReplace("[brokerPerson]", order.Auction.Trader); } catch (Exception) { } // Paste tech spec table if (tableNumbers != null) { foreach (var item in tableNumbers) { try { GetTechSpec(item, orderApplicant); } catch (Exception) { } Thread.Sleep(4000); try { word.PasteInTheBookmark("table"); } catch (Exception) { } } } word.AutoFitTables(); word.CloseDocument(true); word.CloseWord(true); }
private static void FillTemplateForUTB(Order order, string fileName, bool withPDF = false) { WordService word = new WordService(fileName, false); word.FindReplace("[orderNumber]", order.Auction.Number + " от " + order.Date.ToShortDateString()); word.SetCell(1, 1, 2, order.Auction.SupplierOrders[0].Name); word.SetCell(1, 3, 2, order.Auction.Date.ToString("dd.MM.yyyy")); word.SetCell(1, 4, 2, order.Auction.Customer); word.FindReplace("[clientName]", order.Auction.SupplierOrders[0].Name); word.FindReplace("[clientName]", order.Auction.SupplierOrders[0].Name); word.FindReplace("[companyDirector]", string.IsNullOrEmpty(order.Auction.SupplierOrders[0].CompanyDirector) ? "[Впишите ФИО Директора компании]" : order.Auction.SupplierOrders[0].CompanyDirector); word.FindReplace("[brokerName]", order.Auction.SupplierOrders[0].BrokerName); word.FindReplace("[clientName]", order.Auction.SupplierOrders[0].Name); word.FindReplace("[traderName]", order.Auction.SupplierOrders[0].Trader); int iCount = 2; decimal sum = 0; decimal minimalPrice = 0; // Early getted from inside foreach (var item in order.Auction.Lots) { if (iCount > 2) { word.AddTableRow(2); } word.SetCell(2, iCount, 1, (iCount - 1).ToString()); word.SetCell(2, iCount, 2, item.Number); word.SetCell(2, iCount, 3, item.Name); word.SetCell(2, iCount, 4, item.Unit); word.SetCell(2, iCount, 5, item.Quantity.ToString(CultureInfo.InvariantCulture)); if (order.Auction.SiteId != 4 && order.Auction.Customer.ToLower().Contains("караж")) { word.SetCell(2, iCount, 6, Math.Round(minimalPrice / item.Quantity, 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(2, iCount, 7, Math.Round(minimalPrice, 2).ToString(CultureInfo.InvariantCulture)); sum += minimalPrice; } else { word.SetCell(2, iCount, 6, Math.Round(item.Sum / item.Quantity, 2).ToString(CultureInfo.InvariantCulture)); word.SetCell(2, iCount, 7, Math.Round(item.Sum * item.Quantity, 2).ToString(CultureInfo.InvariantCulture)); sum += item.Sum; } word.SetCell(2, iCount, 8, item.PaymentTerm); word.SetCell(2, iCount, 9, item.DeliveryPlace.Replace("|", ", ") + ", " + item.DeliveryTime); iCount++; } word.FindReplace("[sum]", Math.Round(sum, 2).ToString(CultureInfo.InvariantCulture)); word.FindReplace("[brokerDirector]", order.Auction.SupplierOrders[0].Trader); if (withPDF) { word.SaveAsPDF(fileName); } word.CloseDocument(true); word.CloseWord(true); }
public bool CreateKaspiReport(string templateFileName, Order order, List <PriceOffer> priceOffers, string accountNumber, string finalPriceOffer) { if (string.IsNullOrEmpty(templateFileName) || order == null || order.Auction == null || order.Auction.Lots == null || order.Auction.Lots.Count < 1 || order.Auction.Lots[0].LotsExtended == null || order.Auction.Lots[0].LotsExtended.Count < 1 || order.Auction.SupplierOrders == null || order.Auction.SupplierOrders.Count < 1 || priceOffers == null || priceOffers.Count < 1) { return(false); } var word = new WordService(templateFileName, false); if (word == null) { return(false); } try { word.FindReplace("[accountNumber]", accountNumber != null ? accountNumber : ""); word.FindReplace("[auctionType]", order.Auction.Type != null ? order.Auction.Type : ""); word.FindReplace("[brokerCustomer]", order.Organizer != null ? order.Organizer : ""); word.FindReplace("[auctionDate]", order.Auction.Date != null ? order.Auction.Date.ToString() : ""); word.FindReplace("[productName]", order.Auction.Lots[0].Name != null ? order.Auction.Lots[0].Name : ""); word.FindReplace("[lotName]", order.Auction.Lots[0].Name != null ? order.Auction.Lots[0].Name : ""); var supplierOrderWinner = order.Auction.SupplierOrders.FirstOrDefault(s => s.status.Id == 23); word.FindReplace("[brokerSupplier]", supplierOrderWinner != null ? supplierOrderWinner.BrokerName != null ? supplierOrderWinner.BrokerName : "" : ""); word.FindReplace("[startPrice]", order.Auction.Lots[0].Price != null ? order.Auction.Lots[0].Price.ToString() : ""); word.FindReplace("[finalPriceOffer]", finalPriceOffer != null ? finalPriceOffer : ""); word.FindReplace("[productsCount]", order.Auction.Lots[0].LotsExtended.Count > 1 ? "Согласно спецификации" : order.Auction.Lots[0].Quantity != null ? order.Auction.Lots[0].Quantity.ToString() : ""); int rowCount = 2; foreach (var item in order.Auction.SupplierOrders) { if (rowCount > 2) { word.AddTableRow(1); } word.SetCell(1, rowCount, 1, item.Name != null ? item.Name : ""); word.SetCell(1, rowCount, 2, item.date != null ? item.date.ToString() : ""); rowCount += 1; } rowCount = 2; foreach (var item in priceOffers) { if (rowCount > 2) { word.AddTableRow(2); } word.SetCell(2, rowCount, 1, (rowCount - 1).ToString()); word.SetCell(2, rowCount, 1, item.firmName != null ? item.firmName : ""); word.SetCell(2, rowCount, 1, item.lotPriceOffer != null ? item.lotPriceOffer : ""); word.SetCell(2, rowCount, 1, item.offerTime != null ? item.offerTime.ToString() : ""); rowCount += 1; } word.CloseDocument(true); word.CloseWord(true); } catch { if (word.IsOpenDocument()) { word.CloseDocument(false); } if (word.IsOpenWord()) { word.CloseWord(false); } return(false); } return(true); }
private static void FillTemplate(int mode) { word = new WordService(fileName, false); if (mode == 1) // UTB { var iCount = 1; word.FindReplace("[auctionDate]", order.Auction.Date.ToShortDateString()); word.FindReplace("[auctionNumber]", order.Auction.Number); foreach (var item in order.Auction.SupplierOrders) { word.SetCell(1, iCount, 1, iCount + ". " + item.Name); word.SetCell(2, iCount, 1, iCount + ". " + item.Name); iCount++; word.AddTableRow(1); word.AddTableRow(2); } } else // ETS { word.FindReplace("[orderDate]", DateTime.Now.ToShortDateString()); word.FindReplace("[lotCode]", order.Auction.Lots[0].Number); word.FindReplace("[orderNumber]", order.Auction.Number); word.FindReplace("[lotCode]", order.Auction.Lots[0].Number); int iCount = 1; foreach (var item in order.Auction.SupplierOrders) { if (iCount != 1) { word.AddTableRow(1); } word.SetCell(1, iCount + 1, 1, iCount.ToString()); word.SetCell(1, iCount + 1, 2, "Код клиента: " + item.Code + " -\n" + ConvertToShortName(item.Name) + "\n\nКод брокера: " + item.BrokerCode + " -\n" + ConvertToShortName(item.BrokerName)); word.SetCell(1, iCount + 1, 3, "БИН " + item.BIN + "\n" + item.BankName + "\nБИК " + item.BIK + " Кбе " + item.Kbe + "\n" + item.IIK); word.SetCell(1, iCount + 1, 4, item.Address); iCount++; } if (!forCustomer) { iCount = 1; foreach (var item in notAllowed) { if (iCount != 1) { word.AddTableRow(2); } word.SetCell(2, iCount + 1, 1, iCount.ToString()); word.SetCell(2, iCount + 1, 2, "Код брокера: " + item.BrokerCode + " -\n" + ConvertToShortName(item.BrokerName)); word.SetCell(2, iCount + 1, 3, item.Name + "\nБИН: " + item.BIN + "\nАдрес: " + item.Address + "\nТелефоны: " + item.Phones); iCount++; } } } word.SaveAsPDF(fileName); word.CloseDocument(true); word.CloseWord(true); }