Example #1
0
        private void loadingCategory()
        {
            flp_Category.Controls.Clear();
            categoryBO bo     = new categoryBO();
            DataSet    result = bo.getAllCategory();

            for (int i = 0; i < result.Tables[0].Rows.Count; i++)
            {
                System.Byte[] arr = (result.Tables[0].Rows[i][2]) as System.Byte[];
                CategoryList.Add(new categoryDTO {
                    categoryId = result.Tables[0].Rows[i][0].ToString(), categoryName = result.Tables[0].Rows[i][1].ToString(), categoryPicture = arr
                });
                Category categoryUC = new Category();
                categoryUC.CATEGORYID      = CategoryList[i].categoryId;
                categoryUC.CATEGORYNAME    = CategoryList[i].categoryName;
                categoryUC.CATEGORYPICTURE = CategoryList[i].categoryPicture;


                flp_Category.Controls.Add(categoryUC);

                foreach (Control control in categoryUC.Controls)
                {
                    control.Click += (sender, e) =>
                    {
                        loadingFoodByCategoryId(sender, e, categoryUC.CATEGORYID);
                    };
                }
            }
        }
Example #2
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (checkingBeforeClickEditOrDelete() == true)
     {
         DialogResult result = MessageBox.Show("Bạn có muốn xóa danh mục " + lb_CategoryName.Text + " này không ?, Việc này không thể khôi phục lại dữ liệu, Bạn chắc chứ ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (result == DialogResult.Yes)
         {
             categoryDTO dto = new categoryDTO();
             dto.categoryId = lb_CategoryId.Text;
             categoryBO bo      = new categoryBO();
             int        result1 = bo.deleteCategory(dto);
             if (result1 != -1)
             {
                 MessageBox.Show("Đã xóa thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadingCategory();
             }
             else
             {
                 MessageBox.Show("Đã có lỗi trong quá trình xóa, vui lòng kiểm tra lại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn trước khi xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #3
0
 private void btn_Add_Click(object sender, EventArgs e)
 {
     if (checkingBeforeSubmit() == true)
     {
         categoryDTO dto = new categoryDTO();
         dto.categoryId   = txt_CategoryId.Text;
         dto.categoryName = txt_CategoryName.Text;
         //image processing
         Image        img    = Image.FromFile(fileName);
         MemoryStream stream = new MemoryStream();
         img.Save(stream, ImageFormat.Jpeg);
         stream.Seek(0, SeekOrigin.Begin);
         byte[] imgByte = System.IO.File.ReadAllBytes(fileName);
         int    sizeImg = imgByte.Length;
         stream.Read(imgByte, 0, sizeImg);
         //done
         dto.categoryPicture = imgByte;
         //
         categoryBO bo     = new categoryBO();
         int        result = bo.addCategory(dto);
         if (result == -1)
         {
             MessageBox.Show("Có lỗi xảy ra, vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             Reset();
         }
     }
     else
     {
         MessageBox.Show("Vui lòng điền thông tin đầy đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #4
0
        private void loadingCategory()
        {
            categoryBO bo     = new categoryBO();
            DataSet    result = bo.getAllCategory();

            dgv_ShowUp.DataSource    = result.Tables[0];
            lb_CategoryId.Text       = "";
            lb_CategoryName.Text     = "";
            pb_CategoryPicture.Image = null;
            ;
        }