Example #1
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 #2
0
        public IHttpActionResult getCategories(eventsDTO dto)
        {
            try {
                var helper = new HelperFunctions();

                // get all of an event's AgeGroup names
                var categoryList = _unitOfWork.Category.GetEventsCategories(dto.eventName);
                var AgeGroupList = categoryList.Select(c => c.Category);
                var catNames     = new List <object>();
                // Get all of categories 'Display Name'
                foreach (var group in AgeGroupList)
                {
                    var num = (int)group;

                    var         attrs       = helper.getEnumDisplayAnnotaion(group, num);
                    categoryDTO categoryDTO = new categoryDTO(num, ((DisplayAttribute)attrs[0]).Name);
                    catNames.Add(categoryDTO);
                }

                return(Ok(new JavaScriptSerializer().Serialize(catNames)));
            }
            catch
            {
                return(BadRequest());
            }
        }
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 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;
        }
Example #5
0
        public DataSet getCategoryNameByID(categoryDTO dto)
        {
            DataSet result = new DataSet();
            string  query  = "SELECT CategoryName FROM Category WHERE CategoryId = @categoryId";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@categoryId", dto.categoryId)
            };

            DataAccess data = new DataAccess();

            result = data.GetDataSet(query, para);
            return(result);
        }
Example #6
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);
            }
        }