/// <summary> /// Default constructor for wndMain /// </summary> public wndMain() { try { InitializeComponent(); Logic = new clsMainLogic(); sql = new clsMainSQL(); ItemLogic = new clsItemsLogic(); ds = new DataSet(); SelectedItems = new List <clsItem>(); SearchLogic = new clsSearchLogic(); // Populate cbItemList List <clsItem> item = ItemLogic.Items(); cbItemList.SetBinding(ComboBox.ItemsSourceProperty, new Binding() { Source = item }); cbItemList.DisplayMemberPath = "sItemDesc"; } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + " " + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message); } }
/// <summary> /// checkInvoices checks all invoices to see if the item exists in any of the invoices /// </summary> public bool checkInvoices(Item item, clsItemsLogic itemsLogic) { try { ObservableCollection <clsInvoices> invoicesList = new ObservableCollection <clsInvoices>(); ObservableCollection <clsInvoices> itemsList = new ObservableCollection <clsInvoices>(); clsMainSQL mainSQL = new clsMainSQL(); bool itemExistsInInvoices = false; string sSQL; int iRet = 0; //Number of return values int iRet2 = 0; //Number of return values int result = 0; DataSet ds = new DataSet(); //Holds the return values DataSet ds2 = new DataSet(); //Holds the return values //Create the SQL statement to extract the invoices sSQL = mainSQL.SelectInvoiceNumAndCostOnDate(); // sql statement to get all current invoices //Extract the invoices and put them into the DataSet ds = db.ExecuteSQLStatement(sSQL, ref iRet); //Loop through the data and create an Invoice class for (int i = 0; i < iRet; i++) //for the length of all invoices { sSQL = mainSQL.SelectLineItemsOnInvoiceNum(ds.Tables[0].Rows[i][0] .ToString()); //grab the current invoice and select all the items within the invoice ds2 = db.ExecuteSQLStatement(sSQL, ref iRet2); for (int j = 0; j < iRet2; j++) //for the length of items { if (ds2.Tables[0].Rows[j][0].ToString() == item.itemCode ) //if our item code matches the current item selected, return true { itemsLogic.invoicesWithItemToDelete.Add(ds.Tables[0].Rows[i][0].ToString()); itemExistsInInvoices = true; } } } if (itemExistsInInvoices) { return(true); } else { return(false); } return(false); } catch (Exception ex) { throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + "->" + ex.Message); } }