Пример #1
0
        //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");
        }
Пример #2
0
        private void frmManageProduct_Load(object sender, EventArgs e)
        {
            //if (this.active_expenses_id != 0)
            //{
            //    Expenses ex = new Expenses();
            //    ex.loadExpenses(this.active_expenses_id);
            //    this.cboType.Text = ex.getExpensesType();
            //    this.txtDescription.Text = ex.getDescription();
            //    this.txtAmount.Text = ex.getAmount().ToString();
            //    this.txtQuantity.Text = ex.getQuantity().ToString();
            //    this.txtRemarks.Text = ex.getRemarks();

            //    this.btnSave.Text = "UPDATE";
            //}
            if(this.active_product_id !=0){
                Product p = new Product();
                ViewItems vi = new ViewItems();
                Producty_type pt = new Producty_type();

                p.loadProducts(this.active_product_id);
                pt.loadProductType(p.getIdProductType());
                vi.loadViewItems(p.getItemId());

                this.cboType.Text = pt.getDescription();
                this.txtProduct.Text = vi.ItemCode;
                this.txtQuantity.Text = p.getQty().ToString();
                this.txtAmount.Text = p.getAmount().ToString();
                this.txtDescription.Text = p.getDescription();
                this.btnSave.Text = "UPDATE";

            }
        }