public ModifyViewModel(ModifyView employeeOpen) { employeee = employeeOpen; Service.Service s = new Service.Service(); employed = s.GetAllEmployee().ToList(); }
/// <summary> /// Updates a fetched record. /// </summary> /// <param name="type">Type of modification mode.</param> /// <param name="record">Record to be modified.</param> public void Modify(ModifyView type, Record record) { int error = MsiInterop.MsiViewModify(this.Handle, Convert.ToInt32(type, CultureInfo.InvariantCulture), record.Handle); if (0 != error) { throw new MsiException(error); } }
public void ModifyMethod() { if (selectedCustomer != null) { ModifyView change = new ModifyView(); Messenger.Default.Send(new MessageMember(selectedCustomer, "edit")); change.Show(); } }
/// <summary> /// Updates a fetched record. /// </summary> /// <param name="type">Type of modification mode.</param> /// <param name="record">Record to be modified.</param> public void Modify(ModifyView type, Record record) { if (IntPtr.Zero == this.handle) { throw new ArgumentNullException(); // TODO: come up with a real exception to throw } uint error = MsiInterop.MsiViewModify(handle, Convert.ToInt32(type), record.InternalHandle); if (0 != error) { throw new System.Runtime.InteropServices.ExternalException("Failed to modify view", (int)error); } }
/// <summary> /// Method for deciding which View will open according to logged in Employee credentials /// </summary> private void LoginExecute() { try { switch (loggedEmployee.Role) { case "Admin": AdminView adminMenu = new AdminView(); adminMenu.ShowDialog(); loginView.Close(); break; case "Employee": EmployeeView employeeView = new EmployeeView(loggedEmployee.ID); employeeView.ShowDialog(); loginView.Close(); break; case "Manager": tblManager manager = Services.LogInService.GetManagerById(loggedEmployee.ID); if (manager.AccessLevel == "Modify") { ModifyView modify = new ModifyView(); modify.ShowDialog(); loginView.Close(); } else { ReadOnlyView readOnly = new ReadOnlyView(); readOnly.ShowDialog(); loginView.Close(); } break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void LoginExecute() { try { switch (role.RoleName) { case "WPFadmin": WPFadminView adminMenu = new WPFadminView(); adminMenu.ShowDialog(); break; case "Employee": AddReportView addReport = new AddReportView(); addReport.ShowDialog(); break; case "Manager": tblManager manager = Service.Service.GetManagerById(logged.EmployeeID); if (manager.AccessLevel == "Modify") { ModifyView modify = new ModifyView(); modify.ShowDialog(); } else { ReadOnlyView readOnly = new ReadOnlyView(); readOnly.ShowDialog(); } break; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
internal void SendModifyView(string schema, string name, string definer, ViewAlgorithm algorithm, ViewSqlSecurity security, ViewCheckOption check, string[] columns, QueryStatement queryStatement) { var builder = new ModifyView(); builder.Collection = ExprUtil.BuildCollection(schema, name); builder.Definer = definer; builder.Algorithm = algorithm; builder.Security = security; builder.Check = check; if (columns != null && columns.Length > 0) { foreach (string column in columns) { builder.Column.Add(column); } } if (queryStatement != null) { builder.Stmt = CreateFindMessage(queryStatement.schema, queryStatement.collection, queryStatement.isRelational, queryStatement.filter, queryStatement.findParams); } _writer.Write((int)ClientMessages.Types.Type.CrudModifyView, builder); }
public ModifyViewModel(ModifyView modifyOpen) { modify = modifyOpen; service = new Service(); EmployeeList = service.GetAllEmployees().ToList(); }
public MainViewModel() { ButtonIsEnabled = false; //Message receivers to accept messages from EditViewModel and AddViewModel //The sender also sends a token as the second parameter and only receivers with the same token will accept it. Messenger.Default.Register <Customer>(this, "add", (customer) => { try { // Code a query to retrieve the selected customer // and store the Customer object in the class variable. selectedCustomer = customer; CustomerIDBox = Convert.ToString(customer.CustomerID); this.DisplayCustomer(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }); Messenger.Default.Register <Customer>(this, "modify", (customer) => { try { // Code a query to retrieve the selected customer // and store the Customer object in the class variable. selectedCustomer = customer; this.DisplayCustomer(); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }); Messenger.Default.Register <Customer>(this, "modData", (customer) => { SelectedCustomer.Name = customer.Name; SelectedCustomer.Address = customer.Address; SelectedCustomer.City = customer.City; SelectedCustomer.State = customer.State; SelectedCustomer.ZipCode = customer.ZipCode; }); Messenger.Default.Register <Customer>(this, "clear", (customer) => { this.ClearControls(); }); Messenger.Default.Register <Customer>(this, "reload", (customer) => { this.GetCustomer(customer.CustomerID); }); /// <summary> /// Get the customer using the customer ID. /// </summary> GetCustomerCommand = new RelayCommand(() => { if (Validator.IsPresent(CustomerIDBox) && Validator.IsInt32(CustomerIDBox)) { int customerID = Convert.ToInt32(CustomerIDBox); this.GetCustomer(customerID); } }); /// <summary> /// Open the add customer view. /// </summary> AddCustomerCommand = new RelayCommand(() => { AddView addView = new AddView(); addView.Show(); ButtonIsEnabled = true; }); /// <summary> /// Open the modify customer view. /// </summary> ModifyCustomerCommand = new RelayCommand(() => { ModifyView modView = new ModifyView(); Messenger.Default.Send(SelectedCustomer, "mod"); modView.Show(); }); /// <summary> /// Delete a customer from the database. /// </summary> DeleteCustomerCommand = new RelayCommand(() => { try { // Mark the row for deletion. // Update the database. MMABooksEntity.mmaBooks.Customers.Remove(selectedCustomer); MMABooksEntity.mmaBooks.SaveChanges(); Messenger.Default.Send(new NotificationMessage("Customer Removed!")); CustomerIDBox = ""; this.ClearControls(); } // Add concurrency error handling. // Place the catch block before the one for a generic exception. catch (DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); if (MMABooksEntity.mmaBooks.Entry(selectedCustomer).State == EntityState.Detached) { MessageBox.Show("Another user has deleted " + "that customer.", "Concurrency Error"); CustomerIDBox = ""; this.ClearControls(); } else { MessageBox.Show("Another user has updated " + "that customer.", "Concurrency Error"); DisplayCustomer(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } ButtonIsEnabled = false; }); /// <summary> /// Close the current window. /// </summary> CloseWindowCommand = new RelayCommand <MainWindow>((window) => { if (window != null) { window.Close(); } }); }