//private void setHeader() //{ // //set up header title // this.addHeaderTitle("ID"); // this.addHeaderTitle("TYPE"); // this.addHeaderTitle("DESCRIPTION"); // this.addHeaderTitle("QUANTITY"); // this.addHeaderTitle("AMOUNT"); // this.addHeaderTitle("DATE ADDED"); // //set up header title width // this.addHeaderWidth(0); // this.addHeaderWidth(100); // this.addHeaderWidth(250); // this.addHeaderWidth(100); // this.addHeaderWidth(120); // this.addHeaderWidth(180); // //set up header alignment // this.addHeaderAlignment("l"); // this.addHeaderAlignment("l"); // this.addHeaderAlignment("L"); // this.addHeaderAlignment("r"); // this.addHeaderAlignment("r"); // this.addHeaderAlignment("l"); // // // this.setListviewHeader(lsvView); //} public void loadListviewItem() { string sql = "SELECT * FROM " + GLOBAL_VARS.tb.PRODUCTS +" WHERE MONTH(date_added)=" + DateTime.Today.Month + " AND YEAR(date_added)="+DateTime.Today.Year + " ORDER BY date_added DESC"; GLOBAL_VARS.db.execute(sql); try { List<int> productId = new List<int>(); this.lsvView.Items.Clear(); if (GLOBAL_VARS.db.reader.HasRows) { while (GLOBAL_VARS.db.reader.Read()) { productId.Add(Convert.ToInt32(GLOBAL_VARS.db.reader["idproducts"].ToString())); //idproducts, idproduct_type, description, qty, amount, date_added } GLOBAL_VARS.db.reader.Close();//modified close int i = 0; foreach (int prodId in productId) { Product p = new Product(); p.loadProducts(Convert.ToDouble(prodId)); this.lsvView.Items.Add(p.getIdProducts().ToString()); Producty_type pt = new Producty_type(); pt.loadProductType(Convert.ToInt32(p.getIdProductType())); this.lsvView.Items[i].SubItems.Add(p.getDateAdded()); this.lsvView.Items[i].SubItems.Add(p.getDescription()); this.lsvView.Items[i].SubItems.Add(p.getQty().ToString()); this.lsvView.Items[i].SubItems.Add(p.getUOM(p.getItemId())); this.lsvView.Items[i].SubItems.Add(p.getAmount().ToString("N")); this.lsvView.Items[i].SubItems.Add(pt.getDescription()); this.lsvView.Items[i].SubItems.Add(p.getOutBy()); i += 1; } } //load in listview } catch (Exception ex) { MessageBox.Show(ex.ToString()); } GLOBAL_VARS.db.reader.Close(); lblTotal.Text = this.calculateTotal().ToString("N"); }