Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Producty_type pt = new Producty_type();
            Product p = new Product();
            ViewItems vi = new ViewItems();
            pt.loadProductType(cboType.Text);
            int temp = pt.getIdproductType();

            vi.loadViewItems(txtProduct.Text);
            double temp2 = vi.ItemId;

            p.setProductType(temp);
            p.setDescription(txtDescription.Text);
            p.setQty(Convert.ToDouble(txtQuantity.Text));
            p.setAmount(Convert.ToDouble(txtAmount.Text));
            p.setItemId(temp2);
            p.setOutBy(GLOBAL_VARS.ActiveUser.Username);

            if (this.active_product_id != 0)
            {
                p.setIdproducts(active_product_id);
                p.edit();
            }
            else {
                p.Save();
            }

             //DB2 Transaction goes here...
            if (cboType.Text == "Egg") {
                TransactionForDB2 tdb2 = new TransactionForDB2();
                //for StockInTransaction Class
                tdb2.St.FromSupplier = 6;
                tdb2.St.Remarks = "Stockin from Poultry";
                tdb2.St.TotalNoOfItems = 1;
                tdb2.St.TotalQty = Convert.ToDouble(txtQuantity.Text);
                tdb2.St.PreparedBy = GLOBAL_VARS.ActiveUser.Username;
                tdb2.St.ApprovedBy = GLOBAL_VARS.ActiveUser.Username;
                tdb2.St.ReceivedBy = GLOBAL_VARS.ActiveUser.Username;
                //for StockIn Class
                tdb2.S.ItemId = IdOfSelectedItem;
                tdb2.S.QtyIn = Convert.ToDouble(txtQuantity.Text);
                tdb2.addToCollectionOfS(tdb2.S);
                //for Quick report
                tdb2.Q.ItemCode = txtProduct.Text;
                tdb2.Q.ItemQty = Convert.ToDouble(txtQuantity.Text);
                tdb2.Q.ItemQtyStanding = ((Convert.ToDouble(f.getAttribute("db2", "items", "item_qty", "item_code", txtProduct.Text))) + tdb2.Q.ItemQty);
                tdb2.Q.TransactionType = "stock_in";

                tdb2.ExecuteDB2Transaction();
            }
             //end of DB2 Transaction

            vp.loadListviewItem();
        }
Example #2
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 #3
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 #4
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Selected record will be deleted", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
     {
         Product delProd = new Product();
         delProd.loadProducts(Convert.ToDouble(lsvView.SelectedItems[0].Text));
         delProd.delete();
         this.loadListviewItem();
     }
 }
Example #5
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 #6
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";

            }
        }