Example #1
0
        protected override async Task MapEditedItemToEditor(Branch item)
        {
            SelectedCountry = CountryList.FirstOrDefault(e => e.Id == item.CountryId);
            await OnCountrySelected(SelectedCountry);

            SelectedCity    = CityList.FirstOrDefault(e => e.Id == item.CityId);
            SelectedCompany = CompanyList.FirstOrDefault(e => e.Id == item.CompanyId);
            await base.MapEditedItemToEditor(item);
        }
        public void DeleteCompany(CompanyEntity newEntity)
        {
            CompanyEntity oldEntity = CompanyList.FirstOrDefault <CompanyEntity>(p => p.CompanyId == newEntity.CompanyId);

            if (oldEntity != null)
            {
                CompanyList.Remove(oldEntity);
            }

            CompanyList = new List <CompanyEntity>(_companyList);
        }
 private void OnSearchResult(object sender, NotificationEventArgs <BindingList <Company> > e)
 {
     if (e.Data != null && e.Data.Count > 0)
     {
         CompanyList     = e.Data;
         SelectedCompany = CompanyList.FirstOrDefault();
         Dirty           = false;
         AllowCommit     = false;
     }
     UnregisterToReceiveMessages <BindingList <Company> >(MessageTokens.CompanySearchToken.ToString(), OnSearchResult);
 }
        public void AddOrUpdateCompany(CompanyEntity newEntity)
        {
            CompanyEntity oldEntity = CompanyList.FirstOrDefault <CompanyEntity>(p => p.CompanyCode == newEntity.CompanyCode);

            if (oldEntity == null)
            {
                CompanyList.Insert(0, newEntity);
            }
            else
            {
                int index = CompanyList.IndexOf(oldEntity);
                CompanyList.Remove(oldEntity);
                CompanyList.Insert(index, newEntity);
            }

            CompanyList = new List <CompanyEntity>(_companyList);
        }
        public void Search()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                    var list = Factory.Resolve <ICompanyDS>().SearchCompanies(new CompanySearchEntity()
                    {
                        SearchText         = this.SearchText,
                        IsCustomer         = this.IsCustomer,
                        IsSupplier         = this.IsSupplier,
                        NotIncludedCompany = ApplicationHelper.CurrentUserProfile.CompanyId
                    });

                    var _Departmentlist = Factory.Resolve <ICompanyDS>().SearchDepartment(new DepartmentSearchEntity()
                    {
                        SearchText = ""
                    });
                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        CompanyList     = list;
                        DepartmentList  = _Departmentlist;
                        SelectedCompany = CompanyList.FirstOrDefault();
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
            //ShowDialog<uvCompanyDetailViewModel>(new uvCompanyDetailViewModel() {
            //    OriginalCompany = SelectCompany
            //});
        }
 private void ChangeKeyLogic()
 {
     if (!string.IsNullOrEmpty(SelectedCompany.CompanyID))
     {//check to see if key is part of the current List...
         Company query = CompanyList.Where(item => item.CompanyID == SelectedCompany.CompanyID &&
                                           item.AutoID != SelectedCompany.AutoID).FirstOrDefault();
         if (query != null)
         {
             //revert it back...
             SelectedCompany.CompanyID = SelectedCompanyMirror.CompanyID;
             //change to the newly selected item...
             SelectedCompany = query;
             return;
         }
         //it is not part of the existing list try to fetch it from the db...
         CompanyList = GetCompanyByID(SelectedCompany.CompanyID);
         if (CompanyList.Count == 0)//it was not found do new record required logic...
         {
             NotifyNewRecordNeeded("Record " + SelectedCompany.CompanyID + " Does Not Exist.  Create A New Record?");
         }
         else
         {
             SelectedCompany = CompanyList.FirstOrDefault();
         }
     }
     else
     {
         string errorMessage = "ID Is Required.";
         NotifyMessage(errorMessage);
         //revert back to the value it was before it was changed...
         if (SelectedCompany.CompanyID != SelectedCompanyMirror.CompanyID)
         {
             SelectedCompany.CompanyID = SelectedCompanyMirror.CompanyID;
         }
     }
 }
Example #7
0
 public void Add(int companyId)
 {
     base.Add();
     SelectedCompany = CompanyList.FirstOrDefault(e => e.Id == companyId);
 }