private void CheckList(string role)
    {
        List <t_RoleFunction> listRoleFunction = roleFunctionBL.FindAll(x => x.Role == role).ToList();
        List <t_Function>     listFunction     = functionBL.FindAll(x => x.Language == "vi").ToList();

        if (listFunction.Count == listRoleFunction.Count)
        {
            return;
        }
        foreach (var item in listFunction)
        {
            var isExit = listRoleFunction.FirstOrDefault(x => x.FunctionId == item.FunctionId);
            if (isExit == null)
            {
                roleFunctionBL.AddRole(new t_RoleFunction
                {
                    Active     = false,
                    FunctionId = item.FunctionId,
                    Role       = role
                });
            }
        }
    }
Example #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Pi-solution
        language = (Session["myapplication.language"] == null) ? "vi" : Session["myapplication.language"].ToString();
        List <t_LanguageTranslate> list = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Language/ChangeFunction.aspx")).ToList();


        // Load language contents - vietnamse
        List <t_Function> functionList_vi    = functionBL.FindAll(x => x.Language == "vi").ToList();
        List <t_Function> functionList_en    = functionBL.FindAll(x => x.Language == "en").ToList();
        List <t_Function> functionList_other = functionBL.FindAll(x => x.Language == "other").ToList();

        List <t_Function_DTO> listDTO = new List <t_Function_DTO>();

        listDTO.Add(new t_Function_DTO {
            Id_display         = "Icon",
            FunctionName_vi    = "",
            FunctionName_en    = "",
            FunctionName_other = "",
        });
        int index = 0;

        foreach (var item in functionList_vi)
        {
            listDTO.Add(new t_Function_DTO {
                Id_display         = index.ToString("0000"),
                FunctionId_vi      = functionList_vi[index].FunctionId,
                FunctionId_en      = functionList_en[index].FunctionId,
                FunctionId_other   = functionList_other[index].FunctionId,
                FunctionName_vi    = functionList_vi[index].FunctionName,
                FunctionName_en    = functionList_en[index].FunctionName,
                FunctionName_other = functionList_other[index].FunctionName,
            });
            index++;
        }

        if (!IsPostBack)
        {
            DataTable dt = new DataTable();
            GridView1.DataSource = ToDataTable(listDTO);
            GridView1.DataBind();

            // Language
            var var1 = list.Where(x => x.ControlId.Contains("btnEdit")).FirstOrDefault();
            btnEdit.Text = (var1 == null) ? "" : var1.Contents;
            var var2 = list.Where(x => x.ControlId.Contains("btnUpdate")).FirstOrDefault();
            btnUpdate.Text = (var2 == null) ? "" : var2.Contents;
        }

        // Set flag
        index = 0;
        foreach (GridViewRow gvr in GridView1.Rows)
        {
            if (index == 0)
            {
                Image type_vi = ((Image)gvr.FindControl("Image1"));
                type_vi.ImageUrl            = "/_imgs/Language/Flag_of_Vietnam.PNG";
                type_vi.Attributes["style"] = "width:30px; height:20px";
                Image type_en = ((Image)gvr.FindControl("Image2"));
                type_en.ImageUrl            = "/_imgs/Language/Flag_of_England.PNG";
                type_en.Attributes["style"] = "width:30px; height:20px";
            }
            break;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            title.Text = sysParamBL.FindSingle(x => x.Name == "title").Val;
        }

        string IP = GetLanIPAddress();

        if (string.IsNullOrEmpty(IP) || IP.Contains('%'))
        {
            IP = GetVisitorIpAddress();
        }
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            t_Users user     = new t_Users();
            string  username = HttpContext.Current.User.Identity.Name;
            // Update name - Pi-solution developer
            lbUserName.Text = username;
            t_Users dbUser = _userBL.GetUser(username);
            user        = dbUser;
            user.Active = true;
            string hostName = Dns.GetHostName();
            user.Ip        = Dns.GetHostAddresses(hostName).GetValue(0).ToString();
            user.Ip        = IP;
            user.TimeStamp = DateTime.Now;
            _userBL.UpdateUser(user, dbUser);
            string role = user.Role;
            //RoleFunciton
            t_RoleFunction _functions = new t_RoleFunction();
            List <int>     dbfunction = (from a in _roleFunctionBL.FindAll(s => s.Role == role && s.Active == true).ToList() select a.FunctionId).ToList();
            //URL by Role
            List <string> fun = (from q in languageobj.FindAll(s => dbfunction.Contains(s.FunctionId) && s.Language == "vi").ToList() select q.URL).ToList();
            hidListMenu.Value = "@";
            foreach (var _f in fun)
            {
                hidListMenu.Value = hidListMenu.Value + _f + "@";
            }
        }
        else
        {
            Response.Redirect("~/Login.aspx");
        }

        // Update logo
        var sysParamList = sysParamBL.FindAll().ToList();
        var var0         = sysParamList.Where(x => x.ID == 2).FirstOrDefault();

        imgLogo.Src = (var0 == null) ? "" : var0.Val;
        // Update Company name
        var var01 = sysParamList.Where(x => x.Name == "company_name").FirstOrDefault();

        lbCompany.Text = (var01 == null) ? "" : var01.Val;


        // Programming language - Pi solution
        if (Session["myapplication.language"] != null)
        {
            language = (Session["myapplication.language"]).ToString();
            if (!IsPostBack)
            {
                // Set drop down current language
                DropDownList_Language.ClearSelection();
                DropDownList_Language.Items.FindByValue(Session["myapplication.language"].ToString()).Selected = true;
            }

            // Load Language from SQL database
            var functionList = languageobj.FindAll(x => x.Language == language).ToList();

            // Update home page + language
            List <t_LanguageTranslate> contentList = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("title_homepage")).ToList();
            var var001 = contentList.Where(x => x.ControlId.Contains("title_homepage")).FirstOrDefault();;
            lbPageTitle.Text = (var001 == null) ? "" : var001.Contents;

            Page.Title = lbPageTitle.Text;

            var var1 = functionList.Where(x => x.URL.Contains("MapJS_rev1.aspx")).FirstOrDefault();
            lbGeneralMap.Text = (var1 == null) ? "" : var1.FunctionName;
            var var2 = functionList.Where(x => x.URL.Contains("MapJS_rev1_DMA.aspx")).FirstOrDefault();
            lbDMAMap.Text = (var2 == null) ? "" : var2.FunctionName;
            var var3 = functionList.Where(x => x.ParentId == 3).FirstOrDefault();
            lbData.Text = (var3 == null) ? "" : var3.FunctionName;

            t_Function var4 = functionList.Where(x => x.URL.Contains("Complex_TA.aspx")).FirstOrDefault();
            lbDataTable.Text = (var4 == null) ? "" : var4.FunctionName;
            var var5 = functionList.Where(x => x.URL.Contains("Daily_Monthly.aspx")).FirstOrDefault();
            lbLoggerData.Text = (var5 == null) ? "" : var5.FunctionName;
            var var6 = functionList.Where(x => x.URL.Contains("Add_Change.aspx")).FirstOrDefault();
            lbManualData.Text = (var6 == null) ? "" : var6.FunctionName;
            var var7 = functionList.Where(x => x.URL.Contains("MinMaxVal.aspx")).FirstOrDefault();
            lbMinMaxValues.Text = (var7 == null) ? "" : var7.FunctionName;
            var var8 = functionList.Where(x => x.ParentId == 4).FirstOrDefault();
            lbReport.Text = (var8 == null) ? "" : var8.FunctionName;
            var var9 = functionList.Where(x => x.URL.Contains("Press.aspx")).FirstOrDefault();
            lbPressure.Text = (var9 == null) ? "" : var9.FunctionName;
            var var10 = functionList.Where(x => x.URL.Contains("Montly.aspx")).FirstOrDefault();
            lbVolume.Text = (var10 == null) ? "" : var10.FunctionName;
            var var11 = functionList.Where(x => x.ParentId == 5).FirstOrDefault();
            blEAndsL.Text = (var11 == null) ? "" : var11.FunctionName;
            var var12 = functionList.Where(x => x.URL.Contains("All.aspx")).FirstOrDefault();
            lbEquipments.Text = (var12 == null) ? "" : var12.FunctionName;
            var var13 = functionList.Where(x => x.URL.Contains("Config.aspx")).FirstOrDefault();
            lbInstallationPoints.Text = (var1 == null) ? "" : var13.FunctionName;
            var var14 = functionList.Where(x => x.ParentId == 6).FirstOrDefault();
            lbAdminPanel.Text = (var14 == null) ? "" : var14.FunctionName;
            var var15 = functionList.Where(x => x.URL.Contains("ViewUsers.aspx")).FirstOrDefault();
            lbViewUserDetails.Text = (var15 == null) ? "" : var15.FunctionName;
            var var16 = functionList.Where(x => x.URL.Contains("CreateUser.aspx")).FirstOrDefault();
            lbCreateUsers.Text = (var16 == null) ? "" : var16.FunctionName;
            var var17 = functionList.Where(x => x.URL.Contains("SettingSMS.aspx")).FirstOrDefault();
            lbMessageSettings.Text = (var17 == null) ? "" : var17.FunctionName;
            var var18 = functionList.Where(x => x.URL.Contains("ChangePassword.aspx")).FirstOrDefault();
            lbChangePassword.Text = (var18 == null) ? "" : var18.FunctionName;
            var var19 = functionList.Where(x => x.ParentId == 8).FirstOrDefault();
            lbLanguageManagement.Text = (var19 == null) ? "" : var19.FunctionName;
            var var20 = functionList.Where(x => x.URL.Contains("ChangeFunction.aspx")).FirstOrDefault();
            lbFunctions.Text = (var20 == null) ? "" : var20.FunctionName;
            var var21 = functionList.Where(x => x.URL.Contains("ChangeContent.aspx")).FirstOrDefault();
            lbContents.Text = (var21 == null) ? "" : var21.FunctionName;

            var var22 = functionList.Where(x => x.ParentId == 9).FirstOrDefault();
            lbConfigSystem.Text = (var22 == null) ? "" : var22.FunctionName;
            var var23 = functionList.Where(x => x.URL.Contains("System/General.aspx")).FirstOrDefault();
            lbGeneralSystem.Text = (var23 == null) ? "" : var23.FunctionName;
            var var24 = functionList.Where(x => x.URL.Contains("System/Users.aspx")).FirstOrDefault();
            lbUserManagement.Text = (var24 == null) ? "" : var24.FunctionName;
            var var25 = functionList.Where(x => x.URL.Contains("System/Roles.aspx")).FirstOrDefault();
            lbRoleManagement.Text = (var25 == null) ? "" : var25.FunctionName;
            var var26 = functionList.Where(x => x.URL.Contains("System/RoleFunction.aspx")).FirstOrDefault();
            lbRoleFunctionManagement.Text = (var26 == null) ? "" : var26.FunctionName;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
        }

        string IP = GetLanIPAddress();

        if (string.IsNullOrEmpty(IP) || IP.Contains('%'))
        {
            IP = GetVisitorIpAddress();
        }
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            t_Users user     = new t_Users();
            string  username = HttpContext.Current.User.Identity.Name;
            // Update name - Pi-solution developer
            // lbUserName.Text = username;
            t_Users dbUser = _userBL.GetUser(username);
            user        = dbUser;
            user.Active = true;
            string hostName = Dns.GetHostName();
            user.Ip        = Dns.GetHostAddresses(hostName).GetValue(0).ToString();
            user.Ip        = IP;
            user.TimeStamp = DateTime.Now;
            _userBL.UpdateUser(user, dbUser);
            string role = user.Role;
            //RoleFunciton
            t_RoleFunction _functions = new t_RoleFunction();
            List <int>     dbfunction = (from a in _roleFunctionBL.FindAll(s => s.Role == role && s.Active == true).ToList() select a.FunctionId).ToList();
            //URL by Role
            List <string> fun = (from q in languageobj.FindAll(s => dbfunction.Contains(s.FunctionId)).ToList() select q.URL).ToList();
            //hidListMenu.Value = "@";
            //foreach (var _f in fun)
            //{
            //    hidListMenu.Value = hidListMenu.Value + _f + "@";
            //}
        }
        else
        {
            Response.Redirect("~/Login.aspx");
        }

        // Update logo
        var sysParamList = sysParamBL.FindAll().ToList();
        var var0         = sysParamList.Where(x => x.ID == 2).FirstOrDefault();
        //  imgLogo.Src = (var0 == null) ? "" : var0.Val;
        // Update Company name
        var var01 = sysParamList.Where(x => x.Name == "company_name").FirstOrDefault();
        //   lbCompany.Text = (var01 == null) ? "" : var01.Val;
        // Update home page
        var var001 = sysParamList.Where(x => x.Name == "home_page").FirstOrDefault();

        //  lbPageTitle.Text = (var001 == null) ? "" : var001.Val;

        // Programming language - Pi solution
        if (Session["myapplication.language"] != null)
        {
            language = (Session["myapplication.language"]).ToString();
            if (!IsPostBack)
            {
                // Set drop down current language
                //DropDownList_Language.ClearSelection();
                //DropDownList_Language.Items.FindByValue(Session["myapplication.language"].ToString()).Selected = true;
            }

            //// Load Language from SQL database
            //var functionList = languageobj.FindAll(x => x.Language == language).ToList();

            //var var1 = functionList.Where(x => x.URL.Contains("MapJS_rev1.aspx")).FirstOrDefault();
            //lbGeneralMap.Text = (var1 == null) ? "" : var1.FunctionName;
            //var var2 = functionList.Where(x => x.URL.Contains("MapJS_rev1_DMA.aspx")).FirstOrDefault();


            //t_Function var4 = functionList.Where(x => x.URL.Contains("Complex_TA.aspx")).FirstOrDefault();
            //lbDataTable.Text = (var4 == null) ? "" : var4.FunctionName;
            //var var5 = functionList.Where(x => x.URL.Contains("Daily_Monthly.aspx")).FirstOrDefault();
            //lbLoggerData.Text = (var5 == null) ? "" : var5.FunctionName;
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            title.Text = sysParamBL.FindSingle(x => x.Name == "title").Val;
        }

        string IP = GetLanIPAddress();

        if (string.IsNullOrEmpty(IP) || IP.Contains('%'))
        {
            IP = GetVisitorIpAddress();
        }
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            t_Users user     = new t_Users();
            string  username = HttpContext.Current.User.Identity.Name;
            // Update name - Pi-solution developer
            lbUserName.Text = username;
            t_Users dbUser = _userBL.GetUser(username);
            user        = dbUser;
            user.Active = true;
            string hostName = Dns.GetHostName();
            user.Ip        = Dns.GetHostAddresses(hostName).GetValue(0).ToString();
            user.Ip        = IP;
            user.TimeStamp = DateTime.Now;
            _userBL.UpdateUser(user, dbUser);
            string role = user.Role;
            //RoleFunciton
            t_RoleFunction _functions = new t_RoleFunction();
            List <int>     dbfunction = (from a in _roleFunctionBL.FindAll(s => s.Role == role && s.Active == true).ToList() select a.FunctionId).ToList();
            //URL by Role
            List <string> fun = (from q in languageobj.FindAll(s => dbfunction.Contains(s.FunctionId) && s.Language == "vi").ToList() select q.URL).ToList();
            hidListMenu.Value = "@";
            foreach (var _f in fun)
            {
                hidListMenu.Value = hidListMenu.Value + _f + "@";
            }
        }
        else
        {
            Response.Redirect("~/Login.aspx");
        }

        // Update logo
        var sysParamList = sysParamBL.FindAll().ToList();
        var var0         = sysParamList.Where(x => x.ID == 2).FirstOrDefault();

        imgLogo.Src = (var0 == null) ? "" : var0.Val;
        // Update Company name
        var var01 = sysParamList.Where(x => x.Name == "company_name").FirstOrDefault();

        lbCompany.Text = (var01 == null) ? "" : var01.Val;


        // Programming language - Pi solution
        if (Session["myapplication.language"] != null)
        {
            language = (Session["myapplication.language"]).ToString();
            if (!IsPostBack)
            {
                // Set drop down current language
                DropDownList_Language.ClearSelection();
                DropDownList_Language.Items.FindByValue(Session["myapplication.language"].ToString()).Selected = true;
            }

            // Load Language from SQL database
            var functionList = languageobj.FindAll(x => x.Language == language).ToList();

            // Update home page + language
            List <t_LanguageTranslate> contentList = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("title_homepage")).ToList();
            var var001 = contentList.Where(x => x.ControlId.Contains("title_homepage")).FirstOrDefault();;
            lbPageTitle.Text = (var001 == null) ? "" : var001.Contents;

            Page.Title = lbPageTitle.Text;
        }
    }