private void CmbMaterialsSelectionChanged(object sender, SelectionChangedEventArgs e) { InputChanged(null, null); if (cmbMaterials.SelectedValue != null) { var material = MaterialsService.Get((Guid)cmbMaterials.SelectedValue); tbAmount.Tag = string.Format(RepositoryMaterialsAndItemsResources.AmountBy, material.StringUnit); } }
public void ValidateAmount(Guid materialID, int amount, out int result) { var material = MaterialsService.Get(materialID); var all = GetAll(materialID); var repositoryAmount = all.Sum(m => m.Amount); if (repositoryAmount + amount >= material.LowestAmount) { result = -2; } else if (repositoryAmount + amount >= 0) { result = -1; } else { result = repositoryAmount; } }
public static string RepositoryMaterialDetailer(RepositoryMaterial repositoryMaterial, ActionType actionType) { var material = MaterialsService.Get(repositoryMaterial.MaterialID); if (material == null) { return(null); } switch (actionType) { case ActionType.Created: return(string.Format("به موجودی مادهای با نام {0} {1} {2} اضافه شد.", material.Name, repositoryMaterial.Amount, material.StringUnit)); case ActionType.Removed: return(string.Format("از موجودی مادهای با نام {0} {1} {2} کم شد.", material.Name, repositoryMaterial.Amount, material.StringUnit)); default: return(null); } }