Exemplo n.º 1
0
        public ActionResult Menu(int?CompID, int?CateID, int?GroupID)
        {
            if (CompID > 0)
            {
                svProductGroup = new ProductGroupService();
                svCategory     = new CategoryService();
                GetStatusWebsite();
                string sqlWhere     = "IsDelete = 0 AND ProductCount>0 AND CompID =" + CompID;
                var    ProductGroup = svProductGroup.SelectData <view_ProductGroup>(" * ", sqlWhere, " ListNo ASC, ProductGroupName ASC");
                ViewBag.GroupID = GroupID != null ? GroupID : 0;
                ViewBag.CateID  = CateID != null ? CateID : 0;
                if (svProductGroup.TotalRow > 0)
                {
                    ViewBag.ProductGroup = ProductGroup;

                    return(PartialView("UC/ProductGroupMenu"));
                }
                else
                {
                    ViewBag.IndrustryCategories = svCategory.ListIndrustryCategory((int)CompID);
                    //ViewBag.WholesaleCategory = svCategory.ListWholesaleCategory((int)CompID);

                    return(PartialView("UC/CategoriesMenu"));
                }
            }
            else
            {
                return(Redirect(res.Pageviews.PvNotFound));
            }
        }
        public ActionResult SaveGroupProduct(string ProductGroupName, int?GroupID, short?RowVersion)
        {
            if (!CheckIsLogin())
            {
                return(Redirect(res.Pageviews.PvMemberSignIn));
            }
            var svProductGroup = new ProductGroupService();
            var model          = new b2bProductGroup();

            try
            {
                #region Set Model

                if (GroupID > 0)
                {
                    model.ProductGroupID = (int)GroupID;
                }
                else
                {
                    var sqlWhere = "IsDelete = 0 and CompID = " + LogonCompID;
                    var data     = svProductGroup.SelectData <b2bProductGroup>("*", sqlWhere, "ListNo DESC");
                    if (svProductGroup.TotalRow == 0)
                    {
                        model.ListNo = 1;
                    }
                    else
                    {
                        model.ListNo = data.First().ListNo + 1;
                    }
                }
                if (RowVersion > 0)
                {
                    model.RowVersion = (short)RowVersion;
                }

                model.ProductGroupName = ProductGroupName;
                model.CompID           = LogonCompID;
                model.IsShow           = true;
                #endregion

                svProductGroup.SaveProductGroup(model);
            }
            catch (Exception ex)
            {
                CreateLogFiles(ex);
            }

            return(Json(new { IsResult = svProductGroup.IsResult, MsgError = GenerateMsgError(svProductGroup.MsgError), ID = model.ProductGroupID }));
        }