public static string GetReportPathByLot(string lotCode) { var lot = DataBaseClient.GetLotByCode(lotCode); if (lot != null) { string folderPath = "\\\\192.168.11.5\\Archive\\Auctions\\ETS\\"; string oldPath = folderPath + lot.auction.date.ToShortDateString() + "\\" + (lot.auction.number.Length > 4 ? lot.auction.number.Substring(lot.auction.number.Length - 4) : lot.auction.number).Replace("/", "_"); string newPath = folderPath + lot.auction.date.ToShortDateString() + "\\" + lot.auction.number.Replace("/", "_"); string path = Directory.Exists(oldPath) ? oldPath : newPath; return(path + "\\"); } else { return(GetReportPath()); } }
/// <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); }
/// <summary> /// Insert the report BO data into a file template of a report for customers. /// Вставка данных в шаблон отчета для заказчиков. /// </summary> /// <param name="report">report BO to insert</param> /// <param name="service">file template of report for customer</param> /// <returns>resulting file template with data</returns> private static WordService InsertIntoClientReport(Report report, WordService service) { var lotInfo = DataBaseClient.GetLotByCode(report.Code); try { service.FindReplace("[orderNumber]", lotInfo == null ? "Номер аукциона" : lotInfo.auction.number); service.FindReplace("[dealNumber]", report.Number); try { service.SetCell(1, 6, 2, lotInfo.auction.customer.company.name); var customerCode = DataBaseClient.GetSupplierCodeByCompany(lotInfo.auction.customer.company.id); if (customerCode != null) { service.SetCell(1, 7, 2, customerCode); } } catch { } service.FindReplace("[auctionDate]", report.Moment.Substring(0, report.Moment.IndexOf(" ", StringComparison.Ordinal))); service.FindReplace("[dealRegDate]", report.Moment); service.FindReplace("[lotCode]", report.Code); service.FindReplace("[productName]", report.ProductName); } catch (Exception) { } string lotSum = lotInfo != null ? $"{lotInfo.sum:C}" : "0,00"; lotSum = lotSum.Substring(0, lotSum.Length - 2); service.FindReplace("[startPrice]", lotInfo == null ? "Введите стартовую цену" : lotSum + " тенге, с учетом НДС"); service.FindReplace("[amountSum]", report.Amt); var supplierInfo = DataBaseClient.GetSupplierByBroker_Auction(report.ContrCode, lotInfo == null ? 0 : lotInfo.auctionid, lotInfo == null ? 0 : lotInfo.id); service.FindReplace("[supplierCode]", supplierInfo == null ? "Код поставщика" : supplierInfo[0]); service.FindReplace("[supplierName]", supplierInfo == null ? "Наименование поставщика" : supplierInfo[1]); service.FindReplace("[brokerCode]", report.ContrCode); switch (report.ContrCode.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("[brokerName]", report.BrokerName); // Change auction status try { if (lotInfo != null) { DataBaseClient.SetAuctionStatus(lotInfo.auctionid, 2); } } catch (Exception) { } return(service); }