/// <summary> /// returns a string list of the distinct charges in the database /// </summary> /// <returns></returns> public List <string> GetListCharges() { List <string> listCharges = new List <string>(); try { clsSQL sql = new clsSQL(); DataSet ds; int iRet = 0; ds = sql.ExecuteSQLStatement("SELECT DISTINCT TotalCost FROM Invoices", ref iRet); listCharges.Add(""); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string invoiceNum = ds.Tables[0].Rows[i][0].ToString(); listCharges.Add(invoiceNum); } } catch (Exception ex) { MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } return(listCharges); }
/// <summary> /// returns an invoice list that matches the parameters supplied to it /// </summary> /// <param name="invoiceNum"></param> /// <param name="date"></param> /// <param name="total"></param> /// <returns></returns> public List <clsInvoice> GetInvoices(string invoiceNum, string date, string total) { List <clsInvoice> invoices = new List <clsInvoice>(); try { clsSQL sql = new clsSQL(); DataSet ds; int iRet = 0; ds = sql.ExecuteSQLStatement(clsSearchSQL.GetInvoices(invoiceNum, date, total), ref iRet); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { invoices.Add(new clsInvoice() { InvoiceNum = Convert.ToInt32(ds.Tables[0].Rows[i][0].ToString()), InvoiceDate = ds.Tables[0].Rows[i][1].ToString(), InvoiceTotal = Convert.ToInt32(ds.Tables[0].Rows[i][2]) }); } } catch (Exception ex) { MessageBox.Show(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } return(invoices); }
/// <summary> /// Retrieve item list for combo box dropdown /// </summary> /// <param name="wndMain"></param> /// <returns></returns> public static BindingList <clsItem> GetItemsList(wndMain wndMain) { try { BindingList <clsItem> ItemList = new BindingList <clsItem>(); //Make Connection clsSQL dataAccess = new clsSQL(); DataSet ds = new DataSet(); int iRet = 0; //store query result in data set ds = dataAccess.ExecuteSQLStatement(clsMainSQL.queryItems(), ref iRet); //Loop through items creating item object and add to a bound list for (int i = 0; i < iRet; i++) { clsItem item = new clsItem(); item.ItemCode = ds.Tables[0].Rows[i][0].ToString(); item.ItemDescription = ds.Tables[0].Rows[i][1].ToString(); item.ItemCost = Convert.ToDecimal(ds.Tables[0].Rows[i][2].ToString()); ItemList.Add(item); } return(ItemList); } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + "->" + ex.Message); } }
/// <summary> /// PopulateDataGrid: Populates DataGrid /// Date Version Name Comments /// 12/03/19 1.0 Dylan Created Method /// </summary> private void PopulateDataGrid() { try { ds = db.ExecuteSQLStatement(clsItemsSQL.GetItemList(), ref iRet); ItemDataGrid.ItemsSource = ds.Tables[0].AsDataView(); } catch (Exception ex) { ClsHandleError.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }
/// <summary> /// Handles when the user clicks the Search Invoice menu item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menuSearchInvoice_Click(object sender, RoutedEventArgs e) { try { wndSearch searchWindow = new wndSearch(); this.Hide(); searchWindow.ShowDialog(); int iRet = 0; DataSet ds; // store data in dateset invoiceNumber = clsSearchLogic.strSelectedInvoice; if (invoiceNumber != "") { ds = db.ExecuteSQLStatement(clsMainSQL.queryInvoice(Convert.ToInt32(invoiceNumber)), ref iRet); string InvoiceDatePull = db.ExecuteScalarSQL(clsMainSQL.queryDate(Convert.ToInt32(invoiceNumber))); //update labels invoiceLbl.Content = "Invoice Number: " + invoiceNumber; invoiceDateLbl.Content = InvoiceDatePull; // extract dataset items into observable list currentInvoiceItems = clsMainLogic.ConvertDataSetToList(ds); // bind observable list to the data source invoiceItemDataGrid.ItemsSource = currentInvoiceItems; // set edit invoice to true editInvoiceMode = true; EditMode(editInvoiceMode); } this.Show(); } catch (Exception ex) { ClsHandleError.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex.Message); } }