public bool insertProductInvoice(Invoice transaction, Product product, int quantity)
 {
     Decimal grpPrice = product.UnitPrice * quantity;
     return create(
         insertValues(transaction.InvoiceId, product.Barcode, quantity, grpPrice)
         );
 }
 void mapProductToTextfields(Product product)
 {
     txtBarcode.Text = product.Barcode;
     txtDescription.Text = product.Description;
     txtPrice.Text = product.UnitPrice.ToString();
     //cmbCategory.Text = product.Category;
 }
        public void insertProduct()
        {
            if(MyExtension.Validation.isFilled(contentPanel)){
                inventory = new Inventory()
            {
                Barcode = txtBarcode.Text,
                StockinDateTime = DateTime.Now,
                QtyReceived = Convert.ToInt32(txtQuantity.Text),
                QtyOnHand = Convert.ToInt32(txtQuantity.Text),
                Supplier = txtSupplier.Text,
            };

            if (checkIfProductAlreadyExists(txtBarcode.Text))
            {
                dbController.insertInventory(inventory);
            }
            else
            {
                product = new Product()
                {
                    Barcode = txtBarcode.Text,
                    Description = txtName.Text,
                    UnitPrice = Convert.ToDecimal(txtPrice.Text),
                    Category = txtCategory.Text,
                };
                dbController.insertProductInsideInventory(inventory, product);
            }

            toggle();

            }
        }
        public bool updateProduct(Product origProduct, Product updatedProduct)
        {
            if (origProduct.Barcode != updatedProduct.Barcode || origProduct.Equals(updatedProduct))
                return false;

            string desc = string.Empty, unitPrice = string.Empty, category = string.Empty, manufacturer = string.Empty, specs = string.Empty,
                warranty = string.Empty, replacement = string.Empty;

            if (origProduct.Description != updatedProduct.Description)
                desc = string.Format("name = '{0}'", updatedProduct.Description);
            if (origProduct.UnitPrice != updatedProduct.UnitPrice)
                unitPrice = string.Format("unit_price = {0}", updatedProduct.UnitPrice);
            if (origProduct.Company != updatedProduct.Company)
                manufacturer = string.Format("source_company_name = '{0}'", updatedProduct.Company);
            if (origProduct.Category_id != updatedProduct.Category_id)
                category = string.Format("category_id = {0}", updatedProduct.Category_id);
            if (origProduct.Specification != updatedProduct.Specification)
                specs = string.Format("specification = '{0}'", updatedProduct.Specification);
            if (origProduct.Warranty != updatedProduct.Warranty)
                warranty = string.Format("warranty = '{0}'", updatedProduct.Warranty);
            if (origProduct.Replacement != updatedProduct.Replacement)
                replacement = string.Format("replacement = '{0}'", updatedProduct.Replacement);

            string condition = string.Format("id = '{0}'", origProduct.Barcode);

            return update(
                updateSet(condition, desc, unitPrice, category, manufacturer, specs, warranty, replacement)
                );
        }
        //public ProductInventoryDomain getProductInventoryThroughBarcode(string barcode)
        //{
        //    Product product = new Product(getEntityWhere(string.Format("Barcode = '{0}'", barcode)),true);
        //    Inventory inventory = new Inventory(getEntityWhere(string.Format("Barcode = '{0}'", barcode)),true);
        //    return new ProductInventoryDomain(product, inventory);
        //}

        public void checkProductCriticalLevel(Product product, MasterController masterController)
        {
            string condition = string.Format("Name = '{0}'", product.Description);
            decimal qty_received = (decimal)readScalar("Qty_Received", condition);
            decimal qty_onhand = (decimal)readScalar("Qty_On_Hand", condition);

            if (qty_onhand <= (qty_received * .10M))
            {
                masterController.displayCriticalNotif(product, (int)qty_onhand);
            }
        }
 public string createProduct(Product product)
 {
     return insertValues(
         product.Barcode,
         product.Description, 
         product.UnitPrice,
         product.Specification,
         product.Warranty,
         product.Replacement,
         product.Category_id
         );
 }
        public ProductInvoice(Entity entity)
        {
            invoice = new Invoice()
            {
                InvoiceId = (int)entity.getField("invoice_id"),
            };

            product = new Product()
            {
                Barcode = entity.getField("product_id").ToString(),
            };

            QuantitySold = (int)entity.getField("quantity");
            GroupPrice = (Decimal)entity.getField("subtotal");
        }
        public void checkProductCriticalLevel(Product product, MasterController masterController)
        {
            string condition = string.Format("Name = '{0}'", product.Description);
            decimal qty_received = (decimal)readScalar("Qty_Received", condition);
            decimal qty_onhand = (decimal)readScalar("Qty_on_Hand", condition);

            if (qty_onhand <= (qty_received * .10M))
            {
                CriticalNotif notif = new CriticalNotif(product, (int)qty_onhand);
                notif.Location = new Point(masterController.getFrmMain.Height - notif.Height,
                                            masterController.getFrmMain.Width - notif.Width
                                            );
                notif.Show();
            }
        }
 public CriticalNotif(Product product, int qty_left)
 {
     InitializeComponent();
     string message = string.Empty;
     if (qty_left == 0)
     {
         message = string.Format("Product {0} is OUT OF STOCK.", product.Description);
     }
     else
     {
         message = string.Format("Product {0} is already in critical level. {1} left.", product.Description, qty_left);
     }
      
     label1.Text = message;
 }
Exemple #10
0
        public bool updateProduct(Product origProduct, Product updatedProduct)
        {
            if (origProduct.Barcode != updatedProduct.Barcode || origProduct.Equals(updatedProduct))
                return false;

            string desc = string.Empty, unitPrice = string.Empty, category = string.Empty, manufacturer = string.Empty;

            if (origProduct.Description != updatedProduct.Description)
                desc = string.Format("name = '{0}'", updatedProduct.Description);
            if (origProduct.UnitPrice != updatedProduct.UnitPrice)
                unitPrice = string.Format("unit_price = {0}", updatedProduct.UnitPrice);
            if (origProduct.Company != updatedProduct.Company)
                manufacturer = string.Format("source_company_name = '{0}'", updatedProduct.Company);
            if (origProduct.Category != updatedProduct.Category)
                category = string.Format("category_id = '{0}'", updatedProduct.Category);

            string condition = string.Format("id = '{0}'", origProduct.Barcode);

            return update(
                updateSet(condition, desc, unitPrice, category, manufacturer)
                );
        }
        public void insertProduct()
        {
            if (MyExtension.Validation.isFilled(contentPanel))
            {
                inventory = new Inventory()
                {
                    Barcode = txtBarcode.Text,
                    StockinDateTime = DateTime.Now,
                    QtyReceived = Convert.ToInt32(txtQuantity.Text),
                    QtyOnHand = Convert.ToInt32(txtQuantity.Text),
                };

                if (checkIfProductAlreadyExists(txtBarcode.Text))
                {
                    dbController.insertInventory(inventory);
                }
                else
                {
                    int category_id = dbController.categoryMapper.getCategoryIndexFromName(cbCategory.Text);
                    product = new Product()
                    {
                        Barcode = txtBarcode.Text,
                        Description = txtName.Text,
                        UnitPrice = Convert.ToDecimal(txtPrice.Text),
                        Warranty = txtWarranty.Text.ToString(),
                        Replacement = txtReplacement.Text.ToString(),
                        Specification = txtSpecs.Text,
                        Category_id = category_id,
                    };
                    dbController.insertProductInsideInventory(inventory, product);
                }
                toggle();
            }
            else
            {
             //   MessageBox.Show("Missing field required");
            }
        }
Exemple #12
0
        public bool queryProduct()
        {
            bool success = false;
            string barcode = txtEncode.Text;
            int quantity = 1;

            if(string.IsNullOrWhiteSpace(txtQuantity.Text))
                MessageBox.Show("Please enter quantity");
            else
                quantity = int.Parse(txtQuantity.Text);

            currentProduct = dbController.getProductFromBarcode(barcode);

            if (!string.IsNullOrWhiteSpace(currentProduct.Barcode)){
                Decimal totalPrice = currentProduct.UnitPrice * quantity;
                lblPOSmsg.Text = String.Format("{0} x{1} @{2}", currentProduct.Description, quantity, totalPrice);
                success = true;
                addRowInDatagrid(quantity);
            }
            else{
                lblPOSmsg.Text = "Item not found";
            }

            return success;
        }
 public void toggle(Product product)
 {
     toggle();
     onupdateMode = true;
     this.origProduct = product;
 }
        public void mapProductToTextfield(Product product)
        {
            clearTexts();
            txtQuantity.Enabled = false;
            txtQuantity.ForeColor = Color.DimGray;
            txtQuantity.BackColor = Color.White;

            txtBarcode.Text = product.Barcode.ToString();
            txtBarcode.Enabled = false;
            txtBarcode.ForeColor = Color.DimGray;
            txtBarcode.BackColor = Color.White;

            txtName.Text = product.Description.ToString();
            txtPrice.Text = product.UnitPrice.ToString();
               // if (product.Company != null)
              //      txtSupplier.Text = product.Company.ToString();
            oldProduct = product;

            lblQuantity.Visible = false;
            txtQuantity.Visible = false;
        }
 void initUpdate(Product product){
     mapProductToTextfields(product);
     txtQuantity.ReadOnly = true;
     txtBarcode.ReadOnly = true;
     txtDescription.Focus();
 }
        void updateProduct()
        {
            product = new Product()
            {
                Barcode = txtBarcode.Text,
                Description = txtDescription.Text,
                UnitPrice = Convert.ToDecimal(txtPrice.Text),
                //Company = txtCompany.Text
            };

           
            dbController.updateProduct(origProduct, product);
            onupdateMode = false;
            txtQuantity.Enabled = true;
            txtBarcode.Enabled = true;

            toggle();
            clear();
        }
        void insertProduct()
        {
            inventory = new Inventory(){
                Barcode = txtBarcode.Text,
                StockinDateTime = DateTime.Now,
                QtyReceived = Convert.ToInt32(txtQuantity.Text),
                QtyOnHand = Convert.ToInt32(txtQuantity.Text),
            };

            if (checkIfProductAlreadyExists(txtBarcode.Text)){
                dbController.insertInventory(inventory);
            }
            else{
                product = new Product(){
                    Barcode = txtBarcode.Text,
                    Description = txtDescription.Text,
                    UnitPrice = Convert.ToDecimal(txtPrice.Text),
                    //Company = txtCompany.Text
                };
                dbController.insertProductInsideInventory(inventory, product);
            }
            
            toggle();
            clear();
        }
 public bool updateProduct(Product origP, Product newP)
 {
     if (productMapper.updateProduct(origP, newP)){
         OnUpdateEntity(new EntityArgs(newP));
         return true;
     }
     return false;
 }
 public int getCurrentStockCountFromBarCode(Product product)
 {
     int quantity = (int)productInventory.getStockQuantity(product);
     return quantity;
 }
Exemple #20
0
        public bool queryProducts()
        {
            bool success = false;
            int invoice_no = 0;
            int sum_of_qty = 0;
            decimal sum_of_price = 0M;

            if (int.TryParse(txtEncode.Text, out invoice_no))
            {
                Invoice invoice = new Invoice() { InvoiceId = invoice_no };

                ProductInvoice pI = new ProductInvoice() { invoice = invoice };
                if (!dbController.checkIfAlreadyConsumed(pI))
                {
                    lblPOSmsg.Text = "PV-" + invoice.InvoiceId.ToString("00000");
                    carts = dbController.getListOfProductInvoice(invoice);
                    int quantity = carts.Count;
                    dt.Clear();

                    foreach (ProductInvoice productInvoice in carts)
                    {
                        currentProduct = dbController.getProductFromBarcode(productInvoice.product.Barcode);
                        sum_of_qty += productInvoice.QuantitySold;
                        sum_of_price += productInvoice.GroupPrice;
                        addRowInDatagrid(productInvoice);
                    }

                    poSlbl2.Text = sum_of_price.ToString("N");
                    totalAmount = sum_of_price;
                    success = true;
                }
                else
                {
                    MessageBox.Show("Invoice transaction was already used or do not exist.");
                }
            }
            txtEncode.Clear();
            return success;
        }
 public decimal getStockQuantity(Product product)
 {
     string condition = string.Format("Name = '{0}'", product.Description);
     decimal qty_onhand = (decimal)readScalar("Qty_On_Hand", condition);
     return qty_onhand;
 }
        void updateProduct()
        {
            product = new Product()
            {
                Barcode = txtBarcode.Text,
                Description = txtName.Text,
                UnitPrice = Convert.ToDecimal(txtPrice.Text),
            };

            dbController.updateProduct(oldProduct, product);
            txtQuantity.Enabled = true;
            txtBarcode.Enabled = true;

            toggle();
            clearTexts();
        }
Exemple #23
0
 public string createProduct(Product product)
 {
     return insertValues(
         product.Barcode, product.Description, product.UnitPrice /*,
         product.Category*/);
 }
 public bool insertProductInsideInventory(Inventory inventory, Product product){
     string insertInventory = inventoryMapper.createInventory(inventory);
     string insertProduct = productMapper.createProduct(product);
     if(createTransaction(insertProduct, insertInventory)){
         OnInsertEntity(new EntityArgs(inventory));
         OnInsertEntity(new EntityArgs(product));
         return true;
     }
     return false;
 }
        void updateProduct()
        {
            if (MyExtension.Validation.isFilled(contentPanel))
            {
                int category_id = dbController.categoryMapper.getCategoryIndexFromName(cbCategory.Text);

                product = new Product()
                {
                    Barcode = txtBarcode.Text,
                    Description = txtName.Text,
                   
                    Warranty = txtWarranty.Text,
                    Replacement = txtReplacement.Text,
                    Specification = txtSpecs.Text,
                    Category_id = category_id,
                };

                dbController.updateProduct(oldProduct, product);
                txtBarcode.Enabled = true;

                toggle();
                clearTexts();
            }
        }
 public void displayCriticalNotif(Product product, int qty_onhand)
 {
     notif = new CriticalNotif(product, qty_onhand);
     notif.Location = new Point(getFrmMain.Height - notif.Height,
                                 getFrmMain.Width - notif.Width
                                 );
     Form form = Application.OpenForms["CriticalNotif"];
     if (form == null)
         notif.Show();
 }
        void updateProduct()
        {
            if (MyExtension.Validation.isFilled(contentPanel) || string.IsNullOrWhiteSpace(txtQuantity.Text))
            {
                int category_id = dbController.categoryMapper.getCategoryIndexFromName(cbCategory.Text);

                product = new Product()
                {
                    Barcode = txtBarcode.Text,
                    Description = txtName.Text,
                    UnitPrice = Convert.ToDecimal(txtPrice.Text),
                    Warranty = txtWarranty.Text,
                    Replacement = txtReplacement.Text,
                    Specification = txtSpecs.Text,
                    Category_id = category_id,
                };

                dbController.updateProduct(oldProduct, product);
                txtQuantity.Enabled = true;
                txtBarcode.Enabled = true;

                toggle();
                clearTexts();
            }
        }
 public void checkProductCriticalLevel(Product product)
 {
     productInventory.checkProductCriticalLevel(product, masterController);
 }
        public void mapProductToTextfield(Product product)
        {
            clearTexts();
            try
            {
                txtQuantity.Enabled = false;
                txtQuantity.ForeColor = Color.DimGray;
                txtQuantity.BackColor = Color.White;

                txtBarcode.Text = product.Barcode.ToString();
                txtBarcode.Enabled = false;
                txtBarcode.ForeColor = Color.DimGray;
                txtBarcode.BackColor = Color.White;

                txtName.Text = product.Description.ToString();
                txtPrice.Text = product.UnitPrice.ToString();
                txtSpecs.Text = product.Specification.ToString();
                txtReplacement.Text = product.Replacement.ToString();
                txtWarranty.Text = product.Warranty.ToString();

                string category = dbController.categoryMapper.getCategoryNameFromId(product.Category_id);
                cbCategory.Text = category;

                oldProduct = product;

            }catch(Exception){

            }
            
            lblQuantity.Visible = false;
            txtQuantity.Visible = false;
        }
 public ProductInventoryDomain(Product product, Inventory inventory)
 {
     this.product = product;
     this.inventory = inventory;
 }