示例#1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xóa!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
     {
         return;
     }
     else
     {
         _SubCategoryBusiness = new SubCategoryBusiness();
         var  index   = dgvListSubCategory.CurrentCell.RowIndex;
         bool kiemTra = false;
         kiemTra = _SubCategoryBusiness.CanDeleteSubCategory(int.Parse(dgvListSubCategory.Rows[index].Cells[0].Value.ToString()));
         if (kiemTra == false)
         {
             MessageBox.Show("Loại điện thoại thuộc danh mục này chưa thể xóa được! muốn xóa loại này xin xóa các sản phẩm của loại điện thoại thuộc danh mục này trước", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             if (_SubCategoryBusiness.DeleteSubCategory(int.Parse(dgvListSubCategory.Rows[index].Cells[0].Value.ToString())))
             {
                 MessageBox.Show("Xóa Thành Công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Xóa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
         }
     }
 }
示例#2
0
 private void cbCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     _ItemBusiness        = new ItemBusiness();
     _CategoryBusiness    = new CategoryBusiness();
     _SubCategoryBusiness = new SubCategoryBusiness();
     if (cbCategory.Items.Count > 0)
     {
         int index = cbCategory.SelectedIndex;
         if (index == 0)
         {
             dgvSubCategory.Rows.Clear();
             dgvItem.Rows.Clear();
         }
         else
         {
             _lstSubCategory = _SubCategoryBusiness.GetListSubCategoryWhenIdCategory((int)cbCategory.SelectedValue);
             dgvSubCategory.Rows.Clear();
             for (int i = 0; i < _lstSubCategory.Count; i++)
             {
                 var c = dgvSubCategory.Rows.Add();
                 dgvSubCategory.Rows[c].Cells[0].Value = _lstSubCategory[i].Id;
                 dgvSubCategory.Rows[c].Cells[1].Value = _lstSubCategory[i].Name;
             }
             _lstItem = _ItemBusiness.GetListItemWhenCategoryId((int)cbCategory.SelectedValue);
             dgvItem.Rows.Clear();
             for (int j = 0; j < _lstItem.Count; j++)
             {
                 var d = dgvItem.Rows.Add();
                 dgvItem.Rows[d].Cells[0].Value = _lstItem[j].Id;
                 dgvItem.Rows[d].Cells[1].Value = _ItemBusiness.SelectNameItem(_lstItem[j].Id);
             }
         }
     }
 }
 public ProductViewModel(ProductBusiness productBusiness, SubCategoryBusiness subCategoryBusiness)
 {
     this.productBusiness     = productBusiness;
     this.subCategoryBusiness = subCategoryBusiness;
     UploadCommand            = new RelayCommand((object obj) => Upload());
     ReUploadCommand          = new RelayCommand((object obj) => ReUpload((Product)obj));
 }
示例#4
0
 public LoadPartialController()
 {
     this._unitOfWork          = new UnitOfWork(_df);
     this._categoryBusiness    = new CategoryBusiness(_df, this._unitOfWork);
     this._subCategoryBusiness = new SubCategoryBusiness(_df, this._unitOfWork);
     this._brandBusiness       = new BrandBusiness(_df, this._unitOfWork);
     this._productBusiness     = new ProductBusiness(_df, this._unitOfWork);
     this._sliderBusiness      = new SliderBusiness(_df, this._unitOfWork);
     this._ImageBusiness       = new ImageBusiness(_df, this._unitOfWork);
 }
示例#5
0
 public DetailController()
 {
     this._unitOfWork               = new UnitOfWork(_df);
     this._productBusiness          = new ProductBusiness(_df, this._unitOfWork);
     this._ImageBusiness            = new ImageBusiness(_df, this._unitOfWork);
     this._ReviewBusiness           = new ReviewBusiness(_df, this._unitOfWork);
     this._userBusiness             = new UserBusiness(_df, this._unitOfWork);
     this._CategoryBusiness         = new CategoryBusiness(_df, this._unitOfWork);
     this._SubCategoryBusiness      = new SubCategoryBusiness(_df, this._unitOfWork);
     this._productSizeBusiness      = new ProductSizeBusiness(_df, this._unitOfWork);
     this._productAttributeBusiness = new ProductAttributeBusiness(_df, this._unitOfWork);
 }
示例#6
0
        //
        // GET: /Product/

        public AdminProductController()
        {
            this._unitOfWork               = new UnitOfWork(_df);
            this._productBusiness          = new ProductBusiness(_df, this._unitOfWork);
            this._productSizeBusiness      = new ProductSizeBusiness(_df, this._unitOfWork);
            this._productAttributeBusiness = new ProductAttributeBusiness(_df, this._unitOfWork);
            this._brandBusiness            = new BrandBusiness(_df, this._unitOfWork);
            this._categoryBusiness         = new CategoryBusiness(_df, this._unitOfWork);
            this._imageBusiness            = new ImageBusiness(_df, this._unitOfWork);
            this._sliderBusiness           = new SliderBusiness(_df, this._unitOfWork);
            this._subCategoryBusiness      = new SubCategoryBusiness(_df, this._unitOfWork);
        }
示例#7
0
 public ProductController()
 {
     this._unitOfWork               = new UnitOfWork(_df);
     this._categoryBusiness         = new CategoryBusiness(_df, this._unitOfWork);
     this._subCategoryBusiness      = new SubCategoryBusiness(_df, this._unitOfWork);
     this._brandBusiness            = new BrandBusiness(_df, this._unitOfWork);
     this._productBusiness          = new ProductBusiness(_df, this._unitOfWork);
     this._productSizeBusiness      = new ProductSizeBusiness(_df, this._unitOfWork);
     this._productAttributeBusiness = new ProductAttributeBusiness(_df, this._unitOfWork);
     this._ImageBusiness            = new ImageBusiness(_df, this._unitOfWork);
     this._AddToCartBusiness        = new AddToCartBusiness(_df, this._unitOfWork);
     this._WishListBusiness         = new WishListBusiness(_df, this._unitOfWork);
     this._CompareListBusiness      = new CompareListBusiness(_df, this._unitOfWork);
 }
示例#8
0
 private void LoadData()
 {
     _SubCategoryBusiness = new SubCategoryBusiness();
     _CategoryBusiness    = new CategoryBusiness();
     currentAction        = (int)ACTION.LOADING;
     _lstSubCategory      = _SubCategoryBusiness.GetSubCategoryList();
     dgvListSubCategory.Rows.Clear();
     for (int i = 0; i < _lstSubCategory.Count; i++)
     {
         int inDex = dgvListSubCategory.Rows.Add();
         dgvListSubCategory.Rows[inDex].Cells[0].Value = _lstSubCategory[i].Id;
         dgvListSubCategory.Rows[inDex].Cells[1].Value = _CategoryBusiness.SelectNameCategory(_lstSubCategory[i].CategoryId);
         dgvListSubCategory.Rows[inDex].Cells[2].Value = _lstSubCategory[i].Name;
     }
     currentAction = (int)ACTION.NONE;
     if (_lstSubCategory.Count > 0)
     {
         dgvListSubCategory.Rows[0].Selected = true;
     }
 }
 public AdminSubCategoryController()
 {
     this._unitOfWork          = new UnitOfWork(_df);
     this._subcategoryBusiness = new SubCategoryBusiness(_df, this._unitOfWork);
     this._categoryBusiness    = new CategoryBusiness(_df, this._unitOfWork);
 }
示例#10
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            var index = dgvListSubCategory.CurrentCell.RowIndex;

            _SubCategoryBusiness = new SubCategoryBusiness();
            int  ma      = -1;
            bool kiemTra = false;

            if (txtName.Text == "")
            {
                MessageBox.Show("Tên Loại Không Được Trống!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if ((int)cbNameCategory.SelectedValue == -1)
            {
                MessageBox.Show("Vui lòng chọn danh mục!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #region Lưu khi thêm
            else if (g == 1)
            {
                SubCategoryDTO subCategory = new SubCategoryDTO();
                subCategory.Name       = txtName.Text.ToString().Trim();
                subCategory.CategoryId = (int)cbNameCategory.SelectedValue;
                kiemTra = _SubCategoryBusiness.ExisSubName(txtName.Text.ToString(), ma, (int)cbNameCategory.SelectedValue);
                if (kiemTra == false)
                {
                    MessageBox.Show("Tên loại thuộc danh mục này đã tồn tại! Vui Lòng Chọn Tên Khác", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (_SubCategoryBusiness.AddSubCategory(subCategory))
                    {
                        MessageBox.Show("Thêm mới thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadData();
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            #endregion

            #region Lưu khi sửa
            else if (g == 2)
            {
                SubCategoryDTO subCategory = _lstSubCategory.ElementAtOrDefault(index);
                subCategory.Name       = txtName.Text.ToString().Trim();
                subCategory.CategoryId = (int)cbNameCategory.SelectedValue;
                kiemTra = _SubCategoryBusiness.ExisSubName(txtName.Text.ToString(), int.Parse(dgvListSubCategory.Rows[index].Cells[0].Value.ToString()), (int)cbNameCategory.SelectedValue);
                if (kiemTra == false)
                {
                    MessageBox.Show("Tên loại thuộc danh mục này đã tồn tại! Vui Lòng Chọn Tên Khác", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (_SubCategoryBusiness.EditSubCategory(subCategory))
                    {
                        MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LoadData();
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            #endregion

            DieuKhien((int)DIEUKHIEN.MO);
            g = 0;
        }
示例#11
0
 public SubCategoryViewModel(SubCategoryBusiness subCategoryBusiness, CategoryBusiness categoryBusiness)
 {
     this.categoryBusiness    = categoryBusiness;
     this.subCategoryBusiness = subCategoryBusiness;
 }