Exemple #1
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 #2
0
        private void ChangeQuantity()
        {
            if (m_receipt.PurchasedItems.Count == 0)
            {
                return;
            }
            if (txtBarcode.Text.Trim() == "")
            {
                txtBarcode.Text = dgvPurchase.SelectedRows[0].Cells[0].Value.ToString();
            }
            if (txtBarcode.Text != "")
            {
                clsProductItem prod = clsProductItem.SearchProduct(txtBarcode.Text);
                if (prod != null && prod.BarCode != "")
                {
                    if (m_receipt.PurchasedItems.ContainsKey(prod.BarCode))
                    {
                        if (txtBarcode.Text.Trim() != "")
                        {
                            try
                            {
                                string          barcode      = txtBarcode.Text.Trim();
                                frmAddInventory addinventory = new frmAddInventory();
                                addinventory.Quantity = m_receipt.PurchasedItems[barcode].Qty;
                                addinventory.Capital  = m_receipt.PurchasedItems[barcode].Capital;
                                addinventory.Retail   = m_receipt.PurchasedItems[barcode].Amount;


                                if (addinventory.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    if (addinventory.Capital <= 0 || addinventory.Retail <= 0)
                                    {
                                        MessageBox.Show("Capital/Quantity must be greater than 0", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        return;
                                    }
                                    else
                                    {
                                        m_receipt.PurchasedItems[prod.BarCode].Qty     = addinventory.Quantity;
                                        m_receipt.PurchasedItems[prod.BarCode].Capital = addinventory.Capital;
                                        m_receipt.PurchasedItems[prod.BarCode].Amount  = addinventory.Retail;
                                        UpdatePurchases();
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                        //frmInput input = new frmInput();
                        //input.Title = "Quantity";
                        //input.Caption = "Quantity";
                        //input.Value = m_receipt.PurchasedItems[prod.BarCode].Qty.ToString();
                        //input.IsNumericOnly = true;
                        //if (input.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        //{
                        //    double qty = Convert.ToDouble(input.Value);
                        //    if (qty > 0)
                        //    {
                        //        m_receipt.PurchasedItems[prod.BarCode].Qty = Convert.ToDouble(input.Value);
                        //    }
                        //    else
                        //    {
                        //        m_receipt.PurchasedItems.Remove(prod.BarCode);
                        //    }
                        //    UpdatePurchases();
                        //}
                    }
                }
            }
        }