private void GuitarTypeSelectionChanged(object sender, SelectionChangedEventArgs e) { try { dataGridInventory.ItemsSource = null; var guitar = (Guitar) cboBoxGuitarTypes.SelectedItem; var guitarType = new Guid(guitar.Id.ToString()); var nhi = new NHibernateInventory(); var guitarTypes = (List<Inventory>) nhi.ExecuteICriteria(guitarType); dataGridInventory.ItemsSource = guitarTypes; if (guitarTypes != null) { dataGridInventory.Columns[0].Visibility = Visibility.Hidden; dataGridInventory.Columns[1].Visibility = Visibility.Hidden; } PopulateComboBox(); } catch (Exception) { throw; } }
private void PopulateGrid() { var nhi = new NHibernateInventory(); var list = (List<Inventory>) nhi.ExecuteICriteriaOrderBy("Builder"); dataGridInventory.ItemsSource = list; if (list != null) { dataGridInventory.Columns[0].Visibility = Visibility.Hidden; dataGridInventory.Columns[1].Visibility = Visibility.Hidden; // dataGridInventory.Columns[8].Visibility = Visibility.Hidden; } }
private void buttonDelete_Click(object sender, RoutedEventArgs e) { var inventoryItem = (Inventory) dataGridInventory.SelectedItem; var item = new Guid(inventoryItem.Id.ToString()); var nhi = new NHibernateInventory(); if (nhi.DeleteInventoryItem(item)) { dataGridInventory.ItemsSource = null; PopulateDataGrid(); labelMessage.Content = "Item deleted."; } else labelMessage.Content = "Item deletion failed."; }
private void comboBoxGuitarTypes_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { dataGridInventory.ItemsSource = null; var guitar = (Guitar) comboBoxGuitarTypes.SelectedItem; var guitarType = new Guid(guitar.Id.ToString()); var nhi = new NHibernateInventory(); var list = (List<Inventory>) nhi.ExecuteICriteria(guitarType); dataGridInventory.ItemsSource = list; if (list != null) HideColumnsWhichContainTechnicalInformation(); } catch (Exception ex) { labelMessage.Content = ex.Message; } }
private void PopulateDataGrid() { var nhi = new NHibernateInventory(); IList<Inventory> list = nhi.ExecuteICriteriaOrderBy("Builder"); dataGridInventory.ItemsSource = list; if (list != null) HideColumnsWhichContainTechnicalInformation(); }
private void averageButton_Click(object sender, RoutedEventArgs e) { var nhi = new NHibernateInventory(); List<string> fields = new List<string> { "Guitar Type","Total Value" }; IList guitarInventory = nhi.ExecuteNamedQuery("GuitarAVGValueByTypeHQL"); inventoryDataGrid.ItemsSource = this.BuildDataTable(fields, guitarInventory).DefaultView; SetDatabaseRoundTripImage(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //test NHibernateInventory nHibernateInventory = new NHibernateInventory(); var resultSet = nHibernateInventory.ExecuteNamedQuery("GuitarValueByTypeHQL"); // populate the combo box with the guitars/inventory type. PopulateComboBox(); // load the Inventory with all guitar types. LoadInventoryGrid(); this.SetDatabaseRoundTripImage(); }
private void LoadInventoryGrid() { NHibernateInventory nHibernateInventory = new NHibernateInventory(); // create a list of fields we want to get. List<string> fields = new List<string> { "Id", "Builder", "Model","Qoh","Cost","Price","Received", "Profit" }; // get the selected guitar type, if one is selected. var typeId = this.GetSelectedGuitarType(); // get the inventory from the DB. var inventoryTuple = nHibernateInventory.GetDynamicInventory(typeId: typeId, maxResult:this.maxResultsPerPage, firstResult:this.firstResultInPage); // get the total inventory count. this.totalInventoryCount = inventoryTuple.Item1; // set the data source to the list of inventory inventoryDataGrid.ItemsSource = BuildDataTable(fields, inventoryTuple.Item2).DefaultView; //var inventoryList = nHibernateInventory.ExecuteICriteriaOrderBy("Builder"); // if we got results back hid the Id column if (inventoryTuple.Item2 != null && inventoryTuple.Item2.Count > 0) { inventoryDataGrid.Columns[0].Visibility = Visibility.Hidden; } gridCountLabel.Content = "Retrieved " + firstResultInPage.ToString() + " to " + (firstResultInPage + inventoryTuple.Item2.Count).ToString() + " of " + totalInventoryCount.ToString(); // figure out which pagination buttons need to be available EnablePaginationButtons(); }
/// <summary> /// Click event for the delete button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void deleteInventoryButton_Click(object sender, RoutedEventArgs e) { Inventory inventoryItem = (Inventory) inventoryDataGrid.SelectedItem; Guid itemId = inventoryItem.Id; NHibernateInventory nhi = new NHibernateInventory(); if (nhi.DeleteInventoryItem(itemId)) { inventoryDataGrid.ItemsSource = null; // now we need to reload the grid. this.LoadInventoryGrid(); messagelabel.Content = "Item deleted."; } else { messagelabel.Content = "Item deletion failed."; } }