コード例 #1
0
        public void GetInfoForAttachDocument()
        {
            // Show path to client order attach and open them
            word = new WordService(GetPathWithOrderAttach(), false);

            // Find table with technic specification
            var tCount = word.GetTablesCount();

            for (var iCount = 1; iCount <= tCount; iCount++)
            {
                if (word.GetCell(iCount, 1, 1).Contains("Техническая") || word.GetCell(iCount, 2, 1).Contains("Техническая"))
                {
                    // Delete first two rows
                    word.DeleteTableRows(iCount, new int[2] {
                        1, 1
                    });

                    // Copy left table
                    word.CopyTable(iCount);
                    break;
                }
            }

            // Close order attach
            word.CloseDocument(false);
            word.CloseWord(false);
        }
コード例 #2
0
        private void CloseTemplate()
        {
            word.CloseDocument(true);
            word.CloseWord(true);

            RenameFile();
        }
コード例 #3
0
        public static void CreateReport(string template, Report report, int type)
        {
            archiveManager = new ArchiveManager(dataManager);
            var service = new WordService(template, false);

            service = type == 2 ? InsertIntoSupplierReport(report, service) : InsertIntoClientReport(report, service);
            var fileListId = DataBaseClient.GetFileListAuctionByLot(report.Code);

            if (fileListId != null)
            {
                DocumentRequisite docReq = new DocumentRequisite()
                {
                    date     = fileListId.date,
                    fileName = template.Substring(template.LastIndexOf("\\") + 1),
                    market   = AltaBO.specifics.MarketPlaceEnum.ETS,
                    number   = fileListId.number,
                    section  = AltaBO.specifics.DocumentSectionEnum.Auction,
                    type     = type == 2 ? AltaBO.specifics.DocumentTypeEnum.SupplierReport : AltaBO.specifics.DocumentTypeEnum.CustomerReport
                };

                archiveManager.SaveFile(docReq, (int)fileListId.fileslistid);
                docReq.fileName = docReq.fileName.Replace(".docx", ".pdf");
                archiveManager.SaveFile(docReq, (int)fileListId.fileslistid);
            }

            service.SaveAsPDF(template);
            service.CloseDocument(true);
            service.CloseWord(true);
        }
コード例 #4
0
        private void PasteInfoToCommissionDoc()
        {
            // Open commission template to fill
            word = new WordService(path + "\\" + FILE_NAME_COMMISSION, false);

            // Fill commisiion
            word.SetCell(1, 2, 2, stockDealInfo.ComDateOut.ToShortDateString());
            word.SetCell(1, 4, 2, auctionDate);
            word.SetCell(1, 5, 2, "Заявка № " + auctionNumber);
            word.SetCell(1, 6, 2, stockDealInfo.MemberName);
            word.SetCell(1, 7, 2, stockDealInfo.MemberCode);
            word.SetCell(1, 8, 2, stockDealInfo.SupplierName);
            word.SetCell(1, 9, 2, stockDealInfo.SupplierCode);
            word.SetCell(1, 12, 1, stockDealInfo.LotCode);
            word.SetCell(1, 25, 1, stockDealInfo.ComDateIn.ToShortDateString());
            word.SetCell(1, 25, 2, stockDealInfo.ComDateIn.ToLongTimeString());
            word.SetCell(1, 25, 3, stockDealInfo.Employe);

            // Paste table
            word.PasteBookmark("table");

            // Fit tables in document
            word.AutoFitTables();

            // Fill lefted info
            word.FindReplace("[startPrice]", word.GetCell(2, word.FindTextInRow(2, "ИТОГО", 2), 6));

            // Close and save commission
            word.CloseDocument(true);
            word.CloseWord(true);

            System.IO.File.Move(path + "\\" + FILE_NAME_COMMISSION, path + "\\" + "Поручение на сделку по лоту - " + stockDealInfo.LotCode + " - у клиента - " + stockDealInfo.SupplierName + " " + DateTime.Now.ToString().Replace(":", "_") + ".docx");
        }
コード例 #5
0
        private static void FillTemplateFile()
        {
            word = new WordService(orderFileName, false);

            try {
                word.FindReplace("[orderNumber]", orderInfo.Title);
                word.FindReplace("[auctionDate]", orderInfo.Auction.Date.ToShortDateString());

                word.SetCell(1, 2, 1, "1");
                word.SetCell(1, 2, 2, lotInfo.description);
                word.SetCell(1, 2, 3, lotInfo.amount.ToString(CultureInfo.InvariantCulture));
                word.SetCell(1, 2, 4, DataBaseClient.ReadUnitInfo(lotInfo.unitid).name);
                word.SetCell(1, 2, 5, lotInfo.price.ToString(CultureInfo.InvariantCulture));
                word.SetCell(1, 2, 6, lotInfo.sum.ToString(CultureInfo.InvariantCulture));
                word.SetCell(1, 2, 7, lotInfo.step.ToString(CultureInfo.InvariantCulture));
                word.SetCell(1, 2, 8, lotInfo.deliveryplace);
                word.SetCell(1, 2, 9, lotInfo.paymentterm);
                word.SetCell(1, 2, 10, lotInfo.warranty.ToString(CultureInfo.InvariantCulture));
                word.SetCell(1, 2, 11, lotInfo.localcontent.ToString());
                word.SetCell(1, 3, 6, lotInfo.sum.ToString(CultureInfo.InvariantCulture));
            } catch (Exception) {
                // ignored
            }

            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #6
0
 public override void Close()
 {
     excel.CloseWorkbook(false);
     excel.CloseExcel();
     word.CloseDocument(true);
     word.CloseWord(true);
 }
コード例 #7
0
        private static void FillTemplate()
        {
            word = new WordService(protocolsFileName, false);

            var winApplicant = order.Auction.SupplierOrders[0].Name.ToUpper().Contains("АЛТЫН") ? 1 : 0;

            decimal minimalPrice = order.Auction.Procuratories[0].MinimalPrice < order.Auction.Procuratories[1].MinimalPrice ? order.Auction.Procuratories[0].MinimalPrice : order.Auction.Procuratories[1].MinimalPrice;

            word.FindReplace("[auctionDate]", order.Auction.Date.ToShortDateString());
            word.FindReplace("[amount]", Math.Round(order.Auction.Lots[0].Sum, 2).ToString());
            word.FindReplace("[supplier1]", order.Auction.SupplierOrders[0].Name);
            word.FindReplace("[supplier2]", order.Auction.SupplierOrders[1].Name);
            word.FindReplace("[winningPrice]", Math.Round(minimalPrice, 2).ToString());
            word.SetCell(1, 17, 1, "1");
            word.SetCell(1, 17, 2, order.Auction.Lots[0].Number);
            word.SetCell(1, 17, 3, order.Auction.Lots[0].Name);
            word.SetCell(1, 17, 4, order.Auction.Lots[0].Unit);
            word.SetCell(1, 17, 5, Math.Round(order.Auction.Lots[0].Quantity, 2).ToString());
            word.SetCell(1, 17, 6, Math.Round(minimalPrice / order.Auction.Lots[0].Quantity, 2).ToString());
            word.SetCell(1, 17, 7, Math.Round(minimalPrice, 2).ToString());
            word.SetCell(1, 17, 8, order.Auction.Lots[0].PaymentTerm);
            word.SetCell(1, 17, 9, order.Auction.Lots[0].DeliveryTime + ", " + order.Auction.Lots[0].DeliveryPlace.Replace("|", ", "));
            word.SetCell(1, 18, 7, Math.Round(minimalPrice, 2).ToString());
            word.FindReplace("[supplier]", order.Auction.SupplierOrders[winApplicant].Name);
            word.FindReplace("[supplierBroker]", order.Auction.SupplierOrders[winApplicant].BrokerName);
            word.FindReplace("[broker]", order.Auction.SupplierOrders[winApplicant].BrokerName.Replace("Товарищество с ограниченной ответственностью", "ТОО"));

            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #8
0
        public static List <LotsExtended> ParseOrderWithTS(string fileName, int lotId)
        {
            WordService word = new WordService(fileName, false);

            if (word.GetTablesCount() == 0)
            {
                return(null);
            }

            List <LotsExtended> lotsExtended = new List <LotsExtended>();
            int tablesCount = word.GetTablesCount();

            for (var tCount = 1; tCount <= tablesCount; tCount++)
            {
                int    rowCount = word.GetTableRowsCount(tCount);
                string valueLeft = "", valueRight = "";

                for (var rCount = tCount == 1 ? 2 : 1; rCount < rowCount + 1; rCount++)
                {
                    bool getValue = true;

                    try {
                        valueLeft  = word.GetCell(tCount, rCount, 1);
                        valueRight = word.GetCell(tCount, rCount, 12);
                    } catch { getValue = false; }

                    if (getValue && (string.IsNullOrEmpty(valueLeft.Replace("\r", "").Replace("\a", "")) || string.IsNullOrEmpty(valueRight.Replace("\r", "").Replace("\a", ""))))
                    {
                        getValue = false;
                    }

                    if (getValue)
                    {
                        lotsExtended.Add(new LotsExtended()
                        {
                            serialnumber   = Convert.ToInt32(word.GetCell(tCount, rCount, 1).Replace("\r", "").Replace("\a", "")),
                            name           = word.GetCell(tCount, rCount, 2).Replace("\r", "").Replace("\a", ""),
                            unit           = word.GetCell(tCount, rCount, 3).Replace("\r", "").Replace("\a", ""),
                            quantity       = Convert.ToDecimal(word.GetCell(tCount, rCount, 4).Replace("\r", "").Replace("\a", "").Replace(" ", "")),
                            price          = Convert.ToDecimal(word.GetCell(tCount, rCount, 5).Replace("\r", "").Replace("\a", "").Replace(" ", "")),
                            sum            = Convert.ToDecimal(word.GetCell(tCount, rCount, 6).Replace("\r", "").Replace("\a", "").Replace(" ", "")),
                            country        = word.GetCell(tCount, rCount, 7).Replace("\r", "").Replace("\a", ""),
                            techspec       = word.GetCell(tCount, rCount, 8).Replace("\r", "").Replace("\a", ""),
                            terms          = word.GetCell(tCount, rCount, 9).Replace("\r", "").Replace("\a", ""),
                            paymentterm    = word.GetCell(tCount, rCount, 10).Replace("\r", "").Replace("\a", ""),
                            dks            = Convert.ToInt32(Math.Round(Convert.ToDecimal(word.GetCell(tCount, rCount, 11).Replace("\r", "").Replace("\a", "").Replace("%", "")), 0)),
                            contractnumber = word.GetCell(tCount, rCount, 12).Replace("\r", "").Replace("\a", ""),
                            lotId          = lotId
                        });
                    }
                }
            }

            word.CloseDocument(false);
            word.CloseWord(false);

            return(lotsExtended);
        }
コード例 #9
0
        public static bool FillKaspiProcuratory(string templateFileName, Order order, string direction)
        {
            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)
            {
                return(false);
            }

            var word = new WordService(templateFileName, false);

            if (word == null)
            {
                return(false);
            }

            try {
                word.FindReplace("[brokerCompany]", "");
                word.FindReplace("[brokerDirector]", "");

                word.SetCell(1, 6, 3, direction != null ? direction : "Продажа/покупка");
                word.SetCell(1, 7, 3, order.Organizer != null ? order.Organizer : "");
                word.SetCell(1, 8, 3, order.Initiator != null ? order.Initiator : "");
                word.SetCell(1, 9, 3, order.Auction.Lots[0].Name != null ? order.Auction.Lots[0].Name : "");
                word.SetCell(1, 10, 3, order.Auction.Type != null ? order.Auction.Type : "");
                word.SetCell(1, 11, 3, order.Auction.Lots[0].LotsExtended[0].marka != null ? order.Auction.Lots[0].LotsExtended[0].marka : "");
                word.SetCell(1, 12, 3, order.Auction.Lots[0].LotsExtended[0].gost != null ? order.Auction.Lots[0].LotsExtended[0].gost : "");
                word.SetCell(1, 13, 3, order.Auction.Lots[0].CodeTRFEA != null ? order.Auction.Lots[0].CodeTRFEA : "");
                word.SetCell(1, 14, 3, order.Auction.Lots[0].LotsExtended[0].country != null ? order.Auction.Lots[0].LotsExtended[0].country : "");
                word.SetCell(1, 15, 3, order.Auction.Lots[0].LotsExtended[0].factory != null ? order.Auction.Lots[0].LotsExtended[0].factory : "");
                word.SetCell(1, 16, 3, order.Auction.Lots[0].LotsExtended.Count > 1 ? "Согласно спецификации" : (order.Auction.Lots[0].Quantity != null ? order.Auction.Lots[0].Quantity : 0).ToString());
                word.SetCell(1, 17, 3, order.Auction.Lots[0].LotsExtended.Count > 1 ? "Согласно спецификации" : (order.Auction.Lots[0].Unit != null ? order.Auction.Lots[0].Unit : ""));
                word.SetCell(1, 18, 3, order.Auction.Lots[0].LotsExtended.Count > 1 ? "Согласно спецификации" : (order.Auction.Lots[0].Price != null ? order.Auction.Lots[0].Price : 0).ToString());
                word.SetCell(1, 19, 3, order.Auction.Comments != null ? order.Auction.Comments : ""); // currency
                word.SetCell(1, 20, 3, (order.Auction.Lots[0].Step != null ? order.Auction.Lots[0].Step : 0) + " " + word.GetCell(1, 19, 3));
                word.SetCell(1, 21, 3, order.Auction.Lots[0].DeliveryPlace != null ? order.Auction.Lots[0].DeliveryPlace : "");
                word.SetCell(1, 22, 3, order.Auction.Lots[0].LotsExtended[0].terms != null ? order.Auction.Lots[0].LotsExtended[0].terms : "");
                word.SetCell(1, 23, 3, order.Auction.Lots[0].PaymentTerm != null ? order.Auction.Lots[0].PaymentTerm : "");
                word.SetCell(1, 24, 3, order.Auction.Lots[0].DeliveryTime != null ? order.Auction.Lots[0].DeliveryTime : "");
                word.SetCell(1, 25, 3, order.Auction.Date != null ? order.Auction.Date.ToShortDateString() : "");
                word.SetCell(1, 26, 3, "Техническая спецификация");
                word.SetCell(1, 27, 3, order.Auction.Lots[0].LotsExtended[0].sum != null ? order.Auction.Lots[0].LotsExtended.Sum(l => l.sum).ToString() : "");
            } catch {
                return(false);
            } finally {
                if (word.IsOpenDocument())
                {
                    word.CloseDocument(true);
                }
                if (word.IsOpenWord())
                {
                    word.CloseWord(true);
                }
            }

            return(true);
        }
コード例 #10
0
        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); }
        }
コード例 #11
0
        private void FillAct()
        {
            word = new WordService(fName, false);

            word.FindReplace("[sourceNumber]", failedAct.sourceNumber);
            word.FindReplace("[fromDate]", failedAct.fromDate);
            word.FindReplace("[auctionDate]", failedAct.auctionDate);
            word.FindReplace("[orderNumber]", failedAct.orderNumber);

            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #12
0
        private static void GetTechSpec(int tableNumber, string orderApplicant)
        {
            if (!String.IsNullOrEmpty(orderApplicant) && File.Exists(orderApplicant))
            {
                WordService techSpecWord = new WordService(orderApplicant, false);

                techSpecWord.CopyTable(tableNumber);

                Thread.Sleep(4000);

                techSpecWord.CloseDocument(false);
                techSpecWord.CloseWord(false);
            }
        }
コード例 #13
0
        public static bool FillApplicants(string templateFileName, List <SupplierOrder> applicants, DateTime auctionDate, string orderNumber, string customerCompany)
        {
            if (string.IsNullOrEmpty(templateFileName) || applicants == null || applicants.Count < 1)
            {
                return(false);
            }

            var word = new WordService(templateFileName, false);

            if (word == null)
            {
                return(false);
            }

            try {
                word.FindReplace("[auctionDate]", auctionDate != null ? auctionDate.ToShortDateString() : "");
                word.FindReplace("[orderNumber]", orderNumber != null ? orderNumber : "");
                word.FindReplace("[customerCompany]", customerCompany != null ? customerCompany : "");

                FillApplicantsTable(word, applicants, 1);

                var accessPlayers = applicants.Where(a => a.status != null && a.status.Id != null && a.status.Id != 16);

                if (accessPlayers != null && accessPlayers.ToList().Count > 0)
                {
                    FillApplicantsTable(word, accessPlayers.ToList(), 2);
                }

                var deniedPlayers = applicants.Where(a => a.status != null && a.status.Id != null && a.status.Id == 16);

                if (deniedPlayers != null && deniedPlayers.ToList().Count > 0)
                {
                    FillApplicantsTable(word, deniedPlayers.ToList(), 3);
                }
            } catch {
                return(false);
            } finally {
                if (word.IsOpenDocument())
                {
                    word.CloseDocument(true);
                }
                if (word.IsOpenWord())
                {
                    word.CloseWord(true);
                }
            }

            return(true);
        }
コード例 #14
0
        private static void FillDocument()
        {
            var word = new WordService(fileName, false);

            word.SetCell(1, 1, 2, formc01.broker.name);
            word.SetCell(1, 2, 2, formc01.broker.code);
            word.SetCell(2, 2, 1, formc01.code);
            word.SetCell(2, 2, 2, formc01.bin);
            word.SetCell(2, 2, 3, formc01.name);
            word.SetCell(2, 2, 5, formc01.codeG + " " + formc01.codeS);
            word.SetCell(2, 2, 6, formc01.codeP);

            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #15
0
        public static List <SupplierOrder> ParseApplicants(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            var word = new WordService(fileName, false);

            if (word == null)
            {
                return(null);
            }

            List <SupplierOrder> supplierOrders = new List <SupplierOrder>();

            try {
                int           rowQuantity = word.GetTableRowsCount(1);
                SupplierOrder applicant   = new SupplierOrder();

                for (var rowCount = 2; rowCount <= rowQuantity + 1; rowCount++)
                {
                    var supplierName = word.GetCell(1, rowCount, 2);
                    applicant.Name = supplierName != null ? supplierName : "";

                    var brokerName = word.GetCell(1, rowCount, 3);
                    applicant.BrokerName = brokerName != null ? brokerName : "";

                    supplierOrders.Add(applicant);
                }
            } catch {
                return(null);
            } finally {
                if (word.IsOpenDocument())
                {
                    word.CloseDocument();
                }
                if (word.IsOpenWord())
                {
                    word.CloseWord(false);
                }
            }

            return(supplierOrders);
        }
コード例 #16
0
        public void FillFileAndSave()
        {
            // TODO : Fill base
            //DataBaseTransport.AddSupplierOrder(entryOrder);

            GetInfoFromDB();

            var word = new WordService(wherePath + "\\" + FILE_NAME, false);

            word.FindReplace("[fromDate]", entryOrder.fromDate);
            //word.FindReplace("[brokerClient]", entryOrder.brokerClient);
            //word.FindReplace("[brokerClient]", entryOrder.brokerClient);
            word.FindReplace("[lotNumber]", entryOrder.lotNumber);
            word.FindReplace("[memberCode]", entryOrder.memberCode);
            word.FindReplace("[fullMemberName]", entryOrder.fullMemberName);
            word.FindReplace("[clientCode]", entryOrder.clientCode);
            word.FindReplace("[clientFullName]", entryOrder.clientFullName);
            word.FindReplace("[clientAddress]", entryOrder.clientAddress);
            word.FindReplace("[clientBIN]", entryOrder.clientBIN);
            word.FindReplace("[clientPhones]", entryOrder.clientPhones);
            word.FindReplace("[clientBankIIK]", entryOrder.clientBankIIK);
            word.FindReplace("[clientBankBIK]", entryOrder.clientBankBIK);
            word.FindReplace("[clientBankName]", entryOrder.clientBankName);

            var stringBuilder = new StringBuilder();

            stringBuilder.Append("Список запрашиваемых документов").Append("\n");
            stringBuilder.Append("1. Заявка на участие").Append("\n");

            var iCount = 2;

            foreach (var rDoc in entryOrder.requestedDocs)
            {
                stringBuilder.Append(iCount + ". " + rDoc.name).Append("\n");
                iCount++;
            }

            word.SetCell(2, 3, 2, stringBuilder.ToString());

            word.CloseDocument(true);
            word.CloseWord(true);

            ChangeFileName();
        }
コード例 #17
0
        public void CreateTemplate(FormC01 form, string saveTo)
        {
            var FILE_NAME = "formC01.docx";

            System.IO.File.Copy(FileArchiveTransport.GetFormC01TemplateFileName(), saveTo + "\\" + FILE_NAME, true);

            var word = new WordService(saveTo + "\\" + FILE_NAME, false);

            word.SetCell(1, 1, 2, form.broker.name);
            word.SetCell(1, 2, 2, form.broker.code);
            word.SetCell(2, 2, 1, form.code);
            word.SetCell(2, 2, 2, form.bin);
            word.SetCell(2, 2, 3, form.name);
            word.SetCell(2, 2, 5, form.codeG + " " + form.codeS);
            word.SetCell(2, 2, 6, form.codeP);

            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        private static void FillSpecification()
        {
            // Fill specification
            word = new WordService(orderFiles[2], false);

            word.FindReplace("[auctionNumber]", order.Auction.Number);                                               // Auction number

            word.SetCell(1, 2, 1, "1");                                                                              // Number
            word.SetCell(1, 2, 2, order.Auction.Lots[0].Name);                                                       // Name
            word.SetCell(1, 2, 3, order.Auction.Lots[0].Unit);                                                       // Unit of size
            word.SetCell(1, 2, 4, order.Auction.Lots[0].Quantity.ToString());                                        // Quantity
            word.SetCell(1, 2, 5, order.Auction.Lots[0].Price.ToString());                                           // Price
            word.SetCell(1, 2, 6, order.Auction.Lots[0].Sum.ToString());                                             // Sum
            word.SetCell(1, 2, 7, order.Auction.Lots[0].Step.ToString());                                            // Step
            word.SetCell(1, 2, 8, order.Auction.Lots[0].DeliveryPlace + " | " + order.Auction.Lots[0].DeliveryTime); // Terms
            word.SetCell(1, 2, 9, order.Auction.Lots[0].PaymentTerm);                                                // Payment
            word.SetCell(1, 2, 10, order.Auction.Lots[0].Warranty.ToString());                                       // Warranty
            word.SetCell(1, 2, 11, order.Auction.Lots[0].LocalContent.ToString());                                   // Local

            // Close specification
            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #21
0
        public void ChangeMoneyDirection()
        {
            // Choose file that need correct
            fPath = Service.GetFile("Выберите файл заявления об изменении учета денег (до торгов)", "Заявление об изменении учета денег (*.docx)|*.docx").FullName;

            // Choose path to save
            var wherePath = Service.GetDirectory();

            if (wherePath != null)
            {
                // Copy this file
                var tmpName = wherePath.FullName + "\\Заявление об изменении учета денег (после торгов) " + DateTime.Now.ToString().Replace(":", "_") + ".docx";

                System.IO.File.Copy(fPath, tmpName, true);

                // Change data in copied file
                word = new WordService(tmpName, false);

                var    rCount = word.GetTableRowsCount(1);
                string lSide, rSide;

                for (var iRow = 2; iRow <= rCount; iRow++)
                {
                    lSide = word.GetCell(1, iRow, 1);
                    rSide = word.GetCell(1, iRow, 2);
                    word.SetCell(1, iRow, 1, rSide);
                    word.SetCell(1, iRow, 2, lSide);
                }

                // Close
                word.CloseDocument(true);
                word.CloseWord(true);

                // Open prepared dir
                Process.Start("explorer", wherePath.FullName);
            }
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
 // Save and close word
 private void SaveAndClose()
 {
     word.CloseDocument(true);
     word.CloseWord(true);
 }
コード例 #25
0
        public static Order ParseKaspiProcuratory(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            var word = new WordService(fileName, false);

            if (word == null)
            {
                return(null);
            }

            Order order = new Order();

            order.Auction      = new Auction();
            order.Auction.Lots = new System.Collections.ObjectModel.ObservableCollection <Lot>();
            order.Auction.Lots.Add(new Lot()
            {
                LotsExtended = new System.Collections.ObjectModel.ObservableCollection <LotsExtended>()
            });

            bool     result;
            DateTime dateTime;
            decimal  decimalNumber;
            double   doubleNumber;
            int      intNumber;

            try {
                order.Organizer            = word.GetCell(1, 6, 3).Replace("\r\a", "").Trim();
                order.Initiator            = word.GetCell(1, 7, 3).Replace("\r\a", "").Trim();
                order.Auction.Lots[0].Name = word.GetCell(1, 8, 3).Replace("\r\a", "").Trim();
                order.Auction.Type         = word.GetCell(1, 9, 3).Replace("\r\a", "").Trim();

                result = decimal.TryParse(word.GetCell(1, 15, 3).Replace("\r\a", "").Trim(), out decimalNumber);
                order.Auction.Lots[0].Quantity = result ? decimalNumber : 0;
                order.Auction.Lots[0].Unit     = word.GetCell(1, 16, 3).Replace("\r\a", "").Trim();

                result = decimal.TryParse(word.GetCell(1, 17, 3).Replace("\r\a", "").Trim(), out decimalNumber);
                order.Auction.Lots[0].Price = result ? decimalNumber : 0;
                order.Auction.Comments      = word.GetCell(1, 18, 3).Replace("\r\a", "").Trim(); // currency

                result = decimal.TryParse(word.GetCell(1, 19, 3).Replace("\r\a", "").Trim(), out decimalNumber);
                order.Auction.Lots[0].Step          = result ? decimalNumber : 0;
                order.Auction.Lots[0].DeliveryPlace = word.GetCell(1, 20, 3).Replace("\r\a", "").Trim();
                order.Auction.Lots[0].PaymentTerm   = word.GetCell(1, 21, 3).Replace("\r\a", "").Trim();
                order.Auction.Lots[0].DeliveryTime  = word.GetCell(1, 22, 3).Replace("\r\a", "").Trim();

                result             = DateTime.TryParse(word.GetCell(1, 24, 3).Replace("\r\a", "").Trim(), out dateTime);
                order.Auction.Date = result ? dateTime : DateTime.Now;

                result = decimal.TryParse(word.GetCell(1, 26, 3).Replace("\r\a", "").Trim(), out decimalNumber);
                order.Auction.Lots[0].Sum = result ? decimalNumber : 0;
            } catch {
                return(null);
            } finally {
                if (word.IsOpenDocument())
                {
                    word.CloseDocument(false);
                }
                if (word.IsOpenWord())
                {
                    word.CloseWord(false);
                }
            }


            return(order);
        }
コード例 #26
0
        private static void FillTemplateForKazETS(Order order, string fileName, string coverLetterFileName, string techSpecFile, bool withPDF = false)
        {
            // Fill order
            //excel = new ExcelService(fileName);
            IExcelService excel = new ExcelService(fileName);

            string supplierData = order.Auction.SupplierOrders[0].Name + "\n" + order.Auction.SupplierOrders[0].Address + "\nБИН " + order.Auction.SupplierOrders[0].BIN + "\nИИК " + order.Auction.SupplierOrders[0].IIK + "\n" + order.Auction.SupplierOrders[0].BankName + "\nБИК " + order.Auction.SupplierOrders[0].BIK;

            excel.SetCells(4, "B", "Заявка №" + order.Auction.Number);                                                                                                                                         // Auction number
            excel.SetCells(7, "C", supplierData);                                                                                                                                                              // Supplier data
            excel.SetCells(8, "C", order.Auction.Lots[0].Name);                                                                                                                                                // Lot name
            excel.SetCells(9, "C", order.Auction.Lots[0].CodeTRFEA);                                                                                                                                           // TR FEA
            excel.SetCells(10, "C", order.Auction.Lots[0].Name);                                                                                                                                               // Lot description
            excel.SetCells(11, "C", order.Auction.Lots[0].UnitId != 11 ? Math.Round(order.Auction.Procuratories[0].MinimalPrice / order.Auction.Lots[0].Quantity, 2).ToString() : order.Auction.Lots[0].Unit); // Start price
            excel.SetCells(12, "C", order.Auction.Lots[0].UnitId != 11 ? order.Auction.Lots[0].Quantity.ToString() : order.Auction.Lots[0].Unit);                                                              // Quantity
            excel.SetCells(13, "C", order.Auction.Lots[0].Unit);                                                                                                                                               // Unit of size
            excel.SetCells(14, "C", order.Auction.Procuratories[0].MinimalPrice);                                                                                                                              // Amount sum
            excel.SetCells(15, "C", order.Auction.Lots[0].Step);                                                                                                                                               // Step
            excel.SetCells(16, "C", order.Auction.Lots[0].PaymentTerm);                                                                                                                                        // Payment term
            excel.SetCells(17, "C", order.Auction.Lots[0].DeliveryPlace);                                                                                                                                      // Delivery terms
            excel.SetCells(18, "C", order.Auction.Lots[0].DeliveryTime);                                                                                                                                       // Delivery time
            excel.SetCells(20, "C", order.Auction.Lots[0].LocalContent);                                                                                                                                       // Local content
            excel.SetCells(21, "C", order.Auction.Date.ToShortDateString());                                                                                                                                   // Auction date
            excel.SetCells(23, "C", order.Auction.Lots[0].Warranty);                                                                                                                                           // Warranty
            excel.SetCells(25, "C", CountWorkDays(order.Auction.Date, 10));                                                                                                                                    // Order ellapse date

            // If supplier is alternative then need make one day later than private supplier
            DateTime tmpDate = order.Date;

            if (order.Auction.SupplierOrders[0].Name == order.Auction.SupplierOrders[0].BrokerName)
            {
                tmpDate = order.Deadline;
            }
            else
            {
                tmpDate = order.Deadline.AddDays(-1);
            }

            if (tmpDate.DayOfWeek == DayOfWeek.Sunday)
            {
                tmpDate = tmpDate.AddDays(-2);
            }
            else if (tmpDate.DayOfWeek == DayOfWeek.Saturday)
            {
                tmpDate = tmpDate.AddDays(-1);
            }

            //excel.SetCells(28, "B", "Дата \"" + tmpDate.Day + "\" " + GetMonthName(tmpDate.Month) + " " + tmpDate.Year + " г."); // Supplier order date

            excel.CloseWorkbook(true);
            excel.CloseExcel();

            // Fill cover letter
            //excel = new ExcelService(coverLetterFileName);
            excel = new ExcelService(coverLetterFileName);

            excel.SetCells(3, "A", "ЗАЯВКА №" + order.Auction.Number);                                                                                                                   // Order number
            excel.SetCells(7, "E", order.Auction.SupplierOrders[0].Name);                                                                                                                // Supplier name
            excel.SetCells(11, "B", order.Auction.Lots[0].Name);                                                                                                                         // Lot name
            excel.SetCells(11, "D", order.Auction.Lots[0].Unit);                                                                                                                         // Unit of size
            excel.SetCells(11, "E", order.Auction.Lots[0].UnitId != 11 ? order.Auction.Lots[0].Quantity.ToString() : order.Auction.Lots[0].Unit);                                        // Quantity
            excel.SetCells(11, "F", (order.Auction.Lots[0].UnitId == 11 ? "По приложению" : (order.Auction.Procuratories[0].MinimalPrice / order.Auction.Lots[0].Quantity).ToString())); // Price
            excel.SetCells(11, "H", order.Auction.Procuratories[0].MinimalPrice);                                                                                                        // Sum
            excel.SetCells(12, "H", order.Auction.Procuratories[0].MinimalPrice);                                                                                                        // Amount sum
            excel.SetCells(18, "A", "\"" + tmpDate.Day + "\" " + GetMonthName(tmpDate.Month) + " " + tmpDate.Year + " г.");                                                              // Order date

            // Convert cover letter to pdf
            if (withPDF)
            {
                excel.SaveAsPDF(coverLetterFileName, false);
            }

            // Close cover letter
            excel.CloseWorkbook(true);
            excel.CloseExcel();

            // Fill tech spec
            WordService word = new WordService(techSpecFile, false);

            word.FindReplace("[auctionNumber]", order.Auction.Number);                                                        // Auction number

            word.SetCell(1, 2, 1, "1");                                                                                       // Number
            word.SetCell(1, 2, 2, order.Auction.Lots[0].Name);                                                                // Name
            word.SetCell(1, 2, 3, order.Auction.Lots[0].Unit);                                                                // Unit of size
            word.SetCell(1, 2, 4, order.Auction.Lots[0].Quantity.ToString());                                                 // Quantity
            word.SetCell(1, 2, 5, (order.Auction.Procuratories[0].MinimalPrice / order.Auction.Lots[0].Quantity).ToString()); // Price
            word.SetCell(1, 2, 6, order.Auction.Procuratories[0].MinimalPrice.ToString());                                    // Sum
            word.SetCell(1, 2, 7, order.Auction.Lots[0].Step.ToString());                                                     // Step
            word.SetCell(1, 2, 8, order.Auction.Lots[0].DeliveryPlace + " | " + order.Auction.Lots[0].DeliveryTime);          // Terms
            word.SetCell(1, 2, 9, order.Auction.Lots[0].PaymentTerm);                                                         // Payment
            word.SetCell(1, 2, 10, order.Auction.Lots[0].Warranty.ToString());                                                // Warranty
            word.SetCell(1, 2, 11, order.Auction.Lots[0].LocalContent.ToString());                                            // Local

            // Close specification
            word.CloseDocument(true);
            word.CloseWord(true);
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        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);
        }
コード例 #29
0
 public void Close()
 {
     service.CloseWord(false);
 }
コード例 #30
0
 public void Close()
 {
     service.CloseWord(true);
 }