/// <summary> /// Получить таблицу цен международных перевозок /// </summary> /// <returns></returns> internal List <TruckRate> GetTruckRateInternational() { List <TruckRate> ListRate = new List <TruckRate>(); Worksheet sheetRoute = Globals.ThisWorkbook.Sheets["Rate Inetrnational"]; ListObject rateTable = sheetRoute.ListObjects["TableRateInternational"]; foreach (ListRow row in rateTable.ListRows) { string valTonnage = row.Range[1, rateTable.ListColumns["tonnage, t"].Index].Text; double tonnage = double.TryParse(valTonnage, out double t) ? t : 0; string valCity = row.Range[1, rateTable.ListColumns["City"].Index].Text; valCity = valCity.Trim(); string valCompany = row.Range[1, rateTable.ListColumns["Company"].Index].Text; valCompany = valCompany.Trim(); if (tonnage > 0 && !string.IsNullOrWhiteSpace(valCity)) { string strPrice = row.Range[1, rateTable.ListColumns["vehicle"].Index].Value.ToString(); decimal price = decimal.TryParse(strPrice, out decimal pf) ? pf : 0; strPrice = row.Range[1, rateTable.ListColumns["add.point"].Index].Value.ToString(); decimal priceAdd = decimal.TryParse(strPrice, out decimal pa) ? pa : 0; TruckRate rate = new TruckRate() { City = valCity, Company = valCompany, PriceFirstPoint = price, PriceAddPoint = priceAdd, PlaceShipment = row.Range[1, 1].Text, Tonnage = tonnage }; ListRate.Add(rate); } } return(ListRate); }
/// <summary> /// Получить вес список цен перевозчиков в формате списка /// </summary> /// <returns></returns> private static List <TruckRate> GetTruckRateList() { List <TruckRate> ListRate = new List <TruckRate>(); foreach (ListRow row in RateTable.ListRows) { string valTonnage = row.Range[1, RateTable.ListColumns["tonnage, t"].Index].Text; double tonnage = double.TryParse(valTonnage, out double t) ? t : 0; string valCity = row.Range[1, RateTable.ListColumns["City"].Index].Text; valCity = valCity.Trim(); string valCompany = row.Range[1, RateTable.ListColumns["Company"].Index].Text; valCompany = valCompany.Trim(); if (tonnage > 0 && !string.IsNullOrWhiteSpace(valCity)) { string strPrice = row.Range[1, RateTable.ListColumns["vehicle"].Index].Value.ToString(); decimal priceFirst = decimal.TryParse(strPrice, out decimal pf) ? pf : 0; strPrice = row.Range[1, RateTable.ListColumns["add.point"].Index].Value.ToString(); decimal priceAdd = decimal.TryParse(strPrice, out decimal pa) ? pa : 0; TruckRate rate = new TruckRate() { City = valCity, Company = valCompany, PriceFirstPoint = priceFirst, PriceAddPoint = priceAdd, PlaceShipment = row.Range[1, 1].Text, PlaceDelivery = row.Range[1, 2].Text, Tonnage = tonnage }; ListRate.Add(rate); } } return(ListRate); }