/// <summary> /// Runs the code to view the basic information of all wares. /// </summary> private void WareViewBasicMenu() { if (!SQLCode.SQLControl.DatabaseInUse) { VisualCalculator.WareDisplay(WareInformation.GetWareInformation()); } else { try { List <string[]> informationReady = SQLDataCollection(); VisualCalculator.WareDisplay(informationReady); } catch (Exception e) { Support.ErrorHandling(e, $"Could not collect data: {e.Message}"); } } Support.WaitOnKeyInput(); List <string[]> SQLDataCollection() { List <List <string> > information = SQLCode.SQLControl.GetValuesAllWare(new string[] { "name", "id", "amount", "type" }); List <string[]> informationReady = new List <string[]>(); foreach (List <string> arrayData in information) { informationReady.Add(arrayData.ToArray()); } return(informationReady); } }
/// <summary> /// Runs the code that allows the user to view specific information of all wares. /// </summary> private void WareViewMenu() { Console.Clear(); List <string> searchAttributes = WareInformation.FindAllSearchableAttributesNames(SQLCode.SQLControl.DatabaseInUse); if (!SQLCode.SQLControl.DatabaseInUse) //get attributes { searchAttributes.Add("Type"); } else { searchAttributes.Add("type"); } searchAttributes.Add("Done"); List <string> selectedAttributes = new List <string>(); byte selected; do //select attributes to view { selected = VisualCalculator.MenuRun(searchAttributes.ToArray(), "Select Information To Find"); if (selected != searchAttributes.Count - 1 && !selectedAttributes.Contains(searchAttributes[selected])) { selectedAttributes.Add(searchAttributes[selected]); } } while (selected != searchAttributes.Count - 1); List <Dictionary <string, object> > attributesAndValues; if (selectedAttributes.Count != 0) { //get the data and display it if (!SQLCode.SQLControl.DatabaseInUse) { try { attributesAndValues = WareInformation.GetWareInformation(selectedAttributes); VisualCalculator.WareDisplay(selectedAttributes, attributesAndValues); } catch (NullReferenceException e) { Support.ErrorHandling(e, $"No attibutes were selected. {e.Message}"); } } else { try { List <List <string> > wareValues = SQLCode.SQLControl.GetValuesAllWare(selectedAttributes.ToArray()); VisualCalculator.WareDisplay(selectedAttributes.ToArray(), wareValues); } catch (Exception e) { Support.ErrorHandling(e, $"Encountered an error: {e.Message}"); } } } }