Exemplo n.º 1
0
        private void AddItemToGrid(clsPurchasedItem fitem)
        {
            int rowidx = dgv.Rows.Add();

            dgv.Rows[rowidx].Cells[0].Value = fitem.BarCode;
            dgv.Rows[rowidx].Cells[1].Value = fitem.Description;
            dgv.Rows[rowidx].Cells[2].Value = fitem.Amount;
            dgv.Rows[rowidx].Cells[3].Value = fitem.Qty;
            dgv.Rows[rowidx].Cells[4].Value = fitem.Amount * fitem.Qty;
        }
Exemplo n.º 2
0
        private void AddItemToGrid(clsPurchasedItem fitem)
        {
            int rowidx = dgvPurchase.Rows.Add();

            dgvPurchase.Rows[rowidx].Cells[0].Value = fitem.BarCode;
            dgvPurchase.Rows[rowidx].Cells[1].Value = fitem.Description;
            dgvPurchase.Rows[rowidx].Cells[2].Value = fitem.Qty;
            dgvPurchase.Rows[rowidx].Cells[3].Value = fitem.Unit;
            dgvPurchase.Rows[rowidx].Cells[4].Value = fitem.Capital;
            dgvPurchase.Rows[rowidx].Cells[5].Value = fitem.Capital * fitem.Qty;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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();
        }