Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
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;
        }