private bool SetUserLogin(string sUserID, string sRoleID)
    {
        int nUserID = SystemFunction.ParseInt(sUserID);
        int nRoleID = SystemFunction.ParseInt(sRoleID);

        var dataUser = db.mTUser.FirstOrDefault(w => w.ID == nUserID);
        var dataRole = db.mTUserRole.FirstOrDefault(w => w.ID == nRoleID);

        var lst_RoleAdmin = db.TMenu_Permission.Where(w => w.nUserID == nUserID && w.nRoleID == nRoleID).ToList();          // Role_Admin
        var lst_RoleOther = db.mTUser_FacilityPermission.Where(w => w.nUserID == nUserID && w.nRoleID == nRoleID).ToList(); // Role_Other
        var lstDataRole   = db.mTUserRole.ToList();                                                                         // Query Role_Name

        if (dataUser != null && dataRole != null)
        {
            string  sNameRole = lstDataRole.Any() ? lstDataRole.First(w => w.ID == nRoleID).Name : "";
            UserAcc us        = new UserAcc();
            us.nUserID         = dataUser.ID;
            us.sFullName       = dataUser.Firstname + " " + dataUser.Lastname;
            us.nRoleID         = lst_RoleAdmin.Any() ? lst_RoleAdmin.First().nRoleID : lst_RoleOther.Any() ? lst_RoleOther.First().nRoleID : 0;
            us.sActionRoleName = sNameRole;
            UserAcc.SetObjUser(us);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 2
0
    public static CResultLogin Login(string sUserName, string sPassword, string sMode)
    {
        CResultLogin result = new CResultLogin();
        UserAcc      ua     = new UserAcc();

        if (!string.IsNullOrEmpty(sUserName))
        {
            PTTGC_EPIEntities db = new PTTGC_EPIEntities();
            sUserName = sUserName.Trims();
            sPassword = sPassword.Trims();
            int nUserIDSuperAdmin = SystemFunction.ParseInt(ConfigurationManager.AppSettings["UserIDAdmin"].ToString());
            var query             = db.mTUser.FirstOrDefault(w => w.Username == sUserName && w.cDel == "N" && w.cActive == "Y");
            if (query != null && query.ID == nUserIDSuperAdmin)
            {
                if (sPassword == ConfigurationManager.AppSettings["SupperAdminPWD"].ToString())
                {
                    ua.nUserID         = query.ID;
                    ua.sFullName       = query.Firstname + " " + query.Lastname;
                    ua.nRoleID         = 1;
                    ua.sActionRoleName = "System Admin";
                    UserAcc.SetObjUser(ua);
                    result.Status = SystemFunction.process_Success;
                }
                else
                {
                    result.Status = SystemFunction.process_Failed;
                    result.Msg    = "Incorrect password !";
                }
            }
            else
            {
                var resultLogin = UserAcc.Login(sUserName, sPassword, sMode);
                result.Msg       = resultLogin.Msg;
                result.nUserID   = resultLogin.nUserID;
                result.Status    = resultLogin.Status;
                result.TDataRole = resultLogin.TDataRole;
            }
        }
        return(result);
    }
Exemplo n.º 3
0
 public static int toIntNullToZero(this string instance)
 {
     return(SystemFunction.ParseInt(instance));
 }
    private void SetFocus(string sIndicatorID, string sProductID)
    {
        int nIndID     = SystemFunction.ParseInt(sIndicatorID);
        int nProductID = SystemFunction.ParseInt(sProductID);

        switch (nIndID)
        {
        case 1:
            SetBodyEventOnLoad("formfocus('divEC')");
            break;

        case 2:
            SetBodyEventOnLoad("formfocus('divERC')");
            break;

        case 3:
            SetBodyEventOnLoad("formfocus('C24')");
            break;

        case 4:
            SetBodyEventOnLoad("formfocus('E" + nProductID + "')");
            break;

        case 5:
            SetBodyEventOnLoad("formfocus('C24')");
            break;

        case 6:    //Intensity Denominator
            SetBodyEventOnLoad("formfocus('dvIntensity')");
            break;

        case 7:
            SetBodyEventOnLoad("formfocus('C24')");
            break;

        case 8:    //Material
            switch (nProductID)
            {
            case 33: SetBodyEventOnLoad("formfocus('dvMaterial')"); break;

            case 34: SetBodyEventOnLoad("formfocus('dvMaterial')"); break;

            case 37: SetBodyEventOnLoad("formfocus('dvMaterial')"); break;

            case 41: SetBodyEventOnLoad("formfocus('TBM2')"); break;
            }
            break;

        case 9:    // SPILL
            switch (nProductID)
            {
            case 90: SetBodyEventOnLoad("formfocus('ST1')"); break;

            case 91: SetBodyEventOnLoad("formfocus('ST2')"); break;

            default: SetBodyEventOnLoad("formfocus('divSpill')"); break;
            }
            break;

        case 10:     //Waste
            switch (nProductID)
            {
            case 1: SetBodyEventOnLoad("formfocus('dvWaste')"); break;

            case 16: SetBodyEventOnLoad("formfocus('TBW2')"); break;

            case 104: SetBodyEventOnLoad("formfocus('TBW3')"); break;
            }
            break;

        case 11:    //Water
            switch (nProductID)
            {
            case 91:
                SetBodyEventOnLoad("formfocus('divWaterWithdrawal')");
                break;

            case 101:
                SetBodyEventOnLoad("formfocus('divWaterReuse')");
                break;
            }
            break;
        }
    }