///User selects a table to view ///Validate that the user is permitted to READ tables ///If permitted display the table private void d_listView_tableList_SelectionChanged(object sender, SelectionChangedEventArgs e) { //Get table name string tableName = this.d_listView_tableList.SelectedValue.ToString(); //Format the action the user is trying to perform CS505Project1.Domains.TableAction tableAction = new Domains.TableAction(); tableAction.user_name = _currentUser; tableAction.table_name = tableName; tableAction.operation = Domains.Operation_Type.SELECT; //Attempt to display the table try { dbServices.CanPerformTableAction(tableAction); } catch (Exception ex) { //User was NOT permitted (or was forbidden) to view that table! //Display to the user: MessageBox.Show(ex.Message.ToString()); return; } //Show table this.TableDisplayer_Grid.Visibility = System.Windows.Visibility.Visible; this.d_grid_records.Visibility = System.Windows.Visibility.Visible; //Hide Table chooser this.d_grid_tables.Visibility = System.Windows.Visibility.Hidden; //Todo: Populate Table Displayer with table data this.d_listView_recordList.ItemsSource = dbServices.GetTable(tableName); }
private void d_newrecord_button_submit_Click(object sender, RoutedEventArgs e) { //TRY TO INSERT NEW RECORD //Create TableAction object CS505Project1.Domains.TableAction tableAction = new Domains.TableAction(); tableAction.user_name = _currentUser; tableAction.table_name = this.d_listView_tableList.SelectedValue.ToString().Trim(); tableAction.operation = Domains.Operation_Type.INSERT; //Send tableAction to find out if this action conflicts try { dbServices.CanPerformTableAction(tableAction); } catch (Exception ex) { //Not allowed to perform this action! MessageBox.Show(ex.Message.ToString()); return; } try { string value1 = this.d_newrecord_textbox1.Text; string value2 = this.d_newrecord_textbox2.Text; string value3 = this.d_newrecord_textbox3.Text; dbServices.PerformGenericInsert(tableAction.table_name, value1, value2, value3); } catch (Exception ex) { //Error occured on insert MessageBox.Show(ex.Message.ToString()); return; } }