public void DeleteAgency(CHINHANH chiNhanh) { if (chiNhanh is null) { throw new System.ArgumentNullException(nameof(chiNhanh)); } using (var db = new QUANLYNHADATEntities()) { db.CHINHANHs.Remove(chiNhanh); db.SaveChanges(); } this.Reset(); }
private async void ExecuteEditAgencyCommand(int agencyId) { this.ModifiedAgency = ChiNhanhDAO.GetInstance().GetAgencyById(agencyId); this.AgencyDetailViewModel = new AgencyDetailViewModel { SelectedAgency = this.ModifiedAgency }; var view = new AgencyDetailDialog { DataContext = this.AgencyDetailViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, EditAgencyClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
private async void ExecuteDeleteAgencyCommand(int agencyId) { this.ModifiedAgency = ChiNhanhDAO.GetInstance().GetAgencyById(agencyId); var okeCancelDialogViewModel = new OkCancelDialogViewModel { Message = "Xóa chi nhánh này?" }; var view = new OkCancelDialogControl { DataContext = okeCancelDialogViewModel }; //show the dialog var result = await DialogHost.Show(view, BaseMainWindowViewModel.Instance.Identifier, ExtendedOpenedEventHandler, DeleteExtendedClosingEventHandler).ConfigureAwait(false); //check the result... Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL")); }
public void EditAgency(CHINHANH chiNhanh) { if (chiNhanh is null) { throw new System.ArgumentNullException(nameof(chiNhanh)); } using (var db = new QUANLYNHADATEntities()) { var agency = db.CHINHANHs.Find(chiNhanh.MACN); if (agency != null) { agency.FAX = chiNhanh.FAX; agency.SDT = chiNhanh.SDT; agency.DIACHI = chiNhanh.DIACHI; db.SaveChanges(); } } this.Reset(); }