Esempio n. 1
0
        private void dataGridStock_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridStock.RowCount > 0)
            {
                try
                {
                    //keeps track of what row is selected for editing their record
                    m_SelectedStockId = Convert.ToInt32(dataGridStock.CurrentRow.Cells[0].Value);
                    Raw_Stock selectedStock = Raw_Stock.RetrieveById(m_SelectedStockId);

                    txtUStockName.Text = selectedStock.Name;
                    comboUStockCategory.SelectedItem = selectedStock.Category;
                    numUStockQty.Value     = selectedStock.Quantity;
                    numUReorderLevel.Value = selectedStock.ReorderLevel;
                    txtUPrice.Text         = selectedStock.Price.ToString();

                    for (int i = 0; i < comboUSupplier.Items.Count; i++)
                    {
                        if (((Supplier)comboUSupplier.Items[i]).ID == selectedStock.Supplier.ID)
                        {
                            comboUSupplier.SelectedIndex = i;
                            break;
                        }
                    }
                }
                catch
                {
                    //should never happen
                    Console.WriteLine("ERROR: Cannot convert current row[0] to int32");
                }
            }
        }
Esempio n. 2
0
 private void txtStockSearch_TextChanged(object sender, EventArgs e)
 {
     //retrieve stock based on a SQL search
     //a timer is used here to ensure SQL queries are limited to 1/sec
     if (m_SearchTime % 2 == 0)
     {
         dataGridStock.DataSource = Raw_Stock.Search(txtStockSearch.Text);
     }
 }
Esempio n. 3
0
 public frmAddFoodMenuAttribute(string menu_attribute)
 {
     InitializeComponent();
     this.CenterToScreen();
     searchLimter.Start();
     lblHeader.Text = string.Format("Edit: {0} Option", menu_attribute);
     //load the whole stock table initally
     dataGridStock.DataSource = Raw_Stock.RetrieveAll();
 }
Esempio n. 4
0
        //Add New Menu
        private void pickFoodMenuItem(object sender, EventArgs e)
        {
            try
            {
                TextBox selectedMenuAttribute = sender as TextBox;

                string attributeTag = selectedMenuAttribute.Tag.ToString();

                frmAddFoodMenuAttribute frmSelectMenuAttrib = new frmAddFoodMenuAttribute(attributeTag);

                frmSelectMenuAttrib.ShowDialog();

                //selected item picked in the attribute selector form
                Raw_Stock selectedItem = frmSelectMenuAttrib.CHOOSEN_ITEM;
                if (selectedItem != null)
                {
                    switch (selectedItem.Category)
                    {
                    case "MEAT":
                        Meat = selectedItem;
                        txtNMenuMeat.Text = selectedItem.Name;
                        break;

                    case "VEG":
                        if (Veg1 == null)
                        {
                            Veg1 = selectedItem;
                            txtNMenuVeg1.Text = selectedItem.Name;
                        }
                        else
                        {
                            Veg2 = selectedItem;
                            txtNMenuVeg2.Text = selectedItem.Name;
                        }
                        break;

                    case "DRINK":
                        Drink = selectedItem;
                        txtNMenuDrink.Text = selectedItem.Name;
                        break;

                    default:
                        MessageBox.Show("An unexpected error has occured! Check you picked an item in a suitable category.", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                    //calculate cost price based on current menu items
                    if (Meat != null && Veg1 != null && Veg2 != null && Drink != null)
                    {
                        txtCostPrice.Text = string.Format("{0}", (Meat.Price + Veg1.Price + Veg2.Price + Drink.Price));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: {0}", ex.Message);
            }
        }
Esempio n. 5
0
        private void btnUpdateStock_Click(object sender, EventArgs e)
        {
            if (Raw_Stock.Update(new Raw_Stock(m_SelectedStockId, txtUStockName.Text, comboUStockCategory.Text, (int)numUStockQty.Value,
                                               (int)numUReorderLevel.Value, Convert.ToDecimal(txtUPrice.Text), ((Supplier)comboUSupplier.SelectedItem))))
            {
                MessageBox.Show("Stock Item Updated!", "Success:", MessageBoxButtons.OK);
                LoadStock();
                return;
            }


            MessageBox.Show("Failed to Update Stock, Check your input!", "ERROR:", MessageBoxButtons.OK);
        }
Esempio n. 6
0
        private void btnUpdateMenuAttrib_Click(object sender, EventArgs e)
        {
            //take the selected stock item and assign it to the menu
            //i.e change the foreign key of on of the fields in the menu record
            if (m_SelectedStockItem < 0)
            {
                return;
            }

            CHOOSEN_ITEM = Raw_Stock.RetrieveById(m_SelectedStockItem);
            Console.WriteLine(CHOOSEN_ITEM.Name);
            this.Close();
        }
Esempio n. 7
0
 private void btnAddStock_Click(object sender, EventArgs e)
 {
     try
     {
         if (Raw_Stock.Add(new Raw_Stock(txtStockName.Text, comboStockCategory.Text, (int)numStockQty.Value,
                                         (int)numReorderLevel.Value, Convert.ToDecimal(txtPrice.Text), ((Supplier)comboSupplier.SelectedItem))))
         {
             MessageBox.Show("Stock Item Added!", "Success:", MessageBoxButtons.OK);
             LoadStock();
             return;
         }
     }
     catch
     {
         MessageBox.Show("Failed to Add Stock, Check your input!", "ERROR:", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 8
0
 public void LoadStock()
 {
     searchLimterTimer.Start();
     //load all stock initally
     dataGridStock.DataSource = Raw_Stock.RetrieveAll();
 }
Esempio n. 9
0
 private void LoadLowStock()
 {
     dataGridLowStock.DataSource = Raw_Stock.RetrieveLowStock();
 }