/// <summary> /// Insert the report BO data into a file template of a report for suppliers. /// Вставка данных в шаблон. /// </summary> /// <param name="report">report BO to insert</param> /// <param name="service">file template of report for supplier</param> /// <returns>resulting file template with data</returns> private static WordService InsertIntoSupplierReport(Report report, WordService service) { switch (report.Id.ToLower()) { case "altk": report.BrokerName = "ТОО Альта и К"; break; case "kord": report.BrokerName = "ТОО Корунд-777"; break; case "alta": report.BrokerName = "ТОО Альтаир-Нур"; break; case "akal": report.BrokerName = "ТОО Ак Алтын Ко"; break; default: report.BrokerName = ""; break; } service.FindReplace("[firmBroker]", report.BrokerName); service.FindReplace("[number]", report.Number); var cName = report.ClientName; var lotInfo = DataBaseClient.GetLotByCode(report.Code); var supplierInfo = DataBaseClient.GetSupplierByBroker_Auction(cName.Substring(cName.Length - 4), lotInfo == null ? 0 : lotInfo.auctionid, lotInfo == null ? 0 : lotInfo.id); if (supplierInfo != null) { cName = supplierInfo[1]; // Change statuses of supplier orders to lose ChangeStatusesToSO(lotInfo.auctionid, Convert.ToInt32(supplierInfo[4])); } service.FindReplace("[supplierName]", cName); service.FindReplace("[auctionDate]", report.DateTo); service.FindReplace("[dealRegDate]", report.Moment); service.FindReplace("[productName]", report.ProductName); decimal startPrice = DataBaseClient.GetPriceFromLot(report.Code); string sPrice = $"{startPrice:C}"; sPrice = sPrice.Substring(0, sPrice.Length - 2); service.FindReplace("[startPrice]", startPrice == 0 ? "Введите стартовую цену" : sPrice + " тенге, с учетом НДС"); service.FindReplace("[lotCode]", report.Code); service.FindReplace("[qty]", report.Qty); try { service.SetCell(1, 11, 2, lotInfo.auction.customer.company.name); } catch { } service.FindReplace("[lastPrice]", report.Price); service.FindReplace("[amountSum]", report.Amt); service.FindReplace("[clientBrokerCode]", report.ContrCode); service.FindReplace("[directorName]", report.Director); // Make record in final report table try { if (lotInfo != null && supplierInfo != null) { var finalReport = DataBaseClient.ReadFinalReport(lotInfo.auctionid, lotInfo.id); decimal lastPrice = Convert.ToDecimal(report.Amt.Substring(0, report.Amt.IndexOf(" т") - 2).Replace(" ", "")); if (finalReport != null) { DataBaseClient.DeleteFinalReport(finalReport); } FinalReportEF finalReportItem = new FinalReportEF() { auctionId = lotInfo.auctionid, dealNumber = report.Number, supplierId = Convert.ToInt32(supplierInfo[2]), lotId = lotInfo.id, finalPriceOffer = lastPrice, brokerId = Convert.ToInt32(supplierInfo[3]) }; DataBaseClient.CreateFinalReport(finalReportItem); // Change procuratory try { DataBaseClient.UpdateProcuratory(Convert.ToInt32(supplierInfo[2]), lotInfo.id, lastPrice); } catch (Exception) { } DataBaseClient.SetAuctionStatus(lotInfo.auctionid, 2); } } catch (Exception) { } return(service); }