private bool NewWarehouseLocation(string itemID) { WarehouseLocation newItem = new WarehouseLocation(); //all new records will be give a negative int autoid... //when they are updated then sql will generate one for them overiding this set value... //it will allow us to give uniqueness to the tempory new records... //Before they are updated to the entity and given an autoid... //we use a negative number and keep subtracting by 1 for each new item added... //This will allow it to alwasy be unique and never interfere with SQL's positive autoid... _newWarehouseLocationAutoId = _newWarehouseLocationAutoId - 1; newItem.AutoID = _newWarehouseLocationAutoId; newItem.WarehouseLocationID = itemID; newItem.CompanyID = ClientSessionSingleton.Instance.CompanyID; newItem.IsValid = 1; newItem.NotValidMessage = "New Record Key Field/s Are Required."; WarehouseLocationList.Add(newItem); _serviceAgent.AddToWarehouseLocationRepository(newItem); SelectedWarehouseLocation = WarehouseLocationList.LastOrDefault(); AllowEdit = true; Dirty = false; AllowKeyEntry = true; return(true); }
private double FulfillPercent(WarehouseLocation warehouse, List <MyOrderItem> orderItems, Dictionary <string, ItemComparator.ItemInfo> netsuiteItemInfoMap) { double total_items = 0; double can_be_fulfilled = 0; foreach (MyOrderItem orderItem in orderItems) { // Skip non inv items if (!orderItem.IsInventory()) { continue; } total_items += orderItem.qty; try { double inventory = netsuiteItemInfoMap[orderItem.internal_id].ReturnInv(warehouse); can_be_fulfilled += Math.Min(inventory, orderItem.qty); } catch (KeyNotFoundException keyNotFoundException) { continue; } } Console.WriteLine("-- Location: {0}, Fulfill Precent: {1} --", warehouse, can_be_fulfilled / total_items); return(can_be_fulfilled / total_items); }
private void Refresh() {//refetch current records... long selectedAutoID = SelectedWarehouseLocation.AutoID; string autoIDs = ""; //bool isFirstItem = true; foreach (WarehouseLocation item in WarehouseLocationList) {//auto seeded starts at 1 any records at 0 or less or not valid records... if (item.AutoID > 0) { autoIDs = autoIDs + item.AutoID.ToString() + ","; } } if (autoIDs.Length > 0) { //ditch the extra comma... autoIDs = autoIDs.Remove(autoIDs.Length - 1, 1); WarehouseLocationList = new BindingList <WarehouseLocation>(_serviceAgent.RefreshWarehouseLocation(autoIDs).ToList()); SelectedWarehouseLocation = (from q in WarehouseLocationList where q.AutoID == selectedAutoID select q).FirstOrDefault(); Dirty = false; AllowCommit = false; } }
public async Task <IActionResult> Edit(long id, [Bind("Id,Section,Aisle,Position,Level")] WarehouseLocation warehouseLocation) { if (id != warehouseLocation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(warehouseLocation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WarehouseLocationExists(warehouseLocation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(warehouseLocation)); }
private void ChangeKeyLogic() { if (!string.IsNullOrEmpty(SelectedWarehouseLocation.WarehouseLocationID)) {//check to see if key is part of the current companylist... WarehouseLocation query = WarehouseLocationList.Where(company => company.WarehouseLocationID == SelectedWarehouseLocation.WarehouseLocationID && company.AutoID != SelectedWarehouseLocation.AutoID).FirstOrDefault(); if (query != null) {//revert it back SelectedWarehouseLocation.WarehouseLocationID = SelectedWarehouseLocationMirror.WarehouseLocationID; //change to the newly selected company... SelectedWarehouseLocation = query; return; } //it is not part of the existing list try to fetch it from the db... WarehouseLocationList = GetWarehouseLocationByID(SelectedWarehouseLocation.WarehouseLocationID, XERP.Client.ClientSessionSingleton.Instance.CompanyID); if (WarehouseLocationList.Count == 0)//it was not found do new record required logic... { NotifyNewRecordNeeded("Record " + SelectedWarehouseLocation.WarehouseLocationID + " Does Not Exist. Create A New Record?"); } else { SelectedWarehouseLocation = WarehouseLocationList.FirstOrDefault(); } } else { string errorMessage = "ID Is Required."; NotifyMessage(errorMessage); //revert back to the value it was before it was changed... if (SelectedWarehouseLocation.WarehouseLocationID != SelectedWarehouseLocationMirror.WarehouseLocationID) { SelectedWarehouseLocation.WarehouseLocationID = SelectedWarehouseLocationMirror.WarehouseLocationID; } } }
public override Specification <Product> GetSpecification() { var spec = new Specification <Product>(); if (!Ids.IsEmpty()) { int[] ids = ArrayHelpers.StringToIntArray(Ids); if (ids != null && ids.Length > 0) { spec.And(c => ids.Contains(c.Id)); } } if (VendorId.HasValue) { spec.And(c => c.VendorId == VendorId.Value); } if (!Sku.IsEmpty()) { spec.And(c => c.Sku.StartsWith(Sku)); } if (!Name.IsEmpty()) { spec.And(c => c.Name.StartsWith(Name)); } if (!WarehouseLocation.IsEmpty()) { spec.And(c => c.WarehouseLocation.StartsWith(WarehouseLocation) || c.BulkWarehouseLocation.StartsWith(WarehouseLocation)); } if (!ShowAll) { spec.And(c => !c.Discontinued || c.Inventory.StockQuantity > 0); } return(spec); }
public void DeleteWarehouseLocationCommand() { try { int i = 0; int ii = 0; for (int j = SelectedWarehouseLocationList.Count - 1; j >= 0; j--) { WarehouseLocation item = (WarehouseLocation)SelectedWarehouseLocationList[j]; //get Max Index... i = WarehouseLocationList.IndexOf(item); if (i > ii) { ii = i; } Delete(item); WarehouseLocationList.Remove(item); } if (WarehouseLocationList != null && WarehouseLocationList.Count > 0) { //back off one index from the max index... ii = ii - 1; //if they delete the first row... if (ii < 0) { ii = 0; } //make sure it does not exceed the list count... if (ii >= WarehouseLocationList.Count()) { ii = WarehouseLocationList.Count - 1; } SelectedWarehouseLocation = WarehouseLocationList[ii]; //we will only enable committ for dirty validated records... if (Dirty == true) { AllowCommit = CommitIsAllowed(); } else { AllowCommit = false; } } else//only one record, deleting will result in no records... { SetAsEmptySelection(); } }//we try catch company delete as it may be used in another table as a key... //As well we will force a refresh to sqare up the UI after the botched delete... catch { NotifyMessage("WarehouseLocation/s Can Not Be Deleted. Contact XERP Admin For More Details."); Refresh(); } }
private bool CanWarehouseFulfillAll(WarehouseLocation warehouse, List <MyOrderItem> orderItems, Dictionary <string, ItemComparator.ItemInfo> netsuiteItemInfoMap) { if (FulfillPercent(warehouse, orderItems, netsuiteItemInfoMap) == 1) { return(true); } return(false); }
private BindingList <WarehouseLocation> GetWarehouseLocations(WarehouseLocation item, string companyID) { BindingList <WarehouseLocation> itemList = new BindingList <WarehouseLocation>(_serviceAgent.GetWarehouseLocations(item, companyID).ToList()); Dirty = false; AllowCommit = false; return(itemList); }
private void SetAsEmptySelection() { SelectedWarehouseLocation = new WarehouseLocation(); AllowEdit = false; AllowDelete = false; Dirty = false; AllowCommit = false; AllowRowCopy = false; }
public static void SetPropertyValue(this WarehouseLocation myObj, object propertyName, object propertyValue) { var propInfo = typeof(WarehouseLocation).GetProperty((string)propertyName); if (propInfo != null) { propInfo.SetValue(myObj, propertyValue, null); } }
public static WarehouseLocation Generate() { var aisle = charGenerator.Generate(); var shelf = shelfGenerator.Generate(); var loc = locGenerator.Generate(); var location = new WarehouseLocation(aisle, shelf, loc); return(location); }
public void UpdateRepository(WarehouseLocation item) { if (_repositoryContext.GetEntityDescriptor(item) != null) { item.LastModifiedBy = XERP.Client.ClientSessionSingleton.Instance.SystemUserID; item.LastModifiedByDate = DateTime.Now; _repositoryContext.MergeOption = MergeOption.AppendOnly; _repositoryContext.UpdateObject(item); } }
private void OnSearchResult(object sender, NotificationEventArgs <BindingList <WarehouseLocation> > e) { if (e.Data != null && e.Data.Count > 0) { WarehouseLocationList = e.Data; SelectedWarehouseLocation = WarehouseLocationList.FirstOrDefault(); Dirty = false; AllowCommit = false; } UnregisterToReceiveMessages <BindingList <WarehouseLocation> >(MessageTokens.WarehouseLocationSearchToken.ToString(), OnSearchResult); }
public EntityStates GetWarehouseLocationEntityState(WarehouseLocation item) { if (_repositoryContext.GetEntityDescriptor(item) != null) { return(_repositoryContext.GetEntityDescriptor(item).State); } else { return(EntityStates.Detached); } }
private void DeductInventory(List <MyOrderItem> orderItems, WarehouseLocation warehouse, Dictionary <string, ItemComparator.ItemInfo> netsuiteItemInfoMap) { foreach (MyOrderItem orderItem in orderItems) { if (netsuiteItemInfoMap.ContainsKey(orderItem.internal_id)) { double remaing = netsuiteItemInfoMap[orderItem.internal_id].ReturnInv(warehouse) - orderItem.qty; netsuiteItemInfoMap[orderItem.internal_id].UpdateInv(warehouse, remaing); } } }
protected override void HandleUnknownType <T>(Type memberType, MemberInfo memberInfo, T obj) { if (memberType == typeof(WarehouseLocation)) { var location = new WarehouseLocation(aisleGenerator.Generate(), shelfGenerator.Generate(), locGenerator.Generate()); SetValue(memberInfo, obj, location); } }
public async Task <IActionResult> Create([Bind("Id,Section,Aisle,Position,Level")] WarehouseLocation warehouseLocation) { if (ModelState.IsValid) { _context.Add(warehouseLocation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(warehouseLocation)); }
private RecordRef CreateLocation(WarehouseLocation warehouse) { RecordRef location = new RecordRef() { type = RecordType.location, typeSpecified = true, internalId = warehouse.ToString("d") }; return(location); }
public static object GetPropertyValue(this WarehouseLocation myObj, string propertyName) { var propInfo = typeof(WarehouseLocation).GetProperty(propertyName); if (propInfo != null) { return(propInfo.GetValue(myObj, null)); } else { return(string.Empty); } }
public static string GetPropertyType(this WarehouseLocation myObj, string propertyName) { var propInfo = typeof(WarehouseLocation).GetProperty(propertyName); if (propInfo != null) { return(propInfo.PropertyType.Name.ToString()); } else { return(null); } }
public static WarehouseLocation Parse(SqlString s) { if (s.IsNull) { return(Null); } Validate(s); WarehouseLocation warehouseLocation = new WarehouseLocation(); warehouseLocation.location = s.ToString(); return(warehouseLocation); }
//udpate merely updates the repository a commit is required to commit it to the db... private bool Update(WarehouseLocation item) { _serviceAgent.UpdateWarehouseLocationRepository(item); Dirty = true; if (CommitIsAllowed()) { AllowCommit = true; } else { AllowCommit = false; } return(AllowCommit); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } WarehouseLocation = await _context.WarehouseLocation.FirstOrDefaultAsync(m => m.ID == id); if (WarehouseLocation == null) { return(NotFound()); } return(Page()); }
public async Task <ActionResult <WarehouseLocationDto> > CreateWarehouseLocation(CreateWarehouseLocationDto createWarehouseLocationDto) { var wl = new WarehouseLocation { LocationName = createWarehouseLocationDto.LocationName }; _warehouseLocationRepository.AddWarehouseLocation(wl); if (await _warehouseLocationRepository.SaveAllAsync()) { return(Ok(_mapper.Map <WarehouseLocationDto>(wl))); } return(BadRequest("Failed to add warehouse location.")); }
//Object.Property Scope Validation... private bool WarehouseLocationIsValid(WarehouseLocation item, _warehouseLocationValidationProperties validationProperties, out string errorMessage) { errorMessage = ""; switch (validationProperties) { case _warehouseLocationValidationProperties.WarehouseLocationID: //validate key if (string.IsNullOrEmpty(item.WarehouseLocationID)) { errorMessage = "ID Is Required."; return(false); } EntityStates entityState = GetWarehouseLocationState(item); if (entityState == EntityStates.Added && WarehouseLocationExists(item.WarehouseLocationID, item.WarehouseLocationID, item.WarehouseID, item.PlantID)) { errorMessage = "Item All Ready Exists..."; return(false); } //check cached list for duplicates... int count = WarehouseLocationList.Count(q => q.WarehouseLocationID == item.WarehouseLocationID); if (count > 1) { errorMessage = "Item All Ready Exists..."; return(false); } break; case _warehouseLocationValidationProperties.Name: //validate Description if (string.IsNullOrEmpty(item.Name)) { errorMessage = "Description Is Required."; return(false); } break; case _warehouseLocationValidationProperties.WarehouseID: //validate 2nd key if (string.IsNullOrEmpty(item.WarehouseID)) { errorMessage = "Warehouse Is Required."; return(false); } break; } return(true); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } WarehouseLocation = await _context.WarehouseLocation.FindAsync(id); if (WarehouseLocation != null) { _context.WarehouseLocation.Remove(WarehouseLocation); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
//WarehouseLocation Object Scope Validation check the entire object for validity... private byte WarehouseLocationIsValid(WarehouseLocation item, out string errorMessage) { //validate key errorMessage = ""; if (string.IsNullOrEmpty(item.WarehouseLocationID)) { errorMessage = "ID Is Required."; return(1); } EntityStates entityState = GetWarehouseLocationState(item); if (entityState == EntityStates.Added && WarehouseLocationExists(item.WarehouseLocationID, item.WarehouseLocationID, item.WarehouseID, item.PlantID)) { errorMessage = "Item All Ready Exists."; return(1); } //check cached list for duplicates... int count = WarehouseLocationList.Count(q => q.WarehouseLocationID == item.WarehouseLocationID); if (count > 1) { errorMessage = "Item All Ready Exists..."; return(1); } //validate Name if (string.IsNullOrEmpty(item.Name)) { errorMessage = "Name Is Required."; return(1); } //validate WarehouseLocationID if (string.IsNullOrEmpty(item.WarehouseLocationID)) { errorMessage = "Warehouse Location Is Required."; return(1); } //validate WarehouseID if (string.IsNullOrEmpty(item.WarehouseLocationID)) { errorMessage = "Warehouse Is Required."; return(1); } //a value of 2 is pending changes... //On Commit we will give it a value of 0... return(2); }
public PackageInfo(uint no, WarehouseLocation warehouseLocation, LookupIdName supplier, LookupIdName warehouse, double stockValue, string serialNumber, PackageStatus lastStatus, DateTime?productionDate, DateTime?expiredDate) { if (no < 0) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(no)}", new ArgumentNullException()); } if (warehouseLocation == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(warehouseLocation)}", new ArgumentNullException()); } if (supplier == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(supplier)}", new ArgumentNullException()); } if (warehouse == null) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(warehouse)}", new ArgumentNullException()); } if (stockValue < 0) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(stockValue)}", new ArgumentNullException()); } if (string.IsNullOrEmpty(serialNumber)) { throw new DomainException($"{nameof(PackageInfo)}-{nameof(serialNumber)}", new ArgumentNullException()); } this.Location = warehouseLocation; this.No = no; this.Supplier = supplier; this.Warehouse = warehouse; this.StockValue = stockValue; this.SerialNumber = serialNumber; this.LastStatus = lastStatus; this.ExpiredDate = expiredDate; this.ProductionDate = productionDate; }
public string ReadWarehouseLocationCsvFile() { try { List <WarehouseLocation> result = new List <WarehouseLocation>(); StreamReader sr = new StreamReader(@"Assets/WarehouseLocationCsv.csv"); string strLine = string.Empty; string[] value = null; int x = -1; while (!sr.EndOfStream) { x++; strLine = sr.ReadLine(); value = strLine.Split(','); if (x > 0 && value.Length == 2) { var warehouseLocation = new WarehouseLocation(); warehouseLocation.Id = Int32.Parse(value[0]); warehouseLocation.LocationName = value[1]; result.Add(warehouseLocation); } } _db.WarehouseLocations.AddRange(result); _db.SaveChanges(); GC.Collect(); int counter = _db.WarehouseLocations.Count(); if (counter < 10) { return("Process error less than 10 records"); } return("Completed"); } catch (Exception ex) { return(ex.Message); } }