Example #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");
                }
            }
        }
Example #2
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();
        }