Example #1
0
        public ActionResult Delete()
        {
            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            string menuid = this.HttpContext.Request["menuid"];

            try
            {
                this.SetConnectionDB();


                int          output       = 0;
                MenuServices menuServices = new MenuServices(this.DBConnection);

                output = menuServices.Delete(Int32.Parse(menuid));
                if (menuServices.ERROR != null)
                {
                    BI_Project.Helpers.FileHelper.SaveFile(menuServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
                }
            }
            catch (Exception ex)
            {
            }


            return(RedirectToAction("List"));
        }
Example #2
0
    protected void btn_saveOrder_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            DataBase     db  = new DataBase();
            MenuServices obj = new MenuServices();

            foreach (var i in obj.itemMenu)
            {
                if (i.itemName == ddl_items.Text)
                {
                    this.price = i.itemPrice;
                }
            }

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "INSERT INTO bill values(@itemName,@quatity,@custName,@contact,@totalBill)";
            cmd.Parameters.AddWithValue("@itemName", ddl_items.SelectedValue);
            cmd.Parameters.AddWithValue("@quatity", txt_quant.Text);
            cmd.Parameters.AddWithValue("@custName", txt_name.Text);
            cmd.Parameters.AddWithValue("@contact", txt_contact.Text);
            txt_totalbill.Text = (Convert.ToInt32(txt_quant.Text) * this.price).ToString();
            cmd.Parameters.AddWithValue("@totalBill", txt_totalbill.Text);

            int result = db.ExecuteNonQuery(cmd);
            if (result > 0)
            {
                Response.Write("INSERTED INTO BILL TABLE !");
            }
        }
        else
        {
            Response.Write("<script>alert('Invalid')</script>");
        }
    }
Example #3
0
        public ActionResult GetEmpMenu()
        {
            string strJson = string.Empty;

            try
            {
                if (!WebCookieHelper.EmployeeCheckLogin())
                {
                    return(RedirectToAction("Admin/Account/Login"));
                }

                int nEmpID = WebCookieHelper.GetEmployeeId();

                var menus = MenuServices.GetMenuByEmpID(nEmpID);


                if (menus.ToList().Count > 0)
                {
                    strJson = JsonHelper.GetMenuJson(menus, 0);
                    strJson = "{" + strJson + "}";
                }
                else
                {
                    strJson = "\"menus\":[]";
                }
                //string strJson = "[{\"id\":\"1\",\"text\":\"hello1\",\"checked\":\"true\",\"state\":\"open\",\"children\":[{\"id\":\"2\",\"text\":\"hello2\",\"state\":\"open\"}]},{\"id\":\"1\",\"text\":\"hello1\",\"state\":\"open\",\"children\":[{\"id\":\"2\",\"text\":\"hello2\",\"state\":\"open\"}]}]";
            }
            catch (Exception ex)
            {
                throw;
            }
            return(Content(strJson));
        }
Example #4
0
        static void Main(string[] args)
        {
            MenuServices menu = new MenuServices();

            menu.Iniciar();
            Console.ReadKey();
        }
        protected virtual void RegisterTypes(IUnityContainer container)
        {
            //Standard configuration
            StandardUnityConfig.RegisterStandardFacetFactories(container);
            StandardUnityConfig.RegisterCoreContainerControlledTypes(container);
            StandardUnityConfig.RegisterCorePerTransactionTypes <PerResolveLifetimeManager>(container);

            container.RegisterType <IPrincipal>(new InjectionFactory(c => TestPrincipal));
            var config = new EntityObjectStoreConfiguration();

            //config.UsingEdmxContext("Model").AssociateTypes(AdventureWorksTypes);
            //config.SpecifyTypesNotAssociatedWithAnyContext(() => new[] { typeof(AWDomainObject) });

            container.RegisterInstance <IEntityObjectStoreConfiguration>(config, (new ContainerControlledLifetimeManager()));

            // TODO still done for backward compatibility -
            var reflectorConfig = new ReflectorConfiguration(
                Types ?? new Type[] {},
                MenuServices.Select(s => s.GetType()).ToArray(),
                ContributedActions.Select(s => s.GetType()).ToArray(),
                SystemServices.Select(s => s.GetType()).ToArray(),
                Namespaces ?? new string[] { });

            container.RegisterInstance <IReflectorConfiguration>(reflectorConfig, (new ContainerControlledLifetimeManager()));
            container.RegisterType <ISession>(new PerResolveLifetimeManager(), new InjectionFactory(c => TestSession));
        }
Example #6
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static MenuModel Update(MenuModel model)
        {
            var entity = new Menu();

            model.FillEntity(ref entity);
            return(new MenuModel(MenuServices.Update(entity)));
        }
        public void CleanMainMenuModelInvalidTests()
        {
            //Arrange
            UserModel user = new UserModel
            {
                Email     = "*****@*****.**",
                SuperUser = true
            };

            //Act
            var cleanMenu = new MenuServices().CleanMainMenuModel(null, user);

            //Assert
            Assert.IsNull(cleanMenu);

            MainMenuModels menu = new MainMenuModels {
                MenuItems = null
            };

            cleanMenu = new MenuServices().CleanMainMenuModel(menu, user);

            //Assert
            Assert.IsNull(cleanMenu);

            menu      = MenuServicesTests.GetUnitTestMenu();
            cleanMenu = new MenuServices().CleanMainMenuModel(menu, null);

            //Assert
            Assert.IsNull(cleanMenu);
        }
        public void GetParentIdForMenuItemInvalidTests()
        {
            //Arrange
            var menu = MenuServicesTests.GetUnitTestMenu();

            //Act - fetch the parent ID
            MenuServices services = new MenuServices();
            int          parentId = services.GetParentIdForMenuItem("", menu);

            //Assert
            Assert.AreEqual(-1, parentId);

            parentId = services.GetParentIdForMenuItem(null, menu);

            //Assert
            Assert.AreEqual(-1, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", null);

            //Assert
            Assert.AreEqual(-1, parentId);

            menu = new MainMenuModels {
                MenuItems = null
            };

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", menu);

            //Assert
            Assert.AreEqual(-1, parentId);
        }
Example #9
0
        public void AddMenu_ValidInput_ExpectTwoitems()
        {
            //Act
            DtoMenu menu = new DtoMenu()
            {
                TypeOfMenu     = MenuType.Meals,
                RestaurantName = "seavus restaurant",
            };
            DtoMenu menu2 = new DtoMenu()
            {
                TypeOfMenu     = MenuType.Meals,
                RestaurantName = "seavus restaurant",
            };


            var menuService = new MenuServices();
            var resultOne   = menuService.Add(menu);
            var resultThree = menuService.Add(menu2);

            var result = menuService.LoadAll();


            //assert

            Assert.IsNotNull(resultThree);
            Assert.IsTrue(resultThree.Success);
            Assert.IsNotNull(resultOne);
            Assert.IsTrue(resultOne.Success);
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Success);
            Assert.IsNotNull(result.ListItems);
            Assert.IsTrue(result.ListItems.Any());
        }
        public void GetParentIdForMenuItemTests()
        {
            //Arrange
            var menu = MenuServicesTests.GetUnitTestMenu();

            //Act - fetch the parent ID
            MenuServices services = new MenuServices();
            int          parentId = services.GetParentIdForMenuItem("Unit Test Admin", menu);

            //Assert
            Assert.AreEqual(1, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Development", menu);

            //Assert
            Assert.AreEqual(2, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Testing", menu);

            //Assert
            Assert.AreEqual(3, parentId);

            parentId = services.GetParentIdForMenuItem("Unit Test Design", menu);

            //Assert
            Assert.AreEqual(4, parentId);
        }
Example #11
0
        /// <summary>
        /// Get all by condition
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="parentId"></param>
        /// <param name="isPanel"></param>
        /// <param name="group"></param>
        /// <param name="status"></param>
        /// <param name="userId"></param>
        /// <param name="isDeleted"></param>
        /// <param name="order"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public static List <MenuModel> GetAll(string keyword, int?parentId, bool?isPanel, MenuGroup?group, MenuStatus?status, int?userId,
                                              bool?isDeleted, string order, int?limit)
        {
            // init condition
            var condition = "1=1";

            // keyword
            if (!string.IsNullOrEmpty(keyword))
            {
                condition += " AND ([MenuName] LIKE N'%{0}%' OR [TabName] LIKE N'%{0}%')".FormatWith(keyword.EscapeQuote());
            }

            // parent id
            if (parentId != null)
            {
                condition += " AND [ParentId]={0}".FormatWith(parentId.Value);
            }

            // is panel
            if (isPanel != null)
            {
                condition += " AND [IsPanel]={0}".FormatWith(isPanel.Value ? 1 : 0);
            }

            // group
            if (group != null)
            {
                condition += " AND [Group]={0}".FormatWith((int)group.Value);
            }

            // status
            if (status != null)
            {
                condition += " AND [Status]={0}".FormatWith((int)status.Value);
            }

            // userId
            if (userId != null)
            {
                condition += @" AND [Id] IN (" +
                             "      SELECT [MenuId] FROM [MenuRole] WHERE [RoleId] IN (" +
                             "          SELECT [RoleId] FROM [UserRole] WHERE [UserId]='{0}'))".FormatWith(userId.Value);
            }

            // deleted
            if (isDeleted != null)
            {
                condition += " AND [IsDeleted]={0}".FormatWith(isDeleted.Value ? 1 : 0);
            }

            // order
            if (string.IsNullOrEmpty(order))
            {
                order = @"[Order]";
            }

            // return
            return(MenuServices.GetAll(condition, order, limit).Select(e => new MenuModel(e)).ToList());
        }
Example #12
0
        /// <summary>
        /// Get Menu List from DB
        /// </summary>
        /// <param name="qModel"></param>
        /// <returns></returns>
        public ActionResult GetMenuList(Menu_Resource_Model qModel)
        {
            try {
                int          count = 0;
                MenuServices mSvg  = new MenuServices();
                List <Menu_Resource_Model> list = mSvg.GetMenuList(qModel, out count);

                List <Object> result = new List <object>();
                foreach (Menu_Resource_Model m in list)
                {
                    if (m.ParentMenuID == "0")
                    {
                        result.Add(new {
                            //icon = m.icon,
                            iconSkin     = m.iconSkin,
                            MenuID       = m.MenuID,
                            ParentMenuID = m.ParentMenuID,
                            MenuUrl      = m.MenuUrl,
                            MR_ID        = m.MR_ID,
                            name         = m.MenuName,
                            SortNo       = m.SortNo,
                            Visible      = m.Visible
                        });
                    }
                    else
                    {
                        result.Add(new {
                            //icon = m.icon,
                            iconSkin     = m.iconSkin,
                            MenuID       = m.MenuID,
                            _parentId    = m.ParentMenuID,
                            ParentMenuID = m.ParentMenuID,
                            MenuUrl      = m.MenuUrl,
                            MR_ID        = m.MR_ID,
                            name         = m.MenuName,
                            SortNo       = m.SortNo,
                            Visible      = m.Visible
                        });
                    }
                }

                return(Json(new NBCMSResultJson {
                    Status = StatusType.OK,
                    Data = new {
                        total = result.Count,
                        rows = result
                    }
                }));
            }
            catch (Exception ex) {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Example #13
0
        public ActionResult GetMenuListForTreeGrid()
        {
            try {
                MenuServices  mSvg   = new MenuServices();
                List <Object> result = new List <object>();
                foreach (Menu_Resource_Model m in mSvg.GetAllMenuList())
                {
                    if (m.ParentMenuID == "0")
                    {
                        result.Add(new {
                            //icon = m.icon,
                            iconSkin     = m.iconSkin,
                            MenuID       = m.MenuID,
                            ParentMenuID = m.ParentMenuID,
                            MenuUrl      = m.MenuUrl,
                            MR_ID        = m.MR_ID,
                            name         = m.MenuName,
                            SortNo       = m.SortNo,
                            Visible      = m.Visible
                        });
                    }
                    else
                    {
                        result.Add(new {
                            //icon = m.icon,
                            iconSkin     = m.iconSkin,
                            MenuID       = m.MenuID,
                            _parentId    = m.ParentMenuID,                         //tree-grid must have those formate...
                            ParentMenuID = m.ParentMenuID,
                            MenuUrl      = m.MenuUrl,
                            MR_ID        = m.MR_ID,
                            name         = m.MenuName,
                            SortNo       = m.SortNo,
                            Visible      = m.Visible
                        });
                    }
                }

                return(Json(new NBCMSResultJson {
                    Status = StatusType.OK,
                    Data = new {
                        total = result.Count,
                        rows = result
                    }
                }));
            }
            catch (Exception ex) {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Example #14
0
        public async Task GetMenusTest()
        {
            var context = await GetSqliteDbContextAsync();

            var services = new MenuServices(context);

            var getMenusResult = services.GetMenus();

            Assert.NotEmpty(getMenusResult);
        }
Example #15
0
 private IReflectorConfiguration MyReflectorConfig()
 {
     return(new ReflectorConfiguration(
                this.Types ?? new Type[] { },
                MenuServices.Select(s => s.GetType()).ToArray(),
                ContributedActions.Select(s => s.GetType()).ToArray(),
                SystemServices.Select(s => s.GetType()).ToArray(),
                Types.Select(t => t.Namespace).Distinct().ToArray(),
                LocalMainMenus.MainMenus));
 }
Example #16
0
        /// <summary>
        /// Load root menu
        /// </summary>
        private void LoadMenu()
        {
            var rootMenus = MenuServices.GetAll(0, false, null, null, null, null);

            foreach (var menu in rootMenus)
            {
                ltrMenuTree.Text +=
                    "<li id='{0}'><div class='menuItemName'>{1}</div><div class='menuItemPermission'>| {2}</div>{3}</li>"
                    .FormatWith(
                        menu.Id, menu.MenuName, LoadMenuPermission(menu), LoadChildMenu(menu.Id));
            }
        }
Example #17
0
        public ActionResult Create(EntityMenuModel menu)
        {
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }

            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetConnectionDB();


            int          output       = 0;
            MenuServices menuServices = new MenuServices(this.DBConnection);

            output = menuServices.CreateMenu(menu);

            /****************************************RESPONSE FAILE OR SUCCESS******************************************/

            this.GetLanguage();
            BlockCreateMenuLangModel blockLang = new BlockCreateMenuLangModel();

            blockLang.BlockName = "block_menu_create";
            blockLang.SetLanguage(this.LANGUAGE_OBJECT);
            Session["msg_text"] = blockLang.GetMessage(output);
            Session["msg_code"] = output;

            if (menuServices.ERROR != null)
            {
                BI_Project.Helpers.FileHelper.SaveFile(menuServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }

            if (menu.MenuId > 0 && output > 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_menu_create.success_edit", this.LANGUAGE_OBJECT);
            }
            if (output == 0)
            {
                Session["msg_text"] = blockLang.GetLangByPath("messages.block_menu_create.error_business_1", this.LANGUAGE_OBJECT);
                //return RedirectToAction("Create?roleid=" + model.RoleId);
            }
            if (output > 0)
            {
                return(RedirectToAction("List"));
            }


            TempData["data"] = menu;
            return(RedirectToAction("Create"));
        }
        /// <summary>
        /// Fetches the required menu structure using a service thyen maps this into a Kendo UI tree structure.
        /// </summary>
        /// <param name="mainmenu"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <IViewComponentResult> InvokeAsync(List <TreeViewItemModel> mainmenu, ISession context = null)
        {
            //for unit-testing we pass in an instance of HttpContext.Session to allow for mocking the environment
            if (context == null)
            {
                context = HttpContext.Session;
            }

            var menuitems = context.Get <List <TreeViewItemModel> >(SessionConstants.TopLevelMenuTree);

            if (menuitems == null)
            {
                LoggingService service   = new LoggingService();
                var            stopwatch = new Stopwatch();

                try
                {
                    List <TreeViewItemModel> treemenu = null;
                    var response = await new MenuServices().GetModulesItemsForUser(
                        context.Get <string>(SessionConstants.EmailClaim),
                        context.Get <string>(SessionConstants.WebServicesUrl),
                        context.Get <string>(SessionConstants.EncodedUserId));

                    response = new MenuServices().CleanMainMenuModel(response, context.Get <UserModel>(SessionConstants.CurrentUser));
                    treemenu = response == null?MainMenuViewComponent.GetEmptyTreeMenu() : response.ToKendoTreeViewItemModelList();

                    context.Set <List <TreeViewItemModel> >(SessionConstants.TopLevelMenuTree, treemenu);
                }
                catch (Exception ex)
                {
                    service.TrackException(ex);
                    throw;
                }
                finally
                {
                    stopwatch.Stop();
                    var properties = new Dictionary <string, string>
                    {
                        { "UserEmail", context.Get <string>(SessionConstants.EmailClaim) },
                        { "WebServicesEndpoint", context.Get <string>(SessionConstants.WebServicesUrl) },
                        { "EncodedId", context.Get <string>(SessionConstants.EncodedUserId) }
                    };
                    service.TrackEvent(LoggingServiceConstants.GetTopLevelModules, stopwatch.Elapsed, properties);
                }
            }
            ViewData[SessionConstants.ViewTopLevelMenuItems] =
                context.Get <List <TreeViewItemModel> >(SessionConstants.TopLevelMenuTree);

            return(View(context.Get <List <TreeViewItemModel> >(SessionConstants.TopLevelMenuTree)));
        }
Example #19
0
        public ActionResult UpdateMenu(Menu_Resource_Model model)
        {
            try {
                if (model == null)
                {
                    return(Json(new NBCMSResultJson {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }

                if (model.MR_ID == 0)
                {
                    return(Json(new NBCMSResultJson {
                        Status = StatusType.Error,
                        Data = "Request paramter is null!"
                    }));
                }
                string             cookis      = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]];
                var                serializer  = new JavaScriptSerializer();
                string             decCookies  = CryptTools.Decrypt(cookis);
                User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model;
                MenuServices       mns         = new MenuServices();
                if (mns.EditMenu(model, curUserInfo.User_Account))
                {
                    return(Json(new NBCMSResultJson {
                        Status = StatusType.OK,
                        Data = "Successfully edit menu"
                    }));
                }
                else
                {
                    return(Json(new NBCMSResultJson {
                        Status = StatusType.Error,
                        Data = "faile to edit menu"
                    }));
                }
            }
            catch (Exception ex) {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Example #20
0
        public HttpResponseMessage GetMenuState(int?userId)
        {
            MenuServices service = new MenuServices();

            try {
                var _result = service.GetMenuState(userId);

                return(Request.CreateResponse(HttpStatusCode.OK, _result));
            }
            catch (Exception ex) {
                ex.Data.Add("UserID", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/MenuInfo/GetMenuState");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "Expectation Failed during Menu State SaveArg"));
            }
        }
Example #21
0
        public HttpResponseMessage MenuStateSaveArg(int?userId, string key, string value)
        {
            MenuServices service = new MenuServices();

            try {
                service.MenuStateSaveArg(userId, key, value);

                return(Request.CreateResponse(HttpStatusCode.OK, "Menu State Save Are successed"));
            }
            catch (Exception ex) {
                ex.Data.Add("UserID", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/MenuInfo/MenuStateSaveArg");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "Expectation Failed during Menu State SaveArg"));
            }
        }
Example #22
0
        public HttpResponseMessage Init([FromBody] Models.UserMenuState.Init userPref)
        {
            MenuServices service = new MenuServices();

            try {
                service.MenuStateInit(userPref);

                return(Request.CreateResponse(HttpStatusCode.OK, "UserMenuState successfully inititialized."));
            }
            catch (Exception ex) {
                ex.Data.Add("UserID", userPref.UserID);
                ex.Data.Add("HTTPReferrer", "JCRAPI/MenuInfo/MenuStateInit");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message));
            }
        }
Example #23
0
        /// <summary>
        /// Get by url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static MenuModel GetByUrl(string url)
        {
            // check url
            if (string.IsNullOrEmpty(url))
            {
                return(null);
            }

            // init condition
            var condition = "[LinkUrl]='{0}'".FormatWith(url.TrimStart('/').EscapeQuote());

            // get by condition
            var entity = MenuServices.GetByCondition(condition);

            // return
            return(entity != null ? new MenuModel(entity) : null);
        }
        public void CleanMainMenuModelTests()
        {
            //Arrange
            var       menu = MenuServicesTests.GetUnitTestMenu();
            UserModel user = new UserModel
            {
                Email     = "*****@*****.**",
                SuperUser = true
            };

            //Act - remove all unit testing menu items from the menu
            var cleanMenu = new MenuServices().CleanMainMenuModel(menu, user);

            //Assert
            Assert.IsNotNull(cleanMenu);
            Assert.IsNotNull(cleanMenu.MenuItems);
            Assert.IsFalse(cleanMenu.MenuItems.Exists(m => m.DisplayText.ToLower().Contains("unit test")));
        }
Example #25
0
        //private string x = SESSION_NAME_USERID;

        public ActionResult Create()
        {
            if (null == Session[this.SESSION_NAME_USERID])
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (Session["IsAdmin"] is false)
            {
                return(RedirectToAction("Logout", "Home"));
            }
            this.SetCommonData();
            ViewData["pagename"]     = "menu_create";
            ViewData["action_block"] = "Menus/block_create_menu";
            ViewData["data-form"]    = TempData["data"];



            string menuId = (Request.QueryString["menuid"] == null ? "0" : Request.QueryString["menuid"].ToString());

            this.SetConnectionDB();
            MenuServices menuServices = new MenuServices(this.DBConnection);

            EntityMenuModel entityMenuModel = new EntityMenuModel();

            entityMenuModel = menuServices.GetMenuModel(menuId);
            Services.Departments.DepartmentServices departmentServices = new Services.Departments.DepartmentServices(this.DBConnection);
            ViewData["CurrentOrgId"]         = entityMenuModel.DeptID;
            ViewData["departments"]          = departmentServices.GetList();
            ViewData["listdepartmentsadmin"] = departmentServices.GetListAdminLogin((string)Session["CodeIsAdmin"]);
            this.GetLanguage();
            ViewData["VIEWDATA_LANGUAGE"] = this.LANGUAGE_OBJECT;


            BlockCreateMenuLangModel blockLang = new BlockCreateMenuLangModel();

            BI_Project.Models.UI.BlockModel blockModel = new Models.UI.BlockModel("block_create_menu", this.LANGUAGE_OBJECT, blockLang);
            blockModel.DataModel  = entityMenuModel;
            ViewData["BlockData"] = blockModel;
            if (menuServices.ERROR != null)
            {
                BI_Project.Helpers.FileHelper.SaveFile(menuServices.ERROR, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + BI_Project.Helpers.Utility.APIStringHelper.GenerateFileId() + ".txt");
            }
            return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"));
        }
Example #26
0
        //public void SetConnectionOracleDB()
        //{
        //    oracleConnection = new Services.ConnectOracleDB(CONNECT_STRING_STAGING);
        //}
        /// <summary>
        /// GET THE DATA USE FOR COMMON TARGET AS MENUS,....
        /// </summary>
        public void SetCommonData()
        {
            //this.SetConnectionDB();
            //BI_Project.Services.User.UserServices userServices = new UserServices(this.DBConnection);
            //ViewData["block_menu_left_data"] = userServices.GetListMenus((int)Session[this.SESSION_NAME_USERID],    (bool) Session["IsAdmin"]);

            this.SetConnectionDB();
            UserServices userServices = new UserServices(DBConnection);

            EntityUserModel currentUser = userServices.GetEntityById((int)Session[SESSION_NAME_USERID]);

            ViewData["block_menu_left_data"] = userServices.GetListMenus(currentUser);
            var          it           = ViewData["block_menu_left_data"];
            MenuServices menuServices = new MenuServices(DBConnection);

            var menuData = menuServices.GetMenusByDepId(currentUser.UserId, currentUser.DeptId);

            ViewData["MenuHeaderData"] = menuData;
        }
Example #27
0
        /// <summary>
        /// Load child menu
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        private string LoadChildMenu(int parentId)
        {
            var childMenus = MenuServices.GetAll(parentId, false, null, null, null, null);

            if (childMenus.Count == 0)
            {
                return(string.Empty);
            }

            var strChildMenu = string.Empty;

            foreach (var menu in childMenus)
            {
                strChildMenu +=
                    "<li id='{0}'><div class='menuItemName'>{1}</div><div class='menuItemPermission'>| {2}</div>{3}</li>"
                    .FormatWith(menu.Id, menu.MenuName, LoadMenuPermission(menu), LoadChildMenu(menu.Id));
            }

            return("<ul>{0}</ul>".FormatWith(strChildMenu));
        }
Example #28
0
    protected void btn_generatebill_Click(object sender, EventArgs e)
    {
        //int index = e.NewSelectedIndex;
        //string oid = GridView1.Rows[index].Cells[1].Text;
        //HiddenField1.Value = str;
        DataBase     db  = new DataBase();
        MenuServices obj = new MenuServices();

        Response.Write(txt_finalbillid.Text);

        // con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
        cmd             = new SqlCommand();
        cmd.CommandText = "SELECT itemName,quantity from bill where billID=@billID";
        //   cmd.Connection = con;
        cmd.Parameters.AddWithValue("@billID", txt_invisible.Text);
        SqlDataReader reader   = db.ExecuteReader(cmd);
        int           quantity = 0;
        string        name;
        int           sum = 0;

        while (reader.Read())
        {
            name     = reader[0].ToString();
            quantity = Convert.ToInt32(reader[1].ToString());
            foreach (var i in obj.itemMenu)
            {
                if (i.itemName == name)
                {
                    this.price = i.itemPrice;
                }
                sum += (quantity * Convert.ToInt32(price));
                break;
            }
            txt_finalbill.Text = sum.ToString();
        }
    }
Example #29
0
        public GameVM()
        {
            ObservableCollection <ObservableCollection <Cell> > board = Helper.InitBoard();

            bl        = new GameBusinessLogic(board);
            GameBoard = CellBoardToCellVMBoard(board);



            menuServices = new MenuServices();


            Player player = Helper.InitPlayer();

            CurrentPlayer = new PlayerVM(player);


            PlayerWhite = new PlayerVM(Helper.PlayerWhite);
            PlayerRed   = new PlayerVM(Helper.PlayerRed);



            Winner = new PlayerVM(Helper.Winner);
        }
        public ActionResult Index(int id)
        {
            //lay url tu menu voi id

            ViewData["pagename"]     = "Embed_Tableau";
            ViewData["action_block"] = "Tableau/TableauView";

            SetCommonData();
            GetLanguage();
            SetConnectionDB();


            BI_Project.Models.UI.PageModel pageModel = new Models.UI.PageModel("Embed_Tableau");
            // BI_Project.Models.UI.BlockModel blockModel = new BlockModel("TableauView");
            pageModel.SetLanguage(this.LANGUAGE_OBJECT);
            //pageModel.H1Title = pageModel.GetElementByPath("page_excel.menu" + id + ".h1");
            pageModel.Title        = pageModel.GetElementByPath("title");
            ViewData["page_model"] = pageModel;

            TableauModel param = new TableauModel();

            ViewData["BlockData"] = param;
            MenuServices _menuServices = new MenuServices(DBConnection);


            EntityMenuModel _entityMenuModel = _menuServices.GetMenuModel(id.ToString());

            UserServices _userServices = new UserServices(DBConnection);

            DepartmentServices _departmentServices = new DepartmentServices(DBConnection);

            EntityDepartmentModel _entityDepartmentModel = new EntityDepartmentModel();

            //param.Site_Root = _entityMenuModel.Site_Root;
            param.Ticket     = Helpers.TableauHelper.GetTicket("");
            param.TableauUrl = _entityMenuModel.TableauUrl;
            param.Hidden     = 1;
            param.username   = Session["UserName"].ToString();
            ViewBag.Id       = id;

            var listFilter01 = _departmentServices.GetList().Select(x => x.Filter01).ToArray();

            StringBuilder builderOrganization = new StringBuilder();

            foreach (var _list in listFilter01)
            {
                builderOrganization.Append(_list).Append(',');
            }


            string _resultListOrganization = builderOrganization.ToString().TrimEnd(',');

            ViewBag.ListDepartment = _resultListOrganization;



            var getUser       = _userServices.GetList();
            var getUserCheck  = getUser.FirstOrDefault(x => x.UserName == param.username);
            var getDepartment = _departmentServices.GetEntityById(getUserCheck.DeptId);


            if (getUserCheck.IsAdmin == false && (getDepartment.Filter01 != "PE" || getDepartment.Filter01 != "PA" || getDepartment.Filter01 != "PB" || getDepartment.Filter01 != "PC" || getDepartment.Filter01 != "PD"))
            {
                param.GetFilter(id);
            }
            //param.GetFilter(id);
            Random rd   = new Random();
            int    item = rd.Next(100, 999);
            string log  = DateTime.Now.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) + "_" + item;

            if (_menuServices.ERROR != null)
            {
                FileHelper.SaveFile(new { ERROR = _menuServices.ERROR }, this.LOG_FOLDER + "/ERROR_" + this.GetType().ToString() + APIStringHelper.GenerateFileId() + ".txt");
            }

            FileHelper.SaveFile(_entityMenuModel, this.LOG_FOLDER + "/MenuModel_" + log + ".txt");
            FileHelper.SaveFile(param.Ticket, this.LOG_FOLDER + "/Ticket_" + log + ".txt");
            return(View("~/" + this.THEME_FOLDER + "/" + this.THEME_ACTIVE + "/index.cshtml"));
        }