private void EditAction(object obj) { var form = new Views.Pages.TambahMahasiswaView(SelectedItem.Clone() as Mahasiswa); form.ShowDialog(); var viewmodel = form.DataContext as TambahMahasiswaViewModel; if (viewmodel != null && viewmodel.Model != null) { var result = DataSource.Where(x => x.IDMahasiswa == SelectedItem.IDMahasiswa).FirstOrDefault(); if (result != null) { result.IdJurusan = viewmodel.Model.IdJurusan; result.Jurusan = viewmodel.Jurusan; result.Gelombang = viewmodel.Model.Gelombang; result.HasilTest = viewmodel.Model.HasilTest; result.IdProgdi = viewmodel.Model.IdProgdi; result.IPK = viewmodel.Model.IPK; result.MasaStudi = viewmodel.Model.MasaStudi; result.NPM = viewmodel.Model.NPM; result.Suku = viewmodel.Model.Suku; result.Nama = viewmodel.Model.Nama; result.GelombangModel = viewmodel.Model.GelombangModel; } Source.Refresh(); } }
public void EditTask() { if (SelectedItem == null) { return; } EditTaskCore(SelectedItem.Clone(), false); }
protected virtual void OnSelectedItemChanged() { ActiveFilterItem = SelectedItem.Clone(); UpdateFilterExpression(); if (NavigateAction != null) { NavigateAction(); } }
private void UpdateMethods() { if (IsValid != true || SelectedItem == null || string.IsNullOrEmpty(OperationCode)) { return; } var methods = SelectedItem.PmMethodCodes; var emptyresult = new EditableBusinessObjectCollection <object>(); emptyresult.AcceptChanges(); if (!methods.ContainsKey(OperationCode)) { methods[OperationCode] = emptyresult; } if (methods[OperationCode] == null) { methods[OperationCode] = emptyresult; } var result = methods[OperationCode]; var id = SelectedItem.Id; var key = string.Format("{0}:{1}", id, OperationCode); if (!_owner.IsDeleted.ContainsKey(key)) { _owner.IsDeleted[key] = true; if (!_owner.DataForDelete.ContainsKey(id)) { _owner.DataForDelete[id] = SelectedItem.Clone(); } var oldvalue = result == null ? new EditableBusinessObjectCollection <object>() : new EditableBusinessObjectCollection <object>(result); oldvalue.AcceptChanges(); _owner.DataForDelete[id].PmMethodCodes[OperationCode] = oldvalue; } //Показываем выбранные методы в гриде result.Clear(); if (SelectedMethods != null) { foreach (var m in SelectedMethods) { result.Add(m); } result.AcceptChanges(); } if (!NotNeedRefresh) { SetIsDirty(); } }
/// <summary> /// Установить полуприцеп или водителя. /// </summary> /// <param name="setDriver">True - установить водителя. False - установить полуприцеп.</param> /// <returns></returns> async Task Set(bool setDriver) { int current = 0; BaseId res; if (setDriver) { current = SelectedItem.DriverId.HasValue ? SelectedItem.DriverId.Value : -1; res = await dialogManager.SelectDriver(current); } else { current = SelectedItem.SemitrailerId.HasValue ? SelectedItem.SemitrailerId.Value : -1; res = await dialogManager.SelectSemitrail(current); } if (res == null) { return; } var copy = (Truck)SelectedItem.Clone(); if (setDriver) { copy.DriverId = res.Id; } else { copy.SemitrailerId = res.Id; } var update = await context.Invoker.UpdateAsync(copy); if (update) { if (setDriver) { SelectedItem.Driver = (Driver)res; SelectedItem.DriverId = res.Id; messageQueue.Enqueue("Водитель установлен"); Logger.Log.Info($"Водитель поставлен на машину (id: {SelectedItem.Id})"); } else { SelectedItem.Semitrailer = (Semitrailer)res; SelectedItem.SemitrailerId = res.Id; Logger.Log.Info($"Полуприцеп поставлен на машину (id: {SelectedItem.Id})"); } RaisePropertyChanged(nameof(SelectedItem)); } }
void CustomizeItem() { Spell newSpell = SelectedItem.Clone() as Spell; newSpell.DBLoaderID = 0; SpellEditorActivity.Spell = SelectedItem; SpellEditorActivity.EditorAction = SpellEditorActivity.EditorActionType.Add; Intent intent = new Intent(_v.Context, Java.Lang.Class.FromType(typeof(SpellEditorActivity))); _v.Context.StartActivity(intent); }
void CustomizeButtonClicked(object sender, EventArgs e) { monsterDialog = new MonsterEditorDialog((Monster)SelectedItem.Clone()); monsterDialog.MonsterEditorComplete += (s, monster) => { MonsterDB.DB.AddMonster(monster); Monster.Monsters.Add(monster); Filter(true); }; MainUI.MainView.AddSubview(monsterDialog.View); }
void EditButtonClicked(object sender, EventArgs e) { if (SelectedItem.IsCustom) { monsterDialog = new MonsterEditorDialog((Monster)SelectedItem.Clone()); monsterDialog.MonsterEditorComplete += (s, monster) => { MonsterDB.DB.UpdateMonster(monster); Filter(true); }; MainUI.MainView.AddSubview(monsterDialog.View); } }
protected override void Edit() { SupplierProductDTO editCondition = SelectedItem.Clone(); ConditionDetailViewModel detailModelView = new ConditionDetailViewModel(editCondition, false); if (NavigationService.NavigateTo("Detail", detailModelView) == NavigationResult.Ok) { int index = Items.IndexOf(SelectedItem); Items.Remove(SelectedItem); Items.Insert(index, editCondition); SelectedItem = editCondition; ParentObject.MarkChildForUpdate(editCondition); } }
protected override void Edit() { OrderDetailDTO editOrderDetail = SelectedItem.Clone(); OrderItemDetailViewModel detailModelView = new OrderItemDetailViewModel(editOrderDetail, false); if (NavigationService.NavigateTo("Detail", detailModelView) == NavigationResult.Ok) { int index = Items.IndexOf(SelectedItem); Items.Remove(SelectedItem); Items.Insert(index, editOrderDetail); SelectedItem = editOrderDetail; ParentObject.MarkChildForUpdate(editOrderDetail); } }
void CustomizeItem() { if (SelectedItem != null) { Monster sourceMonster = SelectedItem.Clone() as Monster; sourceMonster.DBLoaderID = 0; MonsterEditorActivity.SourceMonster = sourceMonster; MonsterEditorActivity.DBMonster = true; Intent intent = new Intent(this.Context, (Java.Lang.Class) new MonsterEditorMainActivity().Class); intent.AddFlags(ActivityFlags.NewTask); Context.StartActivity(intent); } }
public WorkingLogDetailPageViewModel(INavigationService navigationService, IPageDialogService dialogService, WorkingLogDetailService workingLogDetailService, ProjectService projectService, RefreshTokenService refreshTokenService, SystemStatusService systemStatusService, AppStatus appStatus) { this.navigationService = navigationService; this.dialogService = dialogService; this.workingLogDetailService = workingLogDetailService; this.projectService = projectService; this.refreshTokenService = refreshTokenService; this.systemStatusService = systemStatusService; this.appStatus = appStatus; #region 新增紀錄 AddCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = new WorkingLogDetailDto(); fooObject.WorkingLogId = MasterItem.Id; paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudAddAction); paras.Add(MagicStringHelper.MasterRecordActionName, MasterItem); await navigationService.NavigateAsync("WorkingLogDetailRecordPage", paras); }); #endregion #region 點選某筆紀錄觸發命令 ItemTappedCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = SelectedItem.Clone(); paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudEditAction); paras.Add(MagicStringHelper.MasterRecordActionName, MasterItem); await navigationService.NavigateAsync("WorkingLogDetailRecordPage", paras); }); #endregion #region 更新遠端紀錄命令 RefreshCommand = new DelegateCommand(async() => { IsRefresh = true; await ReloadData(); IsRefresh = false; }); #endregion }
private void editSelectedItem() { if (!UIHelper.EnsurePremiumLicence()) { return; } var dlg = new EditDomainObjectWindow(); var ctrl = new usrMyPlaceDetails(); dlg.SetControl(ctrl); ctrl.Fill(SelectedItem.Clone()); if (dlg.ShowDialog() == true) { replace(SelectedItem, ctrl.MyPlace); } }
public void EditSelectedItem() { if (!UIHelper.EnsureInstructorLicence()) { return; } var dlg = new EditDomainObjectWindow(); var ctrl = new usrCustomerGroupDetails(); dlg.SetControl(ctrl); ctrl.Fill(SelectedItem.Clone()); if (dlg.ShowDialog() == true) { replace(SelectedItem, ctrl.CustomerGroup); } }
private void EditAction(object obj) { var form = new Views.Pages.TambahJurusanView(SelectedItem.Clone() as Jurusan); form.ShowDialog(); var viewmodel = form.DataContext as TambahJurusanModel; if (viewmodel != null && viewmodel.Model != null) { var result = DataSource.Where(x => x.Id == SelectedItem.Id).FirstOrDefault(); if (result != null) { result.Kode = viewmodel.Model.Kode; result.Name = viewmodel.Model.Name; } Source.Refresh(); } }
// Creates new item with default values or creates copy of currently selected item. Newly created item is selected. public void CreateItem() { PersonViewModel person = null; if (SelectedItem != null) { person = (PersonViewModel)SelectedItem.Clone(); person.LastName += " Copy"; } else { person = new PersonViewModel( Resource.NewPerson_FirstName, Resource.NewPerson_LastName, Resource.NewPerson_Description); } items.Add(person); SelectedItem = person; }
/// <summary> /// Удаление водителя или полуприцепа из машины. /// </summary> /// <param name="removeDriver">True - удаление водителя. False - удаление полуприцепа.</param> /// <returns></returns> async Task Remove(bool removeDriver) { var copy = (Truck)SelectedItem.Clone(); if (removeDriver) { copy.Driver = null; copy.DriverId = null; } else { copy.Semitrailer = null; copy.SemitrailerId = null; } var res = await context.Invoker.UpdateAsync(copy); if (res) { if (removeDriver) { SelectedItem.Driver = null; SelectedItem.DriverId = null; messageQueue.Enqueue("Водитель снят"); Logger.Log.Info($"Водитель снят с машины (id: {SelectedItem.Id})"); } else { SelectedItem.Semitrailer = null; SelectedItem.SemitrailerId = null; messageQueue.Enqueue("Полуприцеп снят"); Logger.Log.Info($"Полуприцеп снят с машины (id: {SelectedItem.Id})"); } RaisePropertyChanged(nameof(SelectedItem)); } }
private void InitCommands() { AddCommand = new DelegateCommand(() => { AddEditWindow aer = new AddEditWindow(); IRepositoryItem result = aer.Show(null); if (result != null) { if (SelectedItem != null) { result.Parent = SelectedItem; SelectedItem.Items.Add(result); } else { result.Parent = null; RepositoryItems.Add(result); } App.Log.Log(String.Format("В репозиторий добавлен элемент <{0}>", result)); OnPropertyChanged("IsEmptyList"); Save(); } }); RemoveCommand = new DelegateCommand(() => { if (SelectedItem == null) { return; } if (App.ShowQuestion("Вы действительно хотите удалить запись с именем '" + SelectedItem.Title + "'?") == System.Windows.MessageBoxResult.Yes) { IRepositoryItem parent = SelectedItem.Parent; if (parent != null) { parent.Items.Remove(SelectedItem); } else { RepositoryItems.Remove(SelectedItem); } App.Log.Log(String.Format("Из репозитория удалён элемент <{0}>", SelectedItem)); Save(); } }, (param) => { return(SelectedItem != null); }); EditCommand = new DelegateCommand(() => { if (SelectedItem == null) { throw new InvalidOperationException("EditCommand - SelectedItem == null"); } App.Log.Log(String.Format("Попытка изменения элемента репозитория: <{0}>", SelectedItem)); AddEditWindow aer = new AddEditWindow(); aer.Owner = App.Current.MainWindow; IRepositoryItem result = aer.Show(SelectedItem.Clone()); if (result != null) { IRepositoryItem parent = SelectedItem.Parent; if (parent != null) { int index = parent.Items.IndexOf(SelectedItem); if (index > 0) { parent.Items[index] = result; } SelectedItem = result; } else { SelectedItem = result; } App.Log.Log(String.Format("Изменённый элемент репозитория: <{0}>", result)); Save(); } }, (param) => { return(SelectedItem != null); }); LoadCommand = new DelegateCommand(() => { if (SelectedItem == null) { throw new InvalidOperationException("EditCommand - SelectedItem == null"); } if (SelectedItem.Type == RepositoryItemType.Group) { throw new ArgumentException("Выбрана не запись, а группа!"); } SqlViewModel = (SelectedItem as RepositoryItem).SqlViewModel; FuncSqlViewModelSelected?.Invoke(this, new SelectFuncSqlViewModelEventArgs(SelectedItem.Title, SqlViewModel)); App.Log.Log(String.Format("Выбран элемент репозитория: <{0}>", SelectedItem)); }, (param) => { return(SelectedItem is RepositoryItem); }); ImportCommand = new DelegateCommand(() => { if (RepositoryItems != null && RepositoryItems.Count > 0) { if (App.ShowQuestion("Очистить список перед импортом'?") == System.Windows.MessageBoxResult.Yes) { RepositoryItems.Clear(); } } Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); ofd.AddExtension = true; ofd.CheckFileExists = true; ofd.Filter = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION); ofd.FilterIndex = 0; bool?show = ofd.ShowDialog(Application.Current.MainWindow); if (show != null && show.HasValue && show.Value == true) { App.Log.Log("Попытка импорта списка запросов из файла '" + ofd.FileName + "'"); bool success = true; IList <IRepositoryItem> list = Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonDeSerialize( ofd.FileName, (e) => { success = false; App.ToLogException(e); App.ShowError(String.Format("Не удалось импортировать список запросов.\n\t{0}", e.Message), "ОШИБКА"); }); if (list != null) { var notImported = new List <IRepositoryItem>(); foreach (var item in list) { if (_repository.AddRepositoryItem(item) == false) { notImported.Add(item); } } int toImportCount = GetRequestsCountInList(list); int notImportedCount = GetRequestsCountInList(notImported); int allCount = GetRequestsCountInList(RepositoryItems); string message = String.Format("Завершён. Импортировано {0} запросов из списка. Не удалось импортировать {1} запросов. Всего сейчас в списке {2} запросов.", toImportCount - notImportedCount, notImportedCount, allCount); App.Log.Log(message); App.ShowInfo(message, "ИМПОРТ"); } else if (success) { string message = "Ничего не импортировано. Файл пуст!"; App.Log.Log(message); App.ShowInfo(message, "ИМПОРТ"); } } }); ExportCommand = new DelegateCommand(() => { Microsoft.Win32.SaveFileDialog ofd = new Microsoft.Win32.SaveFileDialog(); ofd.AddExtension = true; ofd.Filter = String.Format("Файл списка запросов (*{0})|*{0}", RequestsRepository.REPOSITORY_FILE_EXTENSION); ofd.FilterIndex = 0; bool?show = ofd.ShowDialog(Application.Current.MainWindow); if (show != null && show.HasValue && show.Value == true) { App.Log.Log("Попытка экспорта списка запросов в файл '" + ofd.FileName + "'"); bool success = true; Common.RepositoryCommon.BaseDeserializer <List <IRepositoryItem> > .GzJsonSerialize( RepositoryItems.ToList(), ofd.FileName, (e) => { success = false; App.ToLogException(e); App.ShowError(String.Format("Не удалось экспортировать список запросов.\n\t{0}", e.Message), "ОШИБКА"); }); if (success) { string message = String.Format("Экспортировано {0} запросов.", RepositoryItems.Count); App.Log.Log(message); App.ShowInfo(message, "ЭКСПОРТ"); } } }, (param) => { if (RepositoryItems == null) { return(false); } else { return(RepositoryItems.Count != 0); } }); }
protected virtual void OnSelectedItemChanged() { ActiveFilterItem = SelectedItem.Clone(); UpdateFilterExpression(); NavigateCore(); }
public TravelExpensePageViewModel(INavigationService navigationService, IPageDialogService dialogService, TravelExpenseService travelExpenseService, MyUserService myUserService, TravelExpenseDetailService travelExpenseDetailService, RefreshTokenService refreshTokenService, SystemStatusService systemStatusService, AppStatus appStatus) { this.navigationService = navigationService; this.dialogService = dialogService; this.travelExpenseService = travelExpenseService; this.myUserService = myUserService; this.travelExpenseDetailService = travelExpenseDetailService; this.refreshTokenService = refreshTokenService; this.systemStatusService = systemStatusService; this.appStatus = appStatus; #region 新增紀錄 AddCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = new TravelExpenseDto(); fooObject.ApplyDate = DateTime.Now.Date; #region 設定該使用者為預設紀錄申請者 var myUser = myUserService.Items .FirstOrDefault(x => x.Id == appStatus.SystemStatus.UserID); if (myUser != null) { fooObject.MyUserId = myUser.Id; fooObject.MyUserName = myUser.Name; } #endregion paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudAddAction); await navigationService.NavigateAsync("TravelExpenseRecordPage", paras); }); #endregion #region 點選某筆紀錄觸發命令 ItemTappedCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = SelectedItem.Clone(); paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudEditAction); await navigationService.NavigateAsync("TravelExpenseRecordPage", paras); }); #endregion #region 更新遠端紀錄命令 RefreshCommand = new DelegateCommand(async() => { IsRefresh = true; await ReloadData(); IsRefresh = false; }); #endregion #region 顯示明細頁面 ShowDetailCommand = new DelegateCommand <TravelExpenseDto>(async x => { #region 讀取該筆明細清單 using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,更新資料中...", null, null, true, MaskType.Black)) { await AppStatusHelper.ReadAndUpdateAppStatus(systemStatusService, appStatus); #region 檢查 Access Token 是否還可以使用 bool refreshTokenResult = await RefreshTokenHelper .CheckAndRefreshToken(dialogService, refreshTokenService, systemStatusService, appStatus); if (refreshTokenResult == false) { return; } #endregion #region 取得 差旅費用明細紀錄 fooIProgressDialog.Title = "請稍後,取得 差旅費用明細紀錄"; var apiResultssss = await travelExpenseDetailService.GetAsync(x.Id); if (apiResultssss.Status == true) { await travelExpenseDetailService.WriteToFileAsync(); NavigationParameters paras = new NavigationParameters(); paras.Add(MagicStringHelper.MasterRecordActionName, x); await navigationService.NavigateAsync("TravelExpenseDetailPage", paras); } else { await DialogHelper.ShowAPIResultIsFailureMessage(dialogService, apiResultssss); return; } #endregion } #endregion }); #endregion }
public void Update() { EditItem = (TViewModel)SelectedItem.Clone(); EditItem.OnErrorChanged += EditItem_OnErrorChanged; OpenUpdateWindow(); }
public LeaveFormPageViewModel(INavigationService navigationService, IPageDialogService dialogService, LeaveFormService leaveFormService, LeaveCategoryService leaveCategoryService, MyUserService myUserService, RefreshTokenService refreshTokenService, SystemStatusService systemStatusService, AppStatus appStatus) { this.navigationService = navigationService; this.dialogService = dialogService; this.leaveFormService = leaveFormService; this.leaveCategoryService = leaveCategoryService; this.myUserService = myUserService; this.refreshTokenService = refreshTokenService; this.systemStatusService = systemStatusService; this.appStatus = appStatus; #region 新增紀錄 AddCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = new LeaveFormDto(); fooObject.FormDate = DateTime.Now.Date; fooObject.BeginDate = DateTime.Now.AddDays(1).Date + new TimeSpan(09, 00, 00); fooObject.CompleteDate = DateTime.Now.AddDays(1).Date + new TimeSpan(18, 00, 00); fooObject.Hours = 8.0m; #region 設定該使用者為預設紀錄申請者 var myUser = myUserService.Items .FirstOrDefault(x => x.Id == appStatus.SystemStatus.UserID); if (myUser != null) { fooObject.MyUserId = myUser.Id; fooObject.MyUserName = myUser.Name; } #endregion paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudAddAction); await navigationService.NavigateAsync("LeaveFormRecordPage", paras); }); #endregion #region 點選某筆紀錄觸發命令 ItemTappedCommand = new DelegateCommand(async() => { NavigationParameters paras = new NavigationParameters(); var fooObject = SelectedItem.Clone(); paras.Add(MagicStringHelper.CurrentSelectdItemParameterName, fooObject); paras.Add(MagicStringHelper.CrudActionName, MagicStringHelper.CrudEditAction); await navigationService.NavigateAsync("LeaveFormRecordPage", paras); }); #endregion #region 更新遠端紀錄命令 RefreshCommand = new DelegateCommand(async() => { IsRefresh = true; await ReloadData(); IsRefresh = false; }); #endregion }