private void table_SelectionChanged(object sender, EventArgs e)
        {
            if (table.SelectedCells.Count > 0)
            {
                int             selectedrowindex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = table.Rows[selectedrowindex];
                pictureBox.ImageLocation = Convert.ToString(selectedRow.Cells["Picture"].Value);
                nameBox.Text             = Convert.ToString(selectedRow.Cells["Name"].Value);
                priceBox.Text            = Convert.ToString(selectedRow.Cells["Price"].Value);
                descriptionBox.Text      = Convert.ToString(selectedRow.Cells["Description"].Value);
                discountBox.Text         = Convert.ToString(selectedRow.Cells["Discount_Rate"].Value);
                chargesBox.Text          = Convert.ToString(selectedRow.Cells["Other_Charges"].Value);
                stockBox.Text            = Convert.ToString(selectedRow.Cells["Stock_Count"].Value);

                var availability = Convert.ToString(selectedRow.Cells["Availability"].Value);
                if (availability.Equals("Yes"))
                {
                    radioYes.Checked = true;
                }
                else
                {
                    radioNo.Checked = true;
                }

                Software.Model.Food_Type type = types.Single(t => t.Id == Convert.ToInt32(Convert.ToString(selectedRow.Cells["Type_Id"].Value)));
                typeComboBox.SelectedIndex = typeComboBox.FindStringExact(type.Type_Name);
            }
        }
        private void updateBtn_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = 0;

            if (table.SelectedCells.Count > 0)
            {
                Software.Model.Food_Type type = new Software.Model.Food_Type();

                selectedRowIndex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow = table.Rows[selectedRowIndex];

                type.Id          = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value));
                type.Type_Name   = nameBox.Text;
                type.Description = descriptionBox.Text;
                Software.Database.SQL.Food_TypeDB.UpdateFood_Type(type);
                MetroFramework.MetroMessageBox.Show(this, "Your data has been updated.", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "You must select a row to update its value!", "Invalid Selection", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            DoRefresh();
            table.CurrentCell = table.Rows[selectedRowIndex].Cells[0];
            table.Rows[selectedRowIndex].Selected = true;
        }
 private void createBtn_Click(object sender, EventArgs e)
 {
     Software.Model.Food_Type type = new Software.Model.Food_Type
     {
         Type_Name   = nameBox.Text,
         Description = descriptionBox.Text
     };
     Software.Database.SQL.Food_TypeDB.InsertFood_Type(type);
     MetroFramework.MetroMessageBox.Show(this, "Sucess", "Data Inserted Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
     Close();
 }