async void SaveAndOpenLines(ProjectBudgetClient selectedItem) { if (dgProjectBudgetGrid.HasUnsavedData) { var tsk = saveGrid(selectedItem); if (tsk != null && (CopiedData || selectedItem.RowId == 0)) { await tsk; } } if (selectedItem.RowId != 0) { AddDockItem(TabControls.ProjectBudgetLinePage, dgProjectBudgetGrid.syncEntity, string.Format("{0} {1}: {2}", Uniconta.ClientTools.Localization.lookup("Budget"), Uniconta.ClientTools.Localization.lookup("Lines"), selectedItem._Project)); } }
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; }
private void localMenu_OnItemClicked(string ActionType) { string header = string.Empty; ProjectBudgetClient selectedItem = GetSelectedItem(out header); switch (ActionType) { case "AddRow": dgProjectBudgetGrid.AddRow(); break; case "CopyRow": CopiedData = true; dgProjectBudgetGrid.CopyRow(); break; case "SaveGrid": saveGrid(selectedItem); break; case "DeleteRow": if (selectedItem != null && UnicontaMessageBox.Show(string.Format(Uniconta.ClientTools.Localization.lookup("ConfirmDeleteOBJ"), selectedItem._Name), Uniconta.ClientTools.Localization.lookup("Confirmation"), #if !SILVERLIGHT MessageBoxButton.YesNo) == MessageBoxResult.Yes) #else MessageBoxButton.OKCancel) == MessageBoxResult.OK) #endif { dgProjectBudgetGrid.DeleteRow(); } break; case "BudgetLines": if (selectedItem != null) { SaveAndOpenLines(selectedItem); } break; case "BudgetCategorySum": if (selectedItem != null) { AddDockItem(TabControls.ProjectBudgetCategorySumPage, selectedItem, header); } break; case "CreateBudget": CreateBudget(); break; case "UpdatePrices": if (dgProjectBudgetGrid.ItemsSource != null) { UpdatePrices(); } break; case "RefreshGrid": gridRibbon_BaseActions(ActionType); break; default: gridRibbon_BaseActions(ActionType); break; } }