示例#1
0
        private void LoadGrid()
        {
            List <FoodItemDetails> lstfd = bft.GetAllFoodItems();

            foodGridView.DataSource = lstfd;
            for (int i = 0; i < foodGridView.Columns.Count; i++)
            {
                if (foodGridView.Columns[i] is DataGridViewImageColumn)
                {
                    ((DataGridViewImageColumn)foodGridView.Columns[i]).ImageLayout = DataGridViewImageCellLayout.Zoom;
                    break;
                }
            }
            DataGridViewRow row = foodGridView.RowTemplate;

            row.Height = 40;
        }
        private void PopulateData()
        {
            var foodItem = bft.GetAllFoodItems().Where(s => s.Id == Convert.ToInt32(txtItemID.Text)).FirstOrDefault();

            if (foodItem != null)
            {
                txtCategoryName.Text = foodItem.CategoryName;
                txtFoodName.Text     = foodItem.FoodName;
                txtPrice.Text        = foodItem.Price;
                if (foodItem.Status == "Active")
                {
                    radioBtnActive.Checked = true;
                }

                else
                {
                    radioBtnInactive.Checked = true;
                }
                if (foodItem.IsSpecial == "Yes")
                {
                    chkIsSpecial.Checked = true;
                }
                else
                {
                    chkIsSpecial.Checked = false;
                }
                txtDiscount.Text = foodItem.Discount;

                Byte[] img = (Byte[])foodItem.Image;

                MemoryStream ms = new MemoryStream(img);

                pictureBox1.Image         = Image.FromStream(ms);
                btnDeleteFoodItem.Visible = true;
                btnUpdateFoodItem.Visible = true;
                btnSearch.Enabled         = false;
            }
            else
            {
                MessageBox.Show("No Record Found", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }