async void SaveProjectBudgetLine(EmployeeSchedulerLocal proBudgetLine, SchedulerAction action)
        {
            busyIndicator.IsBusy = true;
            var result = ErrorCodes.NoSucces;

            switch (action)
            {
            case SchedulerAction.Delete:
                result = await api.Delete(proBudgetLine);

                break;

            case SchedulerAction.Insert:
                result = await api.Insert(proBudgetLine);

                break;

            case SchedulerAction.Modify:
                result = await api.Update(proBudgetLine);

                break;
            }
            busyIndicator.IsBusy = false;
            if (result != ErrorCodes.Succes)
            {
                UnicontaMessageBox.Show(result.ToString(), Uniconta.ClientTools.Localization.lookup("Error"), MessageBoxButton.OK);
            }
        }
 private void EmployeeScheduler_AppointmentDrop(object sender, AppointmentItemDragDropEventArgs e)
 {
     e.Allow = (bool)e.ViewModels[0].CustomFields["IsBudgetLine"] && e.HitResource.Id.ToString() == "1";
     if (e.Allow)
     {
         AppointmentDragResizeViewModel viewModel = e.ViewModels[0];
         viewModel.Appointment.ResourceId = "1";
         var appointment = viewModel.Appointment.SourceObject as EmployeeSchedulerLocal;
         if (viewModel != null && appointment != null)
         {
             _currentCorasauBaseEntity = null;
             appointment.IsBudgetLine  = true;
             appointment.TaskType      = "1";
             appointment.Date          = viewModel.Start;
             appointment.FromTime      = viewModel.Start;
             appointment.NotifyPropertyChanged("FromTime");
             appointment.ToTime = viewModel.End;
             appointment.NotifyPropertyChanged("ToTime");
         }
     }
     else
     {
         AppointmentDragResizeViewModel viewModel = e.ViewModels[0];
         viewModel.Appointment.ResourceId = e.HitResource.Id.ToString();
         var appointment = viewModel.Appointment.SourceObject as EmployeeSchedulerLocal;
         var apt         = new EmployeeSchedulerLocal();
         if (viewModel != null && appointment != null)
         {
             _currentCorasauBaseEntity = null;
             apt.IsBudgetLine          = false;
             apt.TaskType = "2";
             apt.Date     = viewModel.Start;
             apt.FromTime = viewModel.Start;
             apt.NotifyPropertyChanged("FromTime");
             apt.ToTime = viewModel.End;
             apt.NotifyPropertyChanged("ToTime");
         }
     }
 }
        async Task SetList()
        {
            busyIndicator.IsBusy = true;
            var projects = await api.Query <ProjectLocal>();

            _projectList = new List <ProjectLocal>();
            foreach (var proj in projects)
            {
                int projNumber = 0;
                int.TryParse(proj.Number, out projNumber);
                proj.Color = GetColorForLabel(projNumber);
                _projectList.Add(proj);
            }

            var costList = await api.Query <CostCategoryLocal>();

            _costCatList = costList.ToList();

            // for ProjectBudgetLineClient
            var projBudget = await api.Query <ProjectBudgetClient>();

            var _projectBudget = projBudget.FirstOrDefault(x => x._Current == true);

            if (_projectBudget == null)
            {
                _projectBudget          = new ProjectBudgetClient();
                _projectBudget.Name     = Uniconta.ClientTools.Localization.lookup("Default");
                _projectBudget._Current = true;
                _projectBudget.SetMaster(api.CompanyEntity);
                var err = await api.Insert(_projectBudget);

                if (err != ErrorCodes.Succes)
                {
                    UtilDisplay.ShowErrorCode(err);
                    return;
                }
            }

            var projBudgetLinesLst = await api.Query <EmployeeSchedulerLocal>(new UnicontaBaseEntity[] { _projectBudget, Employee }, null);

            _empSchedulerLinesLst = new ObservableCollection <EmployeeSchedulerLocal>(projBudgetLinesLst);

            // for ProjectJournalLineClient
            var projJournalLinesLst = await api.Query <ProjectJournalLineClient>(_masterList, null);

            var Comp  = api.CompanyEntity;
            var cache = Comp.GetCache(typeof(Uniconta.DataModel.PrCategory));

            if (cache != null)
            {
                foreach (var empJournalLine in projJournalLinesLst)
                {
                    var rec = (Uniconta.DataModel.PrCategory)cache.Get(empJournalLine._PrCategory);
                    if (rec != null && rec._CatType == Uniconta.DataModel.CategoryType.Labour)
                    {
                        var item = new EmployeeSchedulerLocal()
                        {
                            _Date        = empJournalLine._Date,
                            _Project     = empJournalLine._Project,
                            _PrCategory  = empJournalLine._PrCategory,
                            _Task        = empJournalLine._Task,
                            _FromTime    = empJournalLine._TimeFrom,
                            _ToTime      = empJournalLine._TimeTo,
                            _Text        = empJournalLine._Text,
                            _Qty         = empJournalLine._Qty,
                            _CostPrice   = empJournalLine._CostPrice,
                            _SalesPrice  = empJournalLine._SalesPrice,
                            _Item        = empJournalLine._Item,
                            IsBudgetLine = false,
                            TaskType     = "2"
                        };
                        _empSchedulerLinesLst.Add(item);
                    }
                }
            }
            busyIndicator.IsBusy = false;
        }