Exemple #1
0
        private void btnRemoveInventory_Click(object sender, EventArgs e)
        {
            if (txtBarcode.Text.Trim() != "")
            {
                string   OrigQtValue = txtTotalQty.Text;
                frmInput input       = new frmInput();
                input.Title         = "Remove Inventory";
                input.Caption       = "Quantity";
                input.IsNumericOnly = true;

                if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    clsProductItem fi = clsProductItem.SearchProduct(txtBarcode.Text);

                    if (Convert.ToDouble(input.Value) <= 0)
                    {
                        MessageBox.Show("Quantity must be more than 0", "Remove Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    if (fi != null && fi.StocksRemainingQty - Convert.ToDouble(input.Value) >= 0)
                    {
                        frmInput inputReason = new frmInput();
                        inputReason.Title   = "Remove Inventory";
                        inputReason.Caption = "Reason for Removing";
                        inputReason.Value   = "Transfer Inventory";
                        if (inputReason.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            if (input.Value.Trim() == "")
                            {
                                MessageBox.Show("Must enter reason for removal of inventory", "Remove Items", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            clsInventory itemIventory = new clsInventory();
                            itemIventory.BarCode    = txtBarcode.Text;
                            itemIventory.Capital    = Convert.ToDouble(txtCapital.Text);
                            itemIventory.Quantity   = -(Convert.ToDouble(input.Value));
                            itemIventory.Remarks    = inputReason.Value;
                            itemIventory.ExpiryDate = dtInventory.Value;
                            itemIventory.DateAdded  = dtInventory.Value;
                            itemIventory.Save();

                            fi.TotalInventoryQty = clsInventory.GetTotalInventoryQty(fi.BarCode);
                            fi.Save();
                            UpdateList(txtSearchString.Text);
                            UpdateItemDisplay(fi.BarCode);
                        }
                    }
                    else if (fi == null)
                    {
                        MessageBox.Show(string.Format("Product not found"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("Removing quantity greater than available quantity not allowed"), "Remove Inventory", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Exemple #2
0
        private void btnAddInventory_Click(object sender, EventArgs e)
        {
            if (txtBarcode.Text.Trim() != "")
            {
                try
                {
                    string         barcode = txtBarcode.Text.Trim();
                    clsProductItem prod    = clsProductItem.SearchProduct(barcode);
                    if (prod == null)
                    {
                        MessageBox.Show("Save the item first.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    frmAddInventory addinventory = new frmAddInventory();
                    addinventory.Quantity = 0;
                    addinventory.Capital  = prod.Capital;
                    addinventory.Retail   = prod.Amount;
                    if (addinventory.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (addinventory.Capital <= 0 || addinventory.Quantity <= 0 || addinventory.Retail <= 0)
                        {
                            MessageBox.Show("Capital/Quantity/Retail must be greater than 0", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        clsInventory itemIventory = new clsInventory();
                        itemIventory.BarCode    = barcode;
                        itemIventory.Capital    = addinventory.Capital;
                        itemIventory.Quantity   = addinventory.Quantity;
                        itemIventory.ExpiryDate = dtInventory.Value;
                        itemIventory.DateAdded  = dtInventory.Value;
                        itemIventory.Save();

                        prod.Capital           = addinventory.Capital;
                        prod.TotalInventoryQty = clsInventory.GetTotalInventoryQty(prod.BarCode);
                        prod.Amount            = addinventory.Retail;
                        prod.Save();

                        //SelectItemFromGrid(itemIventory.BarCode);
                        UpdateItemDisplay(barcode);
                        UpdateList(txtSearchString.Text);
                        //SaveProductItem(); // Update Quantity after saving inventory
                    }
                }
                catch
                {
                }
            }
        }
Exemple #3
0
        private void CalibrateProductItems()
        {
            Dictionary <string, clsPurchasedItem> lstReceipt = new Dictionary <string, clsPurchasedItem>();
            dbConnect             connect     = new dbConnect();
            List <clsProductItem> lstProducts = new List <clsProductItem>();

            dgvPurchase.Rows.Clear();
            lstProducts     = connect.SearchProductItems("");
            m_ListProdItems = new List <clsProductItem>();
            foreach (clsProductItem fi in lstProducts)
            {
                bool   saveitem     = false;
                double totInventory = clsInventory.GetTotalInventoryQty(fi.BarCode);
                if (fi.TotalInventoryQty != totInventory)
                {
                    fi.TotalInventoryQty = totInventory;
                    saveitem             = true;
                }
                double qtySold = clsPurchasedItem.GetTotalQtySold(fi.BarCode);
                if (fi.QtySold != qtySold)
                {
                    fi.QtySold = qtySold;
                    saveitem   = true;
                }
                if (fi.StocksRemainingQty < 0 && Properties.Settings.Default.AddInvCalibrate)
                {
                    clsInventory itemIventory = new clsInventory();
                    itemIventory.BarCode  = fi.BarCode;
                    itemIventory.Capital  = fi.Capital;
                    itemIventory.Quantity = Math.Abs(fi.StocksRemainingQty);
                    //itemIventory.Remarks = "Calibrate Inventory";
                    itemIventory.Remarks = string.Format("(Calibrate){0}: TotInv={1} + {2}", m_username, fi.StocksRemainingQty, itemIventory.Quantity);

                    itemIventory.Save();
                    fi.TotalInventoryQty += itemIventory.Quantity;
                    saveitem              = true;
                }
                if (saveitem)
                {
                    fi.Save();
                }
                AddItemToGrid(fi);
                m_ListProdItems.Add(fi);
            }
            connect.Close();
        }
Exemple #4
0
        private void btnAddInventory_Click(object sender, EventArgs e)
        {
            frmInput input = new frmInput();

            input.withDecimal   = true;
            input.IsNumericOnly = false;
            input.Value         = "";
            input.Caption       = "Enter Supplier/Reference Num";

            if (input.ShowDialog() == System.Windows.Forms.DialogResult.Cancel || input.Value == "")
            {
                return;
            }
            foreach (KeyValuePair <string, clsPurchasedItem> items in m_receipt.PurchasedItems)
            {
                clsPurchasedItem prod         = items.Value;
                clsInventory     itemIventory = new clsInventory();
                itemIventory.BarCode   = prod.BarCode;
                itemIventory.Capital   = prod.Capital;
                itemIventory.Quantity  = prod.Qty;
                itemIventory.Remarks   = input.Value;
                itemIventory.DateAdded = dtInventory.Value;
                itemIventory.Save();

                clsProductItem item = clsProductItem.SearchProduct(prod.BarCode);
                if (item != null)
                {
                    item.Capital            = prod.Capital;
                    item.TotalInventoryQty += prod.Qty;
                    item.Amount             = prod.Amount;
                    item.Save();
                }
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
        }