public List <LocationBarcode> GenDataToBarCode(List <LocationBarcode> locationData) { List <LocationBarcode> locationBarcode = new List <LocationBarcode>(); foreach (LocationBarcode data in locationData) { LocationBarcode barcode = new LocationBarcode(); barcode.SectionCode = data.SectionCode; barcode.SectionName = data.SectionName; barcode.LocationCode = data.Location; barcode.Location = BarcodeConverter128.StringToBarcode(data.Location); locationBarcode.Add(barcode); } return(locationBarcode); }
private List <LocationBarcode> GenDataToDisplay(List <LocationManagementModel> resultData, LocationManagementModel searchSection) { List <LocationBarcode> dataToDisplay = new List <LocationBarcode>(); foreach (LocationManagementModel data in resultData) { if (string.IsNullOrWhiteSpace(searchSection.LocationFrom) && string.IsNullOrWhiteSpace(searchSection.LocationTo)) { int sectionFrom = Int32.Parse(data.LocationFrom); int sectionTo = Int32.Parse(data.LocationTo); for (int i = sectionFrom; i <= sectionTo; i++) { LocationBarcode section = new LocationBarcode(); section.SectionCode = data.SectionCode; section.SectionName = data.SectionName; section.Location = i.ToString().PadLeft(5, '0'); section.LocationCode = "Section Code " + data.SectionCode + " , Location " + section.Location; dataToDisplay.Add(section); } } else if (string.IsNullOrWhiteSpace(searchSection.LocationFrom)) { int sectionFrom = Int32.Parse(data.LocationFrom); int sectionTo = Int32.Parse(data.LocationTo); int searchLocalTo = Int32.Parse(searchSection.LocationTo); for (int i = sectionFrom; i <= sectionTo; i++) { if (i == searchLocalTo) { LocationBarcode section = new LocationBarcode(); section.SectionCode = data.SectionCode; section.SectionName = data.SectionName; section.Location = i.ToString().PadLeft(5, '0'); section.LocationCode = "Section Code " + data.SectionCode + " , Location " + section.Location; dataToDisplay.Add(section); break; } } } else if (string.IsNullOrWhiteSpace(searchSection.LocationTo)) { int sectionFrom = Int32.Parse(data.LocationFrom); int sectionTo = Int32.Parse(data.LocationTo); int searchLocalFrom = Int32.Parse(searchSection.LocationFrom); for (int i = sectionFrom; i <= sectionTo; i++) { if (i == searchLocalFrom) { LocationBarcode section = new LocationBarcode(); section.SectionCode = data.SectionCode; section.SectionName = data.SectionName; section.Location = i.ToString().PadLeft(5, '0'); section.LocationCode = "Section Code " + data.SectionCode + " , Location " + section.Location; dataToDisplay.Add(section); break; } } } else { int searchLocalFrom = Int32.Parse(searchSection.LocationFrom); int searchLocalTo = Int32.Parse(searchSection.LocationTo); int dataFrom = Int32.Parse(data.LocationFrom); int dataTo = Int32.Parse(data.LocationTo); if (dataFrom < searchLocalFrom) { dataFrom = searchLocalFrom; } for (int i = dataFrom; i <= dataTo; i++) { if (i > searchLocalTo) { break; } LocationBarcode section = new LocationBarcode(); section.SectionCode = data.SectionCode; section.SectionName = data.SectionName; section.Location = i.ToString().PadLeft(5, '0'); section.LocationCode = "Section Code " + data.SectionCode + " , Location " + section.Location; dataToDisplay.Add(section); } } } return(dataToDisplay); }