Example #1
0
        private void loadIncomes(int mo, int yr)
        {
            this.GrossIncome = 0d;
            string sql = "SELECT idproducts, idproduct_type, description, qty, amount, DATE_FORMAT(date_added,'%m-%d-%Y'), item_id, out_by FROM " + GLOBAL_VARS.tb.PRODUCTS + " WHERE MONTH(date_added)=" + mo + " AND YEAR(date_added)=" + yr;
            GLOBAL_VARS.db.execute(sql);
            try
            {
                List<int> productId = new List<int>();
                this.lsvIncome.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.lsvIncome.Items.Add(p.getIdProducts().ToString());
                        Producty_type pt = new Producty_type();
                        pt.loadProductType(Convert.ToInt32(p.getIdProductType()));
                        this.lsvIncome.Items[i].SubItems.Add(p.getDateAdded());
                        this.lsvIncome.Items[i].SubItems.Add(pt.getDescription());
                        this.lsvIncome.Items[i].SubItems.Add(p.getDescription());
                        this.lsvIncome.Items[i].SubItems.Add(p.getQty().ToString());
                        this.lsvIncome.Items[i].SubItems.Add(p.getAmount().ToString("N"));
                        this.lsvIncome.Items[i].SubItems.Add(p.getIdProducts().ToString());
                        this.lsvIncome.Items[i].SubItems.Add(p.getOutBy());
                        GrossIncome += p.getAmount();
                        i += 1;
                    }
                }
                //load in listview

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            GLOBAL_VARS.db.reader.Close();
            lblTotalIncome.Text=this.GrossIncome.ToString("N");
            ////idexpenses, description, amount, quantity, date_created, remarks, expenses_type
            //string sql = "SELECT * FROM " + GLOBAL_VARS.tb.PRODUCTS + " WHERE MONTH(date_added)=" + mo + " AND YEAR(date_added)=" + yr;
            //this.loadItemToListview(lsvIncome, GLOBAL_VARS.db.execute(sql));
            //lblTotalIncome.Text = this.calculateTotal(4, lsvIncome).ToString("N");
        }
Example #2
0
 //overload method
 public void loadListviewItem(string searchKeyword)
 {
     string sql = "SELECT * FROM " + GLOBAL_VARS.tb.PRODUCTS + " WHERE description like '" + searchKeyword + "%'";
     try
     {
         GLOBAL_VARS.db.execute(sql);
         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();
         }
         //load in listview
         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(pt.getDescription());
             this.lsvView.Items[i].SubItems.Add(p.getDescription());
             this.lsvView.Items[i].SubItems.Add(p.getQty().ToString());
             this.lsvView.Items[i].SubItems.Add(p.getAmount().ToString("N"));
             this.lsvView.Items[i].SubItems.Add(p.getDateAdded());
             this.lsvView.Items[i].SubItems.Add(p.getOutBy());
             i += 1;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     lblTotal.Text = this.calculateTotal().ToString("N");
 }
Example #3
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");
        }
Example #4
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";

            }
        }