Exemple #1
0
        private void dgv_ShowUp_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            lb_FoodId.Text   = dgv_ShowUp.CurrentRow.Cells["FoodId"].Value.ToString();
            foodId           = lb_FoodId.Text;
            lb_FoodName.Text = dgv_ShowUp.CurrentRow.Cells["FoodName"].Value.ToString();
            foodName         = lb_FoodName.Text;
            //lb_CategoryName.Text = dgv_ShowUp.CurrentRow.Cells["CategoryName"].Value.ToString();

            categoryDTO dto = new categoryDTO();

            dto.categoryId = dgv_ShowUp.CurrentRow.Cells["CategoryId"].Value.ToString();

            foodBO  bo     = new foodBO();
            DataSet result = bo.getCategoryNameByID(dto);

            lb_CategoryName.Text = result.Tables[0].Rows[0][0].ToString();
            categoryName         = lb_CategoryName.Text;
            System.Byte[] arr = (dgv_ShowUp.CurrentRow.Cells["FoodPicture"].Value) as System.Byte[];
            foodPicture = arr;
            MemoryStream stream = new MemoryStream(arr);
            Image        img    = Image.FromStream(stream);

            pb_FoodPicture.Image = img;

            int Price = int.Parse(dgv_ShowUp.CurrentRow.Cells["FoodPrice"].Value.ToString());

            lb_FoodPrice.Text = String.Format("{0:n0}", Price);
            foodPrice         = Price;
        }
Exemple #2
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            if (checkingBeforeClickEditOrDelete() == true)
            {
                Edit_Food_Form edit = new Edit_Food_Form();
                edit.ShowDialog();
                Loading_Food();
                lb_FoodId.Text   = dgv_ShowUp.CurrentRow.Cells["FoodId"].Value.ToString();
                foodId           = lb_FoodId.Text;
                lb_FoodName.Text = dgv_ShowUp.CurrentRow.Cells["FoodName"].Value.ToString();
                foodName         = lb_FoodName.Text;

                string categoryId = dgv_ShowUp.CurrentRow.Cells["CategoryId"].Value.ToString();

                foodBO      bo  = new foodBO();
                categoryDTO dto = new categoryDTO();
                dto.categoryId = categoryId;

                DataSet result = bo.getCategoryNameByID(dto);

                lb_CategoryName.Text = result.Tables[0].Rows[0][0].ToString();

                System.Byte[] arr = (dgv_ShowUp.CurrentRow.Cells["FoodPicture"].Value) as System.Byte[];
                foodPicture = arr;
                MemoryStream stream = new MemoryStream(arr);
                Image        img    = Image.FromStream(stream);
                pb_FoodPicture.Image = img;

                int Price = int.Parse(dgv_ShowUp.CurrentRow.Cells["FoodPrice"].Value.ToString());
                lb_FoodPrice.Text = String.Format("{0:n0}", Price);
                foodPrice         = Price;
            }
            else
            {
                MessageBox.Show("Vui lòng chọn danh mục để thực hiện sửa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }