コード例 #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);
                    }
                }
            }
        }
コード例 #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
                {
                }
            }
        }
コード例 #3
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;
        }
コード例 #4
0
        private void AddProduct(string barcode)
        {
            if (barcode != "")
            {
                clsProductItem   prod      = clsProductItem.SearchProduct(barcode);
                clsPurchasedItem purchased = null;
                if (prod != null)
                {
                    if (m_receipt.PurchasedItems.ContainsKey(prod.BarCode))
                    {
                        m_receipt.PurchasedItems[prod.BarCode].UserID = m_user.UserId;
                        m_receipt.PurchasedItems[prod.BarCode].Qty   += 1;
                        purchased = m_receipt.PurchasedItems[prod.BarCode];
                    }
                    else
                    {
                        purchased        = new clsPurchasedItem(prod);
                        purchased.UserID = m_user.UserId;

                        if (purchased.Description.ToUpper().Contains("NEW ITEM"))
                        {
                            purchased.BarCode = "";
                            clsProductItem item      = new clsProductItem();
                            frmInput       nobarcode = new frmInput();
                            nobarcode.Title         = "No Barcode";
                            nobarcode.Caption       = "Product Description";
                            nobarcode.IsNumericOnly = false;
                            nobarcode.Value         = purchased.Description;
                            if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                if (nobarcode.Value != "")
                                {
                                    item.Description = nobarcode.Value;
                                    if (MessageBox.Show("Item have Barcode?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        nobarcode               = new frmInput();
                                        nobarcode.Title         = "No Barcode";
                                        nobarcode.Caption       = "Scan Barcode";
                                        nobarcode.IsNumericOnly = false;
                                        nobarcode.withDecimal   = false;
                                        nobarcode.Value         = "";
                                        if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                        {
                                            if (nobarcode.Value != "")
                                            {
                                                item.BarCode = nobarcode.Value;
                                                clsProductItem proditem = clsProductItem.SearchProduct(item.BarCode);
                                                if (proditem != null)
                                                {
                                                    MessageBox.Show("Product already exist!", "New Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Dictionary <int, string> lstCategories = dbConnect.GetCategories();
                                        int catId = 1;
                                        foreach (KeyValuePair <int, string> category in lstCategories)
                                        {
                                            if (category.Value == purchased.Category)
                                            {
                                                catId = category.Key;
                                            }
                                        }
                                        item.BarCode = dbConnect.GetNextSKU().ToString(catId.ToString().Trim() + "000000");
                                    }
                                    nobarcode               = new frmInput();
                                    nobarcode.Title         = "No Barcode";
                                    nobarcode.Caption       = "Capital Amount";
                                    nobarcode.IsNumericOnly = true;
                                    nobarcode.withDecimal   = true;
                                    nobarcode.Value         = "0";
                                    if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                    {
                                        if (nobarcode.Value != "")
                                        {
                                            item.Capital            = Convert.ToDouble(nobarcode.Value);
                                            nobarcode               = new frmInput();
                                            nobarcode.Title         = "No Barcode";
                                            nobarcode.Caption       = "Retail Amount";
                                            nobarcode.IsNumericOnly = true;
                                            nobarcode.withDecimal   = true;
                                            nobarcode.Value         = "0";
                                            if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                            {
                                                if (nobarcode.Value != "")
                                                {
                                                    item.Amount = Convert.ToDouble(nobarcode.Value);
                                                    if (MessageBox.Show("Sold in Wholesale?", "New Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                                                    {
                                                        nobarcode               = new frmInput();
                                                        nobarcode.Title         = "WholeSale";
                                                        nobarcode.Caption       = "Quantity per Set(Box/Case/Rim)";
                                                        nobarcode.IsNumericOnly = true;
                                                        nobarcode.withDecimal   = false;
                                                        nobarcode.Value         = "";
                                                        if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                                        {
                                                            if (nobarcode.Value != "")
                                                            {
                                                                item.WSMinimum          = Convert.ToInt32(nobarcode.Value);
                                                                nobarcode               = new frmInput();
                                                                nobarcode.Title         = "WholeSale";
                                                                nobarcode.Caption       = "Amount per Set(Box/Case/Rim)";
                                                                nobarcode.IsNumericOnly = true;
                                                                nobarcode.withDecimal   = true;
                                                                nobarcode.Value         = "";
                                                                if (nobarcode.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                                                {
                                                                    if (nobarcode.Value != "")
                                                                    {
                                                                        item.WSAmount          = Convert.ToDouble(nobarcode.Value) / item.WSMinimum;
                                                                        item.Category          = prod.Category;
                                                                        item.CategoryId        = prod.CategoryId;
                                                                        item.CriticalLevel     = 10;
                                                                        item.Imagepath         = "";
                                                                        item.QtySold           = 0;
                                                                        item.TotalInventoryQty = 0;
                                                                        item.Save();
                                                                        purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode));
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        item.WSAmount          = item.Amount;
                                                        item.Category          = prod.Category;
                                                        item.CategoryId        = prod.CategoryId;
                                                        item.CriticalLevel     = 10;
                                                        item.Imagepath         = "";
                                                        item.QtySold           = 0;
                                                        item.TotalInventoryQty = 0;
                                                        item.WSMinimum         = 1;
                                                        item.Save();
                                                        purchased = new clsPurchasedItem(clsProductItem.SearchProduct(item.BarCode));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        if (purchased.BarCode != "")
                        {
                            m_receipt.PurchasedItems.Add(purchased.BarCode, purchased);
                        }
                        else
                        {
                            return;
                        }
                    }
                    UpdatePurchases();
                    if (purchased != null && purchased.BarCode != "")
                    {
                        UpdateProductDisplay(purchased.BarCode);
                    }
                }
                else
                {
                    //MessageBox.Show("Barcode/Product Code not found", "Add Item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    string result = SearchProduct(barcode);
                    txtBarcode.Text = result;
                    if (result != "")
                    {
                        AddProduct(result);
                    }
                }
            }
            txtBarcode.SelectAll();
        }