/// <summary> /// First updates the product list from the database to scrape for changes. Then exports to csv. /// </summary> public static void ExportProducts() { ProductList.UpdateProducts(); Dictionary <string, string> productDetails = new Dictionary <string, string>() { { "Name", "" }, { "Category", "" }, { "Cost_Price", "" }, { "Retail_Cost", "" }, { "Current_Stock", "" } }; foreach (Product p in ProductList.products) { if (!productsToCSV.ContainsKey(p.ProductCode)) { string product = p.ProductCode; productsToCSV.Add(p.ProductCode, new Dictionary <string, string>(productDetails)); productsToCSV[product]["Name"] = p.ProductName; productsToCSV[product]["Category"] = p.Cat.ToString(); productsToCSV[product]["Cost_Price"] = p.CostPrice.ToString(); productsToCSV[product]["Retail_Cost"] = p.RetailPrice.ToString(); productsToCSV[product]["Current_Stock"] = p.StockLevel.ToString(); } } string file = "Product_List_as_of_" + DateTime.Today.Date.Year + "-" + DateTime.Today.Date.Month + "-" + DateTime.Today.Date.Day + ".csv"; WriteCSV(file, productsToCSV); }
public frmPointOfSales() { InitializeComponent(); ProductList.UpdateProducts(); AutoCompleteStringCollection productCodes = new AutoCompleteStringCollection(); foreach (Product p in ProductList.products) { productCodes.Add(p.ProductCode); } txtProduct.AutoCompleteCustomSource = productCodes; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DBConnect.Session.Open(); // open the connection with the database // Populate the internal product and companies listings ProductList.UpdateProducts(); CompanyList.UpdateCompanies(); Application.Run(new Form1()); // run the main program form. #region Testing Single Forms //Application.Run(new frmPointOfSales()); // run the main program form. //Application.Run(new SalesForACategory()); #endregion DBConnect.Session.Close(); // safely close the connection to the database. }