/// <summary> /// Open Edit Window Logic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Edit_Click(object sender, RoutedEventArgs e) { try { //Reset UI ResetInvoiceData(); grpboxInvoice.IsEnabled = false; btnPanel.IsEnabled = true; //Open Window Hide(); editWindow.ShowDialog(); Show(); //Repopulate Item Combobox cmbBoxItems.ItemsSource = queries.GetItems(); //Update Items on Currently Displayed Invoice if (currentInvoice != null) { currentInvoice.Items = queries.GetInvoiceContents(currentInvoice.InvoiceNumber); } ResetInvoiceData(); } catch (Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Select invoice number /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (cmbInvoiceNums.SelectedValue != null) //prevents crash when changing item source { //Populate Invoice Information box DataSet ds = new DataSet(); query.GetInvoiceByNum(cmbInvoiceNums.SelectedValue.ToString()); ds = query.GetInvoiceInfo(cmbInvoiceNums.SelectedValue.ToString()); lblInvoiceNum.Content = ds.Tables[0].Rows[0]["InvoiceNum"].ToString(); lblInvoiceDate.Content = ds.Tables[0].Rows[0]["InvoiceDate"].ToString(); lblInvoiceCost.Content = $"{ds.Tables[0].Rows[0]["TotalCharge"]:C}"; //Populate data grid displaying invoice contents List <clsItem> items = new List <clsItem>(); items = query.GetInvoiceContents(cmbInvoiceNums.SelectedValue.ToString()); dgInvoiceContents.ItemsSource = items; } } catch (System.Exception ex) { HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }