Example #1
0
        void XUCCategory_SaveToDBEvent(object sender, EventArgs e)
        {
            TreeNode node = sender as TreeNode;

            if (node == null)
            {
                return;
            }
            CategoryBiz categoryBiz = new CategoryBiz();

            if (node.Tag == null)
            {
                categoryBiz.Add(
                    new Model.Category()
                {
                    ICId          = categoryBiz.GetMaxNextId(),
                    CCategoryName = node.Text,
                    CRemark       = String.Empty,
                    IParentId     = 0
                });
            }
            else
            {
                //categoryBiz.(
                //    new Model.Category()
                //    {
                //        ICId = Convert.ToInt32(node.Tag),
                //        CCategoryName = node.Text,
                //        CRemark = String.Empty,
                //        IParentId = 0
                //    });
            }
        }
        /// <summary>
        /// Listar categorias para generar el modelo que luego
        /// se lo paso a la vista para que la muestre
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var biz   = new CategoryBiz();
            var model = biz.List();

            return(View(model));
        }
        public void GetAll()
        {
            ICategoryData _category = new CategoryData();
            CategoryBiz   category  = new CategoryBiz(_category);

            Assert.AreEqual(2, category.GetAll().list.Count());
        }
        public ActionResult Delete(Category model)
        {
            var biz = new CategoryBiz();

            biz.Eliminar(model);
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            var biz   = new CategoryBiz();
            var model = biz.Get(id);

            return(View(model));
        }
Example #6
0
        public ActionResult Delete(Category model)
        {
            var biz = new CategoryBiz();

            biz.Eliminar(model);

            return(View(model));
        }
Example #7
0
        public ActionResult Edit(Category model)
        {
            var biz = new CategoryBiz();

            biz.Modificar(model);

            return(View(model));
        }
Example #8
0
        private void DropDownAllThirdCategory()
        {
            List <Category> objCategoryList = new List <Category>();

            objCategoryBiz = new CategoryBiz();

            objCategoryList                 = objCategoryBiz.AllThirdCategoryList();
            ddlThirdCategory.DataSource     = objCategoryList;
            ddlThirdCategory.DataValueField = "CategoryId";
            ddlThirdCategory.DataTextField  = "CategoryName";
            ddlThirdCategory.DataBind();
        }
Example #9
0
        private void PopulateDropDownForFirstCategory()
        {
            List <Category> objCategoryList = new List <Category>();

            objCategoryBiz = new CategoryBiz();

            objCategoryList                 = objCategoryBiz.GetCategoryList();
            ddlFirstCategory.DataSource     = objCategoryList;
            ddlFirstCategory.DataValueField = "CategoryId";
            ddlFirstCategory.DataTextField  = "CategoryName";
            ddlFirstCategory.DataBind();
        }
Example #10
0
        private bool CreateFirstCategory()
        {
            objCategory    = new Category();
            objCategoryBiz = new CategoryBiz();

            objCategory.CategoryLevel       = Convert.ToByte(ddlCategoryType.SelectedValue);
            objCategory.CategoryName        = txtCategoryName.Text.Trim();
            objCategory.CategoryDescription = txtCategoryDescription.Text.Trim();
            objCategory.CreatedBy           = Convert.ToInt16(Session["UserId"]);

            MessageBox(objCategoryBiz.CreateFirstCategory(objCategory));

            return(true);
        }
 public ActionResult Delete(Category model)
 {
     try
     {
         var biz = new CategoryBiz();
         biz.Delete(model);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(View(model));
     }
 }
Example #12
0
        private void PopulateDropDownForThirdCategory()
        {
            objCategory = new Category();

            List <Category> objCategoryList = new List <Category>();

            objCategoryBiz = new CategoryBiz();
            objCategory.CategoryParentId = Convert.ToInt16(ddlSecondCategory.SelectedValue);
            objCategoryList                 = objCategoryBiz.GetCategoryList(objCategory);
            ddlThirdCategory.DataSource     = objCategoryList;
            ddlThirdCategory.DataValueField = "CategoryId";
            ddlThirdCategory.DataTextField  = "CategoryName";
            ddlThirdCategory.DataBind();
        }
Example #13
0
        private void PopulateDropDownForFirstCategory()
        {
            List <Category> objCategoryList = new List <Category>();

            objCategoryBiz = new CategoryBiz();

            objCategoryList                 = objCategoryBiz.GetCategoryList();
            ddlFirstCategory.DataSource     = objCategoryList;
            ddlFirstCategory.DataValueField = "CategoryId";
            ddlFirstCategory.DataTextField  = "CategoryName";
            ddlFirstCategory.DataBind();

            ddlFirstCategory.Items.Insert(0, new ListItem("--Select Category--", "0"));
        }
Example #14
0
        // Create third category
        private bool CreateThirdCategory()
        {
            objCategory    = new Category();
            objCategoryBiz = new CategoryBiz();

            objCategory.CategoryLevel       = 3; // Hardcoded value the category level
            objCategory.CategoryName        = txtCategoryName.Text.Trim();
            objCategory.CategoryDescription = txtCategoryDescription.Text.Trim();
            objCategory.CategoryParentId    = Convert.ToInt16(ddlSecondCategory.SelectedValue);
            objCategory.CreatedBy           = Convert.ToInt16(Session["UserId"]);

            MessageBox(objCategoryBiz.CreateSubCategory(objCategory));

            return(true);
        }
Example #15
0
        private void GridViewBindCategoryInfo()
        {
            objCategoryBiz = new CategoryBiz();

            DataTable dtCategory = new DataTable();

            dtCategory = objCategoryBiz.GetCategoryListForGv(txtCategoryName.Text.Trim());
            gvDisplayCategory.DataSource = dtCategory;
            gvDisplayCategory.DataBind();
            gvDisplayCategory.ShowHeaderWhenEmpty = true;
            gvDisplayCategory.EmptyDataText       = "No data found";

            gvDisplayCategory.AlternatingRowStyle.BackColor = System.Drawing.Color.AliceBlue;
            gvDisplayCategory.SelectedRowStyle.BackColor    = System.Drawing.Color.DarkKhaki;
        }
Example #16
0
        private void PopulateDropDownForSecondCategory()
        {
            objCategory = new Category();

            List <Category> objCategoryList = new List <Category>();

            objCategoryBiz = new CategoryBiz();
            objCategory.CategoryParentId = Convert.ToInt16(ddlFirstCategory.SelectedValue);
            objCategoryList = objCategoryBiz.GetCategoryList(objCategory);
            ddlSecondCategory.DataSource     = objCategoryList;
            ddlSecondCategory.DataValueField = "CategoryId";
            ddlSecondCategory.DataTextField  = "CategoryName";
            ddlSecondCategory.DataBind();

            ddlSecondCategory.Items.Insert(0, new ListItem("--Select Category--", "0"));
        }
        public ActionResult Create(Category model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                var biz = new CategoryBiz();
                biz.Agregar(model);
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                /// Que pasa con el error -> Bitacoras
                Console.WriteLine(e);
                return(View(model));
            }
        }
        public ActionResult Create(Category model)
        {
            if (!ModelState.IsValid) // Para controlar si el modelo es vĂ¡lido
            {
                return(View());
            }

            // TODO: implementar para bitacora
            try
            {
                var biz = new CategoryBiz();
                biz.Create(model);
                return(RedirectToAction("Index"));// Para redireccionar al index de Categorias
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(View(model));
            }
        }
Example #19
0
        private bool EditCategory()
        {
            objCategory    = new Category();
            objCategoryBiz = new CategoryBiz();

            GridViewRow row = gvDisplayCategory.SelectedRow;

            objCategory.CategoryId         = Convert.ToInt16(gvDisplayCategory.DataKeys[row.RowIndex].Values[0].ToString());
            objCategory.CategoryName       = txtFirstCategory.Text.Trim();
            objCategory.SecondCategoryId   = Convert.ToInt16(gvDisplayCategory.DataKeys[row.RowIndex].Values[1].ToString());
            objCategory.SecondCategoryName = txtSecondCategory.Text.Trim();
            objCategory.ThirdCategoryId    = Convert.ToInt16(gvDisplayCategory.DataKeys[row.RowIndex].Values[2].ToString());
            objCategory.ThirdCategoryName  = txtThirdCategory.Text.Trim();

            objCategory.CategoryDescription = txtUpdateCategoryDescription.Text.Trim();
            objCategory.IsActive            = Convert.ToBoolean(ddlUpdateCategoryStatus.SelectedValue);
            objCategory.UpdatedBy           = Convert.ToInt16(Session["UserId"].ToString());

            objCategoryBiz.EditCategory(objCategory);

            return(true);
        }
        public ActionResult Create()
        {
            var             categoryBiz  = new CategoryBiz();
            List <Category> categoryList = (from c in categoryBiz.List()
                                            select new Category
            {
                Id = c.Id,
                Name = c.Name
            }).ToList();

            List <SelectListItem> categories = categoryList.ConvertAll(c =>
            {
                return(new SelectListItem()
                {
                    Text = c.Name.ToString(),
                    Value = c.Id.ToString(),
                    Selected = false
                });
            });

            ViewBag.items = categories;

            return(View());
        }
Example #21
0
        public void GetAll()
        {
            CategoryBiz category = new CategoryBiz();

            Assert.AreEqual(2, category.GetAll().list.Count());
        }