public bool CheckCommoditySupplierIsUsed(CommoditySupplier commoditySupplier, EntityStatus intendedStatus) { if (intendedStatus == EntityStatus.Inactive) { if ( _ctx.tblCommodityOwner.Any(n => n.CostCentreId == commoditySupplier.Id && n.IM_Status == (int) EntityStatus.Active)) return true; if (_ctx.tblCommodityProducer.Any(n => n.CostCentreId == commoditySupplier.Id && n.IM_Status == (int)EntityStatus.Active)) return true; } if (intendedStatus == EntityStatus.Deleted) { if (_ctx.tblCommodityOwner.Any(n => n.CostCentreId == commoditySupplier.Id && (n.IM_Status == (int) EntityStatus.Active || n.IM_Status == (int) EntityStatus.Inactive) )) return true; if (_ctx.tblCommodityProducer.Any(n => n.CostCentreId == commoditySupplier.Id && (n.IM_Status == (int) EntityStatus.Active || n.IM_Status == (int) EntityStatus.Inactive) )) return true; } if (_ctx.tblSourcingDocument.Any(n => n.DocumentOnBehalfOfCostCentreId == commoditySupplier.Id)) return true; return false; }
private CommoditySupplierListingViewModel Map(CommoditySupplier commoditySupplier) { var bank = _bankRepository.GetById(commoditySupplier.BankId) ?? new Bank(Guid.NewGuid()); var bankBranch = _bankBranchRepository.GetById(commoditySupplier.BankBranchId) ?? new BankBranch(Guid.NewGuid()); var commoditySupplierVM = new CommoditySupplierListingViewModel(); commoditySupplierVM.Id = commoditySupplier.Id; commoditySupplierVM.CostCentreCode = commoditySupplier.CostCentreCode; commoditySupplierVM.CommoditySupplierType = (int)commoditySupplier.CommoditySupplierType; commoditySupplierVM.Name = commoditySupplier.Name; commoditySupplierVM.JoinDate = commoditySupplier.JoinDate; commoditySupplierVM.AccountNo = commoditySupplier.AccountNo; commoditySupplierVM.PinNo = commoditySupplier.PinNo; commoditySupplierVM.Bank = bank.Name??""; commoditySupplierVM.BankBranch= bankBranch.Name??""; commoditySupplierVM.ParentCostCentreId = commoditySupplier.ParentCostCentre.Id; commoditySupplierVM.IsActive = (int)commoditySupplier._Status; return commoditySupplierVM; }
public CommodityPurchaseNote Create(CostCentre documentIssuerCostCentre, Guid documentIssueCostCentreApplicationId, CostCentre documentRecipientCostCentre, User documentIssuerUser, string documentReference, Guid documentParentId, string deliveredBy, CommodityProducer commodityProducer, CommoditySupplier commoditySupplier, CommodityOwner owner, DateTime documentDate, DateTime documentDateIssued, string description,string note) { Guid id = Guid.NewGuid(); var doc = DocumentPrivateConstruct<CommodityPurchaseNote>(id); if (documentParentId == null || documentParentId == Guid.Empty) doc.DocumentParentId = id; else doc.DocumentParentId = documentParentId; doc.DeliveredBy = deliveredBy; doc.CommodityOwner = owner; doc.CommodityProducer = commodityProducer; doc.CommoditySupplier = commoditySupplier; doc.DocumentIssuerCostCentre = documentIssuerCostCentre; doc.DocumentIssuerCostCentreApplicationId = documentIssueCostCentreApplicationId; doc.DocumentRecipientCostCentre = documentRecipientCostCentre; doc.DocumentReference = documentReference; doc.DocumentIssuerUser = documentIssuerUser; doc.Description = description; doc.Note = note; doc.DocumentDate = documentDate; doc.DocumentDateIssued = documentDateIssued; Map(doc, documentIssuerCostCentre, documentIssueCostCentreApplicationId, documentRecipientCostCentre, documentIssuerUser, documentReference, null, null); SetDefaultDates(doc); doc.EnableAddCommands(); return doc; }
private void ClearFilters() { IsSet = false; LoadCommoditySupplierInventoryList(IsSet); SelectedCommoditySupplier = new CommoditySupplier(Guid.Empty) { Name = "--Select Commodity Supplier---" }; SelectedCommoditySupplierName = "--Select Commdity Supplier---"; SelectedStore = new Store(Guid.Empty) { Name = "--Select Store---" }; SelectedStoreName = "--Select Store---"; UpdatePagenationControl(); }
public bool CommodityOwnerHasPurchases(CommoditySupplier commodityOwner) { return _ctx.tblSourcingDocument.Any(n => n.DocumentIssuerCostCentreId == commodityOwner.Id || n.DocumentRecipientCostCentreId==commodityOwner.Id); }
public bool CommoditySupplierHasOwnersOrProducers(CommoditySupplier commoditySupplier) { return _ctx.tblSourcingDocument.Any(n => n.DocumentOnBehalfOfCostCentreId == commoditySupplier.Id); }
private async void Save() { var commodityOwner =new CommodityOwner(CommodityOwnerId); var commoditySupplier=new CommoditySupplier(Id); var commodityProducer = new CommodityProducer(CommodityProducerId); var contact = new Contact(ContactId); using (var c = NestedContainer) { commodityOwner.Code = OwnerCode; if (string.IsNullOrEmpty(commodityOwner.Code)) { MessageBox.Show("Farmer Code is a Required Field", "Agrimanagr: Farmer Management", MessageBoxButton.OK); return; } commodityOwner.Surname = Surname; commodityOwner.FirstName = FirstName; commodityOwner.LastName = MiddleName; commodityOwner.IdNo = IdNumber; commodityOwner.PinNo = PinNumber; //CommodityOwner.Gender =; commodityOwner.PhysicalAddress = PhysicalAddress; commodityOwner.PostalAddress = PostalAddress; commodityOwner.Email = Email; commodityOwner.PhoneNumber = PhoneNumber; commodityOwner.BusinessNumber = BusinessNumber; commodityOwner.FaxNumber = FaxNumber; commodityOwner.OfficeNumber = OfficeNumber; commodityOwner.Description = Description; commodityOwner.DateOfBirth = DateOfBirth; commodityOwner.CommoditySupplier = commoditySupplier; commodityOwner._Status = EntityStatus.Active; if (DateTime.Now.Year - DateOfBirth.Year < 18) { MessageBox.Show("Farmer must be over 18 years old.", "Agrimanagr: Farmer Management", MessageBoxButton.OK); return; } commodityOwner.MaritalStatus = SelectedMaritalStatus; commodityOwner.CommodityOwnerType = SelectedCommodityOwnerType; commoditySupplier.JoinDate = DateTime.Now.Date; commoditySupplier.AccountName = AccountName; commoditySupplier.AccountNo = AccountNumber; commoditySupplier._Status = EntityStatus.Active; commoditySupplier.PinNo = PinNumber; commoditySupplier.BankId = SelectedBank.Id; commoditySupplier.BankBranchId = SelectedBankBranch.Id; commoditySupplier.CommoditySupplierType = SelectedCommoditySupplierType; commoditySupplier.CostCentreCode = CostCenterCode; commoditySupplier.Name = AccountFullName; var config = Using<IConfigService>(c).Load(); commoditySupplier.ParentCostCentre = new CostCentreRef {Id = config.CostCentreId}; if (!IsValid(commoditySupplier)) return; commodityProducer.CommoditySupplier = commoditySupplier; commodityProducer._SetStatus(EntityStatus.Active); commodityOwner.BusinessNumber = BusinessNumber; if (!IsValid(commodityOwner)) return; commodityProducer.CommodityProducerCentres.Clear(); commodityProducer.CommodityProducerCentres.AddRange(AssignedCentresList.Select(n => n.Centre)); commodityProducer.Code = FarmCode; if (string.IsNullOrEmpty(commodityProducer.Code)) { MessageBox.Show("Farm Code is a Required Field", "Agrimanagr: Farmer Management", MessageBoxButton.OK); return; } commodityProducer.Acrage = Acerage; commodityProducer.Name = FarmName; commodityProducer._Status = EntityStatus.Active; commodityProducer.RegNo = FarmRegistrationNo; commodityProducer.PhysicalAddress = FarmPhysicalAddress; commodityProducer.Description = FarmDescription; commodityProducer.CommoditySupplier = commoditySupplier; contact.BusinessPhone = BusinessNumber; contact.Email = Email; contact.ContactOwnerMasterId = commoditySupplier.Id; contact.Firstname = AccountFullName; contact.PostalAddress = PostalAddress; contact.MobilePhone = PhoneNumber; contact.PhysicalAddress = PhysicalAddress; contact.ContactOwnerType=ContactOwnerType.CommoditySupplier; if (!IsValid() || !IsValid(commodityProducer)) return; string responseMsg = ""; _proxy = Using<IDistributorServiceProxy>(c); var mapper = Using<IMasterDataToDTOMapping>(c); var commoditySupplierdto = mapper.Map(commoditySupplier); ResponseBool response = await _proxy.CommoditySupplierAddAsync(commoditySupplierdto); responseMsg += response.ErrorInfo + "\n"; string log = string.Format("Created commodity supplier: {0}; Code: {1}; And Type {2}", commoditySupplier.Name, commoditySupplier.CostCentreCode, commoditySupplier.CommoditySupplierType); Using<IAuditLogWFManager>(c).AuditLogEntry("Manage Commodity Suppliers", log); if (response.Success) { ContactsList.Clear(); var coResponse = await SaveCommodityOwner(commodityOwner); if (coResponse.ErrorInfo != "") responseMsg += coResponse.ErrorInfo + "\n"; var contactResponse = await SaveSupplierContact(contact); if (contactResponse.ErrorInfo != "") responseMsg += contactResponse.ErrorInfo + "\n"; var cpResponse = await SaveCommodityProducer(commodityProducer); if (cpResponse.ErrorInfo != "") responseMsg += cpResponse.ErrorInfo + "\n"; if (!coResponse.Success || !cpResponse.Success) response.Success = false; } if (response.Success) { responseMsg = "Farmer Successfully Added "; MessageBox.Show(responseMsg, "Agrimanagr: Manage Farmer", MessageBoxButton.OK, MessageBoxImage.Information); SendNavigationRequestMessage( new Uri("views/admin/Supplier/ListOfSuppliers.xaml", UriKind.Relative)); } else { MessageBox.Show(responseMsg, "Agrimanagr: Manage Farmer", MessageBoxButton.OK, MessageBoxImage.Information); } } }
private async Task<ImportValidationResultInfo> ValidateEntityeAsync(CommoditySupplier commodityType) { return await Task.Run(() => { var res = _commoditySupplierRepository.Validate(commodityType); return new ImportValidationResultInfo() { Results = res.Results, // Description = "Row-" + count, Entity = commodityType }; }); }
public CommoditySupplierDTO Map(CommoditySupplier commoditySupplier) { if (commoditySupplier == null) return null; var commoditySupplierDto = Mapper.Map<CommoditySupplier, CommoditySupplierDTO>(commoditySupplier); return commoditySupplierDto; }
public void Save(CommoditySupplierDTO model) { CommoditySupplier commoditySupplier = new CommoditySupplier(model.MasterId); commoditySupplier.AccountName = model.Name; commoditySupplier.Name = model.Name; commoditySupplier.CostCentreCode = model.CostCentreCode; commoditySupplier.CommoditySupplierType = (CommoditySupplierType)model.CommoditySupplierTypeId; commoditySupplier.JoinDate = DateTime.Now; commoditySupplier.AccountNo = model.AccountNo; commoditySupplier.PinNo = model.PinNo; commoditySupplier.BankId = model.BankId; commoditySupplier.BankBranchId = model.BankBranchId; commoditySupplier._Status = EntityStatus.Active; commoditySupplier.ParentCostCentre = new CostCentreRef { Id = model.ParentCostCentreId }; commoditySupplier.CostCentreType = CostCentreType.CommoditySupplier; _commoditySupplierRepository.Save(commoditySupplier); }
private ValidationResultInfo Validate(CommoditySupplier commoditySupplier) { return _commoditySupplierRepository.Validate(commoditySupplier); }
private void CommoditySupplierChanged() { using (var container = NestedContainer) { var selected = Using<IAgriItemsLookUp>(container).SelectCommoditySupplier(); SelectedCommoditySupplier = selected; if (selected == null) { SelectedCommoditySupplier = new CommoditySupplier(Guid.Empty) { Name = "--Select Commodity Supplier---" }; SelectedCommoditySupplierName = "--Select Account---"; } else { SelectedCommoditySupplierName = SelectedCommoditySupplier.Name; LoadUnassignedGrn(SelectedCommoditySupplier.Id); LoadAssignedGrn(SelectedCommoditySupplier.Id); } } }
void ClearViewModel() { DocumentReference = string.Empty; Notes = ""; SelectedAccountName = "--Select Account---"; ; SelectedFarmerName = "--Select Farmer---"; DocumentId = Guid.Empty; SelectedAccount = new CommoditySupplier(Guid.Empty) { AccountName = "--Select Account---" }; SelectedFarmer = new CommodityOwner(Guid.Empty) { FirstName = "--Select Farmer---" }; DocumentIssuerUser = null; DocumentParentId = Guid.Empty; SelectedCommodity = new Commodity(Guid.Empty) { Name = "--Select Commodity---" }; ; SelectedGrade = new CommodityGrade(Guid.Empty) { Name = "--Select Grade---" }; DocumentIssuerCostCentre = null; DocumentRecipientCostCentre = null; DriverName = ""; RegistrationNumber = ""; Weight = decimal.Zero; LineItems.Clear(); FarmersList.Clear(); CommodityList.Clear(); GradeList.Clear(); FarmerVisibility = "Collapsed"; WeighTypeProp = WeighType.Manual; // MakeWeightextBoxReadOnly = false; }
private void SelectAccount() { using (var container = NestedContainer) { var selected = Using<IAgriItemsLookUp>(container).SelectCommoditySupplier(); SelectedAccount = selected; if (selected == null) { SelectedAccount = new CommoditySupplier(Guid.Empty) { AccountName = "--Select Account---" }; FarmerVisibility = "Collapsed"; } else { SelectedAccountName = SelectedAccount.Name; if (SelectedAccount.CommoditySupplierType == CommoditySupplierType.Cooperative) { if (SelectedFarmer != null && SelectedFarmer.Id != SelectedAccount.Id) { SelectedFarmer = new CommodityOwner(Guid.Empty) { FirstName = "--Select Farmer---" }; SelectedFarmerName = "--Select Farmer---"; } FarmerVisibility = "Visible"; } else { SelectedFarmer = Using<ICommodityOwnerRepository>(container).GetBySupplier(SelectedAccount.Id).FirstOrDefault(); FarmerVisibility = "Collapsed"; } } } }
private void CommmoditySupplierChanged() { using (var container = NestedContainer) { var selected = Using<IAgriItemsLookUp>(container).SelectCommoditySupplier(); SelectedCommoditySupplier = selected; if (selected == null) { SelectedCommoditySupplier = new CommoditySupplier(Guid.Empty) { Name = "--Select Commodity Supplier---" }; SelectedCommoditySupplierName = "--Select Commdity Supplier---"; var query = new QueryCommoditySupplierInventory(); if (SelectedStore.Id != Guid.Empty) { query.StoreId = SelectedStore.Id; } QueryCommoditySupplierInventoryLevel = query; IsSet = true; LoadCommoditySupplierInventoryList(IsSet); } else { SelectedCommoditySupplierName = SelectedCommoditySupplier.Name; var query = new QueryCommoditySupplierInventory(); query.CommoditySupplierId = selected.Id; if(SelectedStore.Id!=Guid.Empty) { query.StoreId = SelectedStore.Id; } QueryCommoditySupplierInventoryLevel = query; IsSet = true; LoadCommoditySupplierInventoryList(IsSet); } } }
protected Guid AddCommoditySupplier(string acc,Guid bbn, Guid bn, CommoditySupplierType stype,string code, CostCentreType ctype, string name, CostCentreRef parent, string pin) { CommoditySupplier cs = new CommoditySupplier(Guid.NewGuid()) { AccountName = acc, AccountNo = acc, BankBranchId = bbn, BankId = bn, CommoditySupplierType = stype, CostCentreCode = code, CostCentreType = ctype, JoinDate = DateTime.Now, Name = name, ParentCostCentre = parent, PinNo = pin, _Status = EntityStatus.Active, }; return _commoditySupplierRepository.Save(cs); }
public async Task<ResponseBool> CommoditySupplierAddAsync(CommoditySupplier commoditySupplier) { ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" }; string url = string.Format("api/distributorservices/commoditysupplieradd"); var httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await httpClient.PostAsJsonAsync(url, commoditySupplier); _response = await response.Content.ReadAsAsync<ResponseBool>(); } catch (Exception ex) { _log.Error("Failed to update commodity supplier.", ex); } return _response; }
private VMCommodityOwnerItem Map(CommoditySupplier commodityOwner, int i) { var mapped = new VMCommodityOwnerItem { CommoditySupplier = commodityOwner, RowNumber = i }; if (commodityOwner._Status == EntityStatus.Active) mapped.HlkDeactivateContent = "Deactivate"; else if (commodityOwner._Status == EntityStatus.Inactive) mapped.HlkDeactivateContent = "Activate"; return mapped; }
private VMCommoditySupplierItem Map(CommoditySupplier cs, int index) { VMCommoditySupplierItem mapped = new VMCommoditySupplierItem { CommoditySupplier = cs, RowNumber = index + 1 }; if (cs._Status == EntityStatus.Active) mapped.HlkDeactivateContent = "Deactivate"; else if (cs._Status == EntityStatus.Inactive) mapped.HlkDeactivateContent = "Activate"; return mapped; }
public HttpResponseMessage CommoditySupplierAdd(CommoditySupplier commoditySupplier) { var response = new ResponseBool { Success = false }; try { _commoditySupplierRepository.Save(commoditySupplier); response.Success = true; response.ErrorInfo = "Commodity supplier successfully added."; } catch (DomainValidationException dve) { string errorMsg = dve.ValidationResults.Results.Aggregate("Error: Invalid commodity supplier fields.\n", (current, msg) => current + ("\t- " + msg.ErrorMessage + "\n")); response.ErrorInfo = errorMsg; _log.Error(errorMsg, dve); } catch (Exception ex) //any other { response.ErrorInfo = "Error: An error occurred when saving the commodity supplier.\n" + ex.ToString(); _log.Error("Error: An error occurred when saving the commodity supplier.", ex); } return Request.CreateResponse(HttpStatusCode.OK, response); }