Exemple #1
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");
        }
Exemple #2
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);
        }