Exemple #1
0
        private void LoadItems()
        {
            DataSet ds = new DataSet();
            cInventory inv = new cInventory();

            ds = inv.InventoryGet();

            ds.Tables[0].DefaultView.Sort = "Name asc";

            cmbItems.DataSource = ds.Tables[0].DefaultView;
            cmbItems.ValueMember = "MealID";
            cmbItems.DisplayMember = "Name";

            //cmbItems.Sorted = true;
            cmbItems.SelectedIndex = -1;
        }
Exemple #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (cmbItems.SelectedIndex < 0)
            {
                MessageBox.Show("Please select an item");
                return;
            }
            cInventory inv = new cInventory(0, Convert.ToUInt32(cmbItems.SelectedValue),  Convert.ToUInt32(numQty.Value), dtpDtAdd.Value.ToString(), loggedUser.UserID);

            if (inv.checkInventory())
            {
                DialogResult dialogResult = MessageBox.Show("This this item was already added today. Continue with update?", "Add", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {

                    // preventing adding twice to the same item because
                    //MessageBox.Show("Item not added");
                    //return;
                }
                else
                {
                    MessageBox.Show("Item not added");
                    return;
                }
            }

            if (inv.saveRecord())
            {
                MessageBox.Show("Added");
            }
            else
            {
                MessageBox.Show("Sorry could not be added");
                return;
            }
        }
Exemple #3
0
        private void LoadItems()
        {
            DataSet ds = new DataSet();
            cInventory inv = new cInventory();

            //ds = inv.InventoryGet();

            //cmbItems.DataSource = ds.Tables[0];
            //cmbItems.ValueMember = "MealID";
            //cmbItems.DisplayMember = "Name";

            //cmbItems.SelectedIndex = -1;

            try
            {
                ds = inv.InventoryMealsGet();

                dgvInv.DataSource = ds.Tables[0];

                dgvInv.Columns[0].HeaderText = "Meal ID";
                dgvInv.Columns[1].HeaderText = "Meal ID";
                dgvInv.Columns[2].HeaderText = "Name";
                dgvInv.Columns[3].HeaderText = "Credit";
                dgvInv.Columns[4].HeaderText = "Debit";
                dgvInv.Columns[5].HeaderText = "Stock Left";
                dgvInv.Columns[6].HeaderText = "Last Deduction";
                dgvInv.Columns[7].HeaderText = "Last Credit";
                //dgvInv.Columns[8].HeaderText = "MealID";
                //dgvInv.Columns[9].HeaderText = "Stock Left";
                //dgvInv.Columns[10].HeaderText = "Last Modified";

                dgvInv.Columns[0].Visible = false;
                dgvInv.Columns[1].Width = 50;
                dgvInv.Columns[1].Visible = false;
                dgvInv.Columns[2].Width = 200;
                //dgvInv.Columns[2].Visible = false;
                dgvInv.Columns[3].Width = 100;
                //dgvInv.Columns[3].Visible = false;
                dgvInv.Columns[4].Width = 100;
                //dgvInv.Columns[4].Visible = false;
                dgvInv.Columns[5].Width = 100;
                //dgvInv.Columns[].Visible = false;
                dgvInv.Columns[6].Width = 150;
                dgvInv.Columns[7].Width = 100;
                //dgvInv.Columns[7].Visible = false;
                //dgvInv.Columns[8].Width = 80;
                //dgvInv.Columns[9].Width = 120;
                dgvInv.Columns[8].Visible = false;
                dgvInv.Columns[9].Visible = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ds.Dispose();
            }

            //pEdt.Enabled = false;
            //dgvInv.Sort(dgvInv.Columns["Name"], ListSortDirection.Ascending);
        }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!loggedUser.access(Convert.ToInt16(btnSave.Tag)))
            {
                return;
            }

            cInventory inv = new cInventory(0, Convert.ToUInt32(cmbItems.SelectedValue), Convert.ToUInt32(numQty.Value), dtpDtAdd.Value.ToString(), loggedUser.UserID);

            if (inv.checkInventory())
            {
                DialogResult dialogResult = MessageBox.Show("This item was already added to or deducted from today. Continue with update?", "Add", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {

                    // preventing adding twice to the same item because
                    //MessageBox.Show("Item not added");
                    //return;
                }
                else
                {
                    MessageBox.Show("Item not added");
                    return;
                }
            }

            if (rdbAddition.Checked)
            {

                if (inv.saveRecord())
                {
                    MessageBox.Show("Added");
                }
                else
                {
                    MessageBox.Show("Sorry could not be added");
                    return;
                }
            }
            else if (rdbDeduct.Checked)
            {
                if (!(Convert.ToInt32(dgvInv["SLeft", dgvInv.CurrentCell.RowIndex].Value) - Convert.ToUInt32(numQty.Value) >= 0))
                {
                    MessageBox.Show("Not enough stock on this item");
                    return;
                }

                cInventoryDebit invD = new cInventoryDebit(0, Convert.ToUInt32(cmbItems.SelectedValue), Convert.ToUInt32(numQty.Value), dtpDtAdd.Value.ToString(), loggedUser.UserID);

                try
                {
                    if (!invD.saveRecord())
                    {
                        MessageBox.Show("Could not save to inventory\n");
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    throw ex;
                }

                MessageBox.Show("Deducted");
            }
            else
            {
                MessageBox.Show("Please select addition or deduction option");
                return;
            }
            LoadItems();
            pEdt.Enabled = false;
        }
Exemple #5
0
        // selected listview stockcheck
        private bool stockCheck(ListView.SelectedListViewItemCollection selectedItems, ListView lst, int qtyToBuy, bool selectedListView)
        {
            bool status = true;
            ///////////////////////////////////
            /////inventory////stock////////////

            int mealID = Convert.ToInt32(selectedItems[0].Name);

            bool hasStock = Convert.ToBoolean(selectedItems[0].SubItems[6].Text);

            int qtyLeft = 0;

            DataSet ds = new DataSet();
            cInventory inv = new cInventory();

            inv.MealID = Convert.ToUInt32(mealID);

            ///////////////////////////////// find item in listview and get amount//////////////////////////////////////////////////////
            //int qtyInSelectedList = 0;
            //// Acquire SelectedItems
            ////var sel = selectedItems.
            //var selectedItem = lst.SelectedItems;
            //if (selectedItem.Count > 0 && (lstVwItms.Items.ContainsKey(selectedItem[0].Name)))
            //{
            //    int selectedIntoListViewIndex = lstVwItms.Items.IndexOfKey(selectedItem[0].Name);

            //    //int a = Convert.ToInt16(lst.Items[selectedIntoListViewIndex].SubItems[0].Text.Trim());

            //    qtyInSelectedList = (Convert.ToInt16(lstVwItms.Items[selectedIntoListViewIndex].SubItems[2].Text));
            //    //// multiplier
            //    //if (multiplier.Contains("x") && Convert.ToInt16(multiplier.Substring(0, multiplier.IndexOf("x"))) > 0)
            //    //{
            //    //    qty = Convert.ToInt16(multiplier.Substring(0, multiplier.IndexOf("x")));
            //    //}

            //    //lstVwItms.Items[selectedIntoListViewIndex].SubItems[2].Text = qty.ToString();

            //    //lstVwItms.HideSelection = false;
            //    lstVwItms.Select();
            //    lstVwItms.Items[selectedIntoListViewIndex].Selected = true;

            //}

            //lstVwItms.

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            // if it's part of the inverntory table
            if (hasStock)
            {

                //try
                //{
                ds = inv.InventoryMealsGet();
                qtyLeft = Convert.ToInt32(ds.Tables[0].Rows[0]["SLeft"].ToString());
                //}
                //catch (Exception ex)
                //{

                //}

                if (!(qtyLeft > 0))
                {
                    MessageBox.Show("This item has no stock in the inventory. Pelase top up");
                    status = false;
                }
                //else if (qtyLeft == 2)
                //{
                //    MessageBox.Show("You have two more of this item left");
                //    status = true;
                //}
                //else if (qtyLeft == 1)
                //{
                //    MessageBox.Show("You have one more of this item left. Top up soon");
                //    //don't allow more
                //    status = true;
                //}
                else
                {
                    status = true;
                }
                if (qtyLeft - qtyToBuy < 0)
                {
                    MessageBox.Show("You can not purchase more of this product.\nTop up inventory\n" + qtyLeft + " left.");
                    status = false;
                }
            }
            return status;
        }