protected void AddSubCatagory(object parameter)
        {
            string  sub_category_name;
            TextBox tb = (TextBox)parameter;

            sub_category_name = tb.Text;
            if ((sub_category_name != "") && (SelectedCategory != null))
            {
                List <sub_category> temp_list = SubCategoryServices.GetAllSubCategoryByName(sub_category_name.Trim(), SelectedCategory.id);
                if (temp_list.Count == 0)
                {
                    sub_category ct = new sub_category();
                    ct.id = 0;
                    ct.subcategory_name = sub_category_name;
                    ct.category         = SelectedCategory.id;
                    int temp_SubCategory_id = SubCategoryServices.AddUpdateSubCategory(ct);
                    if (temp_SubCategory_id != 0)
                    {
                        // MessageBox.Show("Category " + sub_category_name + " is Created");
                        InventoryHelper.SuccessAlert("Success", "Category " + sub_category_name + " is Created");
                        BindGrid();
                    }
                }
            }
        }
Beispiel #2
0
        public UnitOfWork(ApplicationDbContext db, IHttpContextAccessor httpContextAccessor, IEmailSender emailSender)
        {
            _db = db;
            _httpContextAccessor = httpContextAccessor;
            _emailSender         = emailSender;

            Category            = new CategoryServices(db);
            SubCategory         = new SubCategoryServices(db);
            Coupon              = new CouponServices(db);
            User                = new UserServices(db, httpContextAccessor);
            MenuItem            = new MenuItemServices(db);
            ShoppingCart        = new ShoppingCartServices(db);
            OrderServices       = new OrderServices(db, emailSender);
            OrderDetailServices = new OrderDetailServices(db);
        }
 public ProcurementController()
 {
     UnitOfWork                   = new UnitOfWork();
     ProcurementServices          = new ProcurementServices(UnitOfWork);
     ProcrurementTypeServices     = new ProcrurementTypeServices(UnitOfWork);
     SupplierCompanyServices      = new SupplierCompanyServices(UnitOfWork);
     SubSubSubSubCategoryServices = new SubSubSubSubCategoryServices(UnitOfWork);
     SubSubSubCategoryServices    = new SubSubSubCategoryServices(UnitOfWork);
     SubSubCategoryServices       = new SubSubCategoryServices(UnitOfWork);
     SubCategoryServices          = new SubCategoryServices(UnitOfWork);
     CategoryServices             = new CategoryServices(UnitOfWork);
     ItemServices                 = new ItemServices(UnitOfWork);
     ModelServices                = new ModelServices(UnitOfWork);
     BrandServices                = new BrandServices(UnitOfWork);
     UnitServices                 = new UnitServices(UnitOfWork);
 }
        protected void UpdateSubCatagory(object parameter)
        {
            int     Sub_category_id = 0;
            TextBox tb = (TextBox)parameter;

            int.TryParse(tb.Text, out Sub_category_id);
            if ((Sub_category_id > 0) && (SelectedCategory != null))
            {
                SubCategoryEntity   ob_sub_Category = _lstSubCategory.Where(s => s.id == Sub_category_id).FirstOrDefault();
                List <sub_category> temp_list       = SubCategoryServices.GetAllSubCategoryByName(ob_sub_Category.sub_category_name.Trim(), SelectedCategory.id);
                if (temp_list.Count == 0 || temp_list.Count == 1)
                {
                    if (temp_list.Count == 1)
                    {
                        sub_category temp = temp_list.FirstOrDefault();
                        if (temp.id != ob_sub_Category.id)
                        {
                            BindGrid();
                            //RaisedPropertyChanged("Category");
                            //MessageBox.Show("SubCategory Name alredy Exist.");
                            InventoryHelper.SimpleAlert("Warning", "SubCategory Name alredy Exist.");
                            return;
                        }
                    }
                    sub_category temp_ob_sub_Category = SubCategoryServices.GetSubCategory(ob_sub_Category.id);
                    temp_ob_sub_Category.subcategory_name = ob_sub_Category.sub_category_name;
                    int temp_sub_Category_id = SubCategoryServices.AddUpdateSubCategory(temp_ob_sub_Category);
                    if (temp_sub_Category_id == ob_sub_Category.id)
                    {
                        //MessageBox.Show("Sub-Category " + ob_sub_Category.sub_category_name + " is Updated");
                        InventoryHelper.SuccessAlert("Success", "Sub-Category " + ob_sub_Category.sub_category_name + " is Updated");
                        BindGrid();
                        //RaisedPropertyChanged("Category");
                    }
                }
                else
                {
                    // MessageBox.Show("Category Name already Exist");
                    InventoryHelper.SimpleAlert("Warning", "Category Name already Exist");
                }
            }
        }
        protected void DeleteCatagory(object parameter)
        {
            bool    flag            = false;
            int     Sub_Category_id = 0;
            TextBox tb = (TextBox)parameter;

            int.TryParse(tb.Text, out Sub_Category_id);
            if (Sub_Category_id > 0)
            {
                flag = SubCategoryServices.DeleteSubCategory(Sub_Category_id);
            }
            if (flag == true)
            {
                BindGrid();
                //MessageBox.Show("Category Deleted");
                InventoryHelper.SuccessAlert("Success", "Category Deleted");
            }
            else
            {
                InventoryHelper.SimpleAlert("Warning", "Sub-category are associated with Category");
                //MessageBox.Show("Sub-category are associated with Category ");
            }
        }
Beispiel #6
0
 public static List <SubCategoryEntity> GetAllSubCategoryEntity(int subCategoryId, int CategoryId)
 {
     return(SubCategoryServices.GetAllSubCategoryEntity(subCategoryId, CategoryId));
 }