private void fnLogin(string lUserEmail)
    {
        //Session.Clear();
        Session["refreshtoken"]   = gs_refreshtoekn;
        Session["accesstoken"]    = gs_accesstoken;
        Session["sRequestId"]     = null;
        Session["sEditRequestId"] = null;
        string strAbsoluteUri = Page.Request.Url.AbsoluteUri.ToString().Replace("loginokta.aspx", "login.aspx");

        strAbsoluteUri = ConfigurationManager.AppSettings["IDP_BaseURL"] + "/accounts/logout/";

        Session["sAbsoluteUrl"] = strAbsoluteUri;
        Session["strTheme"]     = "";
        string strTheme = "";

        if (Request.QueryString["comp"] != null)
        {
            strCompany = Request.QueryString["comp"];
            Session["sAgentCompany"] = strCompany;
            if (strCompany == "924065660726315")
            {
                Session["sDivCode"] = "01";
                strTheme            = "css/" + GetStyleName(strCompany);
            }
            else if (strCompany == "675558760549078")
            {
                Session["sDivCode"] = "02";
                strTheme            = "css/style-style3.css";
            }
            else
            {
                Session["sDivCode"] = "0";
                strTheme            = "css/" + GetStyleName(strCompany);
            }
        }
        else
        {
            strCompany = "924065660726315"; // Default company
            Session["sAgentCompany"] = strCompany;
            Session["sDivCode"]      = "01";
            strTheme = "css/" + GetStyleName(strCompany);
        }
        Session["strTheme"] = strTheme;


        if (Session["sobjResParam"] == null)
        {
            ReservationParameters objResParam = new ReservationParameters();
            objResParam.AbsoluteUrl  = strAbsoluteUri;
            objResParam.AgentCompany = strCompany;
            objResParam.DivCode      = (string)Session["sDivCode"];
            objResParam.CssTheme     = strTheme;
            Session["sobjResParam"]  = objResParam;
        }
        else
        {
            ReservationParameters objResParam = new ReservationParameters();
            objResParam              = (ReservationParameters)Session["sobjResParam"];
            objResParam.AbsoluteUrl  = strAbsoluteUri;
            objResParam.AgentCompany = strCompany;
            objResParam.DivCode      = (string)Session["sDivCode"];
            objResParam.CssTheme     = strTheme;
            Session["sobjResParam"]  = objResParam;
        }

        //LoadLoginPageFields();
        string lUserName;

        lUserName = objclsUtilities.ExecuteQueryReturnStringValue("select top 1 webusername from agentmast (nolock) where isnull(webapprove,0)=1 and webemail='" + lUserEmail + "'");
        string lShortName;

        lShortName = objclsUtilities.ExecuteQueryReturnStringValue("select top 1 ShortName from agentmast (nolock) where isnull(webapprove,0)=1 and webemail='" + lUserEmail + "'");
        if (lUserName == null)
        {
            Response.Write("The account is not authorized to login");
            return;
        }
        if (lUserName.Trim() == "")
        {
            Response.Write("The account is not authorized to login");
            return;
        }
        //string lPassword;
        //lPassword = objclsUtilities.ExecuteQueryReturnStringValue("select dbo.pwddecript(userpwd) from usermaster where usercode='" + lUserName + "'");
        //if (1==2) { //(lPassword == null) {
        //    Response.Write("The username is incorrect.");
        //}
        //else
        //{
        BLLLogin objBLLLogin = new BLLLogin();

        objBLLLogin.UserName  = lUserName;
        objBLLLogin.ShortName = lShortName;
        String LoginIp = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

        objBLLLogin.LoginType = "MAIN";
        objBLLLogin.IpAddress = LoginIp;
        objBLLLogin.DivCode   = (String)Session["sDivCode"];
        DataTable dtValidate;

        dtValidate = objBLLLogin.ValidateUserWithoutPassword();


        if (dtValidate.Rows.Count > 0)
        {
            Session.Add("GlobalUserName", lUserName);
            //Session.Add("Userpwd", txtPassword.Text.Trim);
            Session.Add("changeyear", DateTime.Now.Year.ToString());
            Session.Add("sLoginType", "Agent");

            Session.Add("sAgentCode", dtValidate.Rows[0]["agentcode"].ToString());
            Session.Add("sCurrencyCode", dtValidate.Rows[0]["currcode"].ToString());
            Session.Add("sCountryCode", dtValidate.Rows[0]["ctrycode"].ToString());
            Session["sLang"] = "en-us";

            GetReservationParamValues();


            ReservationParameters objResParam = new ReservationParameters();
            if (Session["sobjResParam"] != null)
            {
                objResParam = (ReservationParameters)Session["sobjResParam"];
            }
            objResParam.LoginIp = LoginIp;
            String strIpLocation = ""; // GeionName = strIpLocation;
            objResParam.AgentCode           = dtValidate.Rows[0]["agentcode"].ToString();
            objResParam.LoginIpLocationName = strIpLocation;
            objResParam.LoginType           = "Agent";


            BLLHotelSearch objBLLHotelSearch = new BLLHotelSearch();
            objResParam.Cumulative = objBLLHotelSearch.FindBookingEnginRateType(dtValidate.Rows[0]["agentcode"].ToString()).ToString();
            objResParam.WhiteLabel = objBLLHotelSearch.FindWhiteLabel(dtValidate.Rows[0]["agentcode"].ToString()).ToString();
            if (dtValidate.Rows[0]["logintype"].ToString() == "subuser")
            {
                objResParam.SubUserCode = dtValidate.Rows[0]["agentsubcode"].ToString();
                objResParam.IsSubUser   = "******";
            }
            else
            {
                objResParam.SubUserCode = "";
                objResParam.IsSubUser   = "******";
            }

            Session["sobjResParam"] = objResParam;
            FormsAuthentication.SetAuthCookie(lUserName, false);
            Session["IDPLOginType"] = "Agent";
            Response.Redirect("Home.aspx", false);
        }
        else
        {
            Response.Write("The account is not authorized to login");
        }
        //}
    }
    private void fnROLogin(string lUserEmail)
    {
        Session.Clear();
        Session["sRequestId"]     = null;
        Session["sEditRequestId"] = null;
        //CheckUnderConstruction();
        string strAbsoluteUri = Page.Request.Url.AbsoluteUri.ToString().Replace("loginokta.aspx", "login.aspx") + "?ro=1";

        strAbsoluteUri = ConfigurationManager.AppSettings["idp_sso_target_logouturl"];

        Session["sAbsoluteUrl"] = strAbsoluteUri;
        Session["strTheme"]     = "";
        string strTheme = "";

        if (Request.QueryString["comp"] != null)
        {
            strCompany = Request.QueryString["comp"];
            Session["sAgentCompany"] = strCompany;
            if (strCompany == "924065660726315")
            {
                Session["sDivCode"] = "01";
                strTheme            = "css/" + GetStyleName(strCompany);
            }
            else if (strCompany == "675558760549078")
            {
                Session["sDivCode"] = "02";
                strTheme            = "css/style-style3.css";
            }
            else
            {
                Session["sDivCode"] = "0";
                strTheme            = "css/" + GetStyleName(strCompany);
            }
        }
        else
        {
            strCompany = "924065660726315"; // Default company
            Session["sAgentCompany"] = strCompany;
            Session["sDivCode"]      = "01";
            strTheme = "css/" + GetStyleName(strCompany);
        }
        Session["strTheme"] = strTheme;


        if (Session["sobjResParam"] == null)
        {
            ReservationParameters objResParam = new ReservationParameters();
            objResParam.AbsoluteUrl  = strAbsoluteUri;
            objResParam.AgentCompany = strCompany;
            objResParam.DivCode      = (string)Session["sDivCode"];
            objResParam.CssTheme     = strTheme;
            Session["sobjResParam"]  = objResParam;
        }
        else
        {
            ReservationParameters objResParam = new ReservationParameters();
            objResParam              = (ReservationParameters)Session["sobjResParam"];
            objResParam.AbsoluteUrl  = strAbsoluteUri;
            objResParam.AgentCompany = strCompany;
            objResParam.DivCode      = (string)Session["sDivCode"];
            objResParam.CssTheme     = strTheme;
            Session["sobjResParam"]  = objResParam;
        }

        //LoadLoginPageFields();
        string lUserName;

        lUserName = objclsUtilities.ExecuteQueryReturnStringValue("select top 1 UserCode from usermaster where usemail='" + lUserEmail + "'");
        if (lUserName == null)
        {
            Response.Write("The account is not authorized to login");
            return;
        }
        if (lUserName.Trim() == "")
        {
            Response.Write("The account is not authorized to login");
            return;
        }
        //string lPassword;
        //lPassword = objclsUtilities.ExecuteQueryReturnStringValue("select dbo.pwddecript(userpwd) from usermaster where usercode='" + lUserName + "'");
        //if (1==2) { //(lPassword == null) {
        //    Response.Write("The username is incorrect.");
        //}
        //else
        //{
        if (objBLLLogin.ValidateROUser(lUserName.Trim()) == true)
        {
            Session.Add("sLoginType", "RO");
            ReservationParameters objResParam = new ReservationParameters();
            if (Session["sobjResParam"] != null)
            {
                objResParam = (ReservationParameters)Session["sobjResParam"];
            }
            objResParam.LoginType = "RO";
            Session["sLang"]      = "en-us";
            DataTable objDataTable;
            objDataTable = objBLLLogin.LoadLoginPageSessionFields((string)Session["sAgentCompany"]);
            if (objDataTable.Rows.Count > 0)
            {
                Session.Add("sAgentCode", objDataTable.Rows[0]["agentcode"].ToString());
                Session.Add("sCurrencyCode", objDataTable.Rows[0]["currcode"].ToString());
                Session.Add("sCountryCode", objDataTable.Rows[0]["ctrycode"].ToString());
                Session.Add("GlobalUserName", lUserName.Trim());
                objResParam.AgentCode      = objDataTable.Rows[0]["agentcode"].ToString();
                objResParam.GlobalUserName = lUserName.Trim();
            }
            else
            {
            }

            GetReservationParamValues();

            string LoginIp = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            objResParam.LoginIp = LoginIp;
            string strIpLocation = "";
            objResParam.LoginIpLocationName = strIpLocation;
            string         strAgentCode      = (string)Session["sAgentCode"].ToString();
            BLLHotelSearch objBLLHotelSearch = new BLLHotelSearch();
            objResParam.Cumulative  = objBLLHotelSearch.FindBookingEnginRateType(strAgentCode).ToString();
            objResParam.WhiteLabel  = objBLLHotelSearch.FindWhiteLabel(strAgentCode).ToString();
            Session["sobjResParam"] = objResParam;

            // objclsUtilities.WriteErrorLog("Redirect Before " & Date.Now)

            Response.Redirect("Home.aspx", false);
        }
        else
        {
            Response.Write("The account is not authorized to login");
        }
        //}
    }