protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserInfo"] == null)
     {
         Response.Redirect("UserLogin.aspx");
     }
     else
     {
         //check here user role is student then redirect to useraccount
         //only tutor user can access this page
         DataTable dt = new DataTable();
         dt = (DataTable)Session["UserInfo"];
         String roleName = dt.Rows[0]["RoleName"].ToString();
         if (roleName.ToLower() == "student")
         {
             Response.Redirect("UserAccount.aspx");
         }
         else
         {
             int    userid     = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());
             String courseName = ClsUsers.getTutorCourseName(userid);
             txtCourse.Text = courseName;
         }
     }
     if (!IsPostBack)
     {
         fillstudents();
     }
 }
Пример #2
0
        public JsonResult Validate(string UserName, string Password)
        {
            string DeviceType = "";
            string DeviceName = "";
            string Browser    = "";
            int    userid     = 0;
            //Session["employeeID"] = EmployeeID;
            ClsUsers U = Administration.getUsers().Where(p => p.userName == UserName).ToList().FirstOrDefault();

            if (U != null)
            {
                if (U.resetPassword == true)
                {
                    Session["ResetUsername"] = U.userName;
                    Session["ResetID"]       = U.userID;
                    return(Json(new { id = U.userID, isSuccess = 0, msg = "PRYP" }));
                }
            }

            Login rs = new Login();

            Tuple <ClsReturnValues, string, List <ClsUserDisplay> > result = rs.authenticateUser(UserName, Password, DeviceType, DeviceName, Browser);

            if (result.Item1.IsSuccess == true)
            {
                Session["MenusMenuItemsRaw"] = result.Item3;
                Session["SessionID"]         = result.Item1.Response;
                Session["Token"]             = result.Item2;
                Session["Username"]          = UserName;
                Session["UserID"]            = result.Item1.ID;
                userid = (int)result.Item1.ID;
                ClsUsers u = Administration.getUsers().Where(f => f.userID == userid).FirstOrDefault();
            }
            return(Json(new { id = result.Item1.ID, isSuccess = result.Item1.IsSuccess, msg = result.Item1.Response }));
        }
Пример #3
0
    public static String CHANGE_PASSWORD(int xType, String xOldPassword, String xPassword, String xUser)
    {
        //MembershipUser currentUser = Membership.GetUser();
        //string user = currentUser.UserName.ToString();
        ClsUsers log = new ClsUsers();

        return(log.CHANGE_PASSWORD(xType, xUser, xOldPassword, xPassword));
    }
    public static int updateCourse(int courseid)
    {
        DataTable dt = new DataTable();

        dt = (DataTable)HttpContext.Current.Session["UserInfo"];
        int userid = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());

        return(ClsUsers.updateTutorCourse(userid, courseid));
    }
Пример #5
0
        public static ClsReturnValues setUsers(ClsUsers obj)
        {
            //password encryption happens here
            obj.password = Security.Encrypt(obj.password);

            ClsReturnValues lst = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspAddEditUsers(obj.userID, obj.userGroupID, obj.userName, obj.password, obj.password, obj.passwordCanExpire, obj.passwordExpiryDate, obj.isLocked, obj.loginAttempts, obj.lastLoginDate, obj.theme, obj.resetPassword, obj.createdByID, obj.sessionID).FirstOrDefault();
            }
            return(lst);
        }
Пример #6
0
        public static ClsReturnValues resetPassword(int userID, string newPassword)
        {
            newPassword = Security.Encrypt(newPassword);
            ClsUsers        U           = Administration.getUsers().Where(p => p.userID == userID).ToList().FirstOrDefault();
            string          oldPassword = U.password;
            ClsReturnValues lst         = new ClsReturnValues();

            using (var db = new tdoEntities())
            {
                lst = db.uspChangePassword(userID, oldPassword, newPassword).FirstOrDefault();
            }
            return(lst);
        }
    void fillTutos()
    {
        DataTable dt = new DataTable();

        dt = (DataTable)Session["UserInfo"];
        int CourseID = Convert.ToInt32(dt.Rows[0]["CourseID"].ToString());


        DataTable dtTtr = new DataTable();

        dtTtr = ClsUsers.GetTutors(CourseID);
        rptTutors.DataSource = dtTtr;
        rptTutors.DataBind();
    }
    void filldata()
    {
        DataTable dt = new DataTable();

        dt = (DataTable)Session["UserInfo"];
        int userId = Convert.ToInt32(dt.Rows[0]["UserID"].ToString());


        DataTable dtModule = new DataTable();

        dtModule = ClsUsers.GetUserModule(userId);
        rptModules.DataSource = dtModule;
        rptModules.DataBind();
    }
    void fillstudents()
    {
        DataTable dt = new DataTable();

        dt = (DataTable)Session["UserInfo"];
        int CourseID = Convert.ToInt32(dt.Rows[0]["CourseID"].ToString());


        DataTable dtTtr = new DataTable();

        dtTtr = ClsUsers.GetStudents(CourseID);
        lstStudents.DataSource     = dtTtr;
        lstStudents.DataTextField  = "StudentName";
        lstStudents.DataValueField = "UserID";
        lstStudents.DataBind();
    }
Пример #10
0
    public static int updatePWD(string oldpassword, string newpassword)
    {
        string    result = string.Empty;
        DataTable dt     = new DataTable();

        if (HttpContext.Current.Session["UserInfo"] != null)
        {
            dt = (DataTable)HttpContext.Current.Session["UserInfo"];

            ClsUsers ObjUser = new ClsUsers();
            ObjUser.UserPassword = clsEncryption.Encrypt(oldpassword);//currunt pwd
            ObjUser.UserID       = Convert.ToInt32(dt.Rows[0]["UserId"].ToString());
            return(ClsUsers.ChangePwd(ObjUser, clsEncryption.Encrypt(newpassword)));
        }
        else
        {
            return(0);
        }
    }
Пример #11
0
    public static string login(string username, string pwd)
    {
        String result = "";

        ClsUsers oBJ = new ClsUsers();

        oBJ.UserName     = username;
        oBJ.UserPassword = clsEncryption.Encrypt(pwd);

        DataTable dt = new DataTable();

        dt = ClsUsers.Login(oBJ);

        if (dt != null && dt.Rows.Count != 0)
        {
            HttpContext.Current.Session["UserInfo"] = dt;
            result = "success";
        }
        else
        {
            result = "fail";
        }
        return(result);
    }
Пример #12
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     // Put user code to initialize the page here
     if (!IsPostBack)
     {
         HttpCookieCollection cookieCols = new HttpCookieCollection();
         cookieCols = Request.Cookies;
         if (!(cookieCols["CMS"] == null))
         {
             if (cookieCols["CMS"].Value != "")
             {
                 short UserId = short.Parse(cookieCols["CMS"].Value.ToString());
                 objuser = new ClsUsers(UserId);//callingconstructor
                 //txtuserid.Text = objuser.UserCode;
                 chksignin.Checked = true;
             }
             else
             {
                 chksignin.Checked = false;
                 //txtuserid.Text = "";
             }
         }
     }
 }
Пример #13
0
        public Tuple <ClsReturnValues, string, List <ClsUserDisplay> > authenticateUser(string UserName, string Password, string DeviceType, string DeviceName, string Browser)
        {
            string encryptedPassword     = Security.Encrypt(Password);
            string token                 = "";
            List <ClsUserDisplay> ud     = new List <ClsUserDisplay>();
            ClsReturnValues       result = new ClsReturnValues();
            ClsUsers userGroup           = new ClsUsers();

            using (tdoEntities db = new tdoEntities())
            {
                result    = db.uspUserAuthentication(UserName, encryptedPassword, DeviceType, DeviceName, Browser).FirstOrDefault();
                userGroup = db.uspGetUsers().Where(p => p.userID == result.ID).FirstOrDefault();

                if (result.IsSuccess == true)
                {
                    ud = db.uspGetUserDisplay(result.ID).ToList <ClsUserDisplay>();
                    // Token issuer
                    TokenIssuer issuer = new TokenIssuer();
                    // A client of the relying party app gets the token
                    token = issuer.GetToken(result, ud.First().userGroupID);
                }
            }
            return(new Tuple <ClsReturnValues, string, List <ClsUserDisplay> >(result, token, ud));
        }
    public static int register(ClsUsers ObjUser)
    {
        int result = ClsUsers.InsertUpdate(ObjUser);

        return(result);
    }
 public static int deleteStudent(int userid)
 {
     return(ClsUsers.deleteStudent(userid));
 }