Esempio n. 1
0
        public User(string user)
        {
            _username = user;
            DataTable userTable = db.ReadTable("Users", String.Format("SELECT * FROM Users WHERE Username='******'", _username));

            if (userTable.Rows.Count > 0)
            {
                _id         = AppHandler.ToInt(userTable.Rows[0]["UserID"]);
                _name       = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Name"]);
                _phone      = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Phone"]);
                _email      = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Email"]);
                _username   = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Username"]);
                _password   = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Password"]);
                _usertype   = AppHandler.IgnoreDBNullString(userTable.Rows[0]["UserType"]);
                _status     = (short)AppHandler.ToInt(userTable.Rows[0]["Status"]);
                _logs       = AppHandler.ToInt(userTable.Rows[0]["Logs"]);
                _date_added = AppHandler.ToDateTime(userTable.Rows[0]["DateAdded"].ToString());
                _firm_id    = AppHandler.ToInt(userTable.Rows[0]["FirmID"]);
                _role_id    = AppHandler.ToInt(userTable.Rows[0]["RoleID"]);
                _exists     = true;

                //if (System.IO.File.Exists("~/Admin/Passports/" + _username + ".jpg"))
                //    _image_url = "~/Admin/Passports/" + _username + ".jpg";
                //else
                //    _image_url = "~/images/avater.png";
            }
        }
Esempio n. 2
0
        public User(string user, string pswd)
        {
            _username      = user;
            _password      = pswd;
            db.DBError     = "";
            ExecutionError = "";
            DataTable userTable = db.ReadTable("Users", String.Format("SELECT DISTINCT * FROM Users WHERE Username='******' AND Password='******'", _username, AppHandler.Sha1(_password)));

            if (userTable.Rows.Count > 0)
            {
                _id         = AppHandler.ToInt(userTable.Rows[0]["UserID"]);
                _name       = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Name"]);
                _phone      = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Phone"]);
                _email      = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Email"]);
                _username   = AppHandler.IgnoreDBNullString(userTable.Rows[0]["Username"]);
                _usertype   = AppHandler.IgnoreDBNullString(userTable.Rows[0]["UserType"]);
                _status     = (short)AppHandler.ToInt(userTable.Rows[0]["Status"]);
                _logs       = AppHandler.ToInt(userTable.Rows[0]["Logs"]);
                _date_added = AppHandler.ToDateTime(userTable.Rows[0]["DateAdded"].ToString());
                _firm_id    = AppHandler.ToInt(userTable.Rows[0]["FirmID"]);
                _role_id    = AppHandler.ToInt(userTable.Rows[0]["RoleID"]);
                _exists     = true;
            }
            else if (db.DBError.Length > 0)
            {
                ExecutionError = db.DBError;
            }
        }
Esempio n. 3
0
 public static string NextSession(string session)
 {
     string[] newSession = session.Split('/');
     newSession[0] = (AppHandler.ToInt(newSession[0]) + 1).ToString();
     newSession[1] = (AppHandler.ToInt(newSession[1]) + 1).ToString();
     return(newSession[0] + "/" + newSession[1]);
 }
Esempio n. 4
0
        public static DateTime GetRetirementDate(DateTime birthdate, DateTime firstAppDate)
        {
            int      yr    = birthdate.Year;
            int      age   = AppHandler.GetAge(birthdate);
            int      rYear = (60 - age) + DateTime.Now.Year;
            DateTime dt    = new DateTime(firstAppDate.Year + 35, firstAppDate.Month, firstAppDate.Day);

            if (dt.Year - birthdate.Year <= 60)
            {
                return(dt);
            }
            return(new DateTime(rYear, birthdate.Month, birthdate.Day));
        }
Esempio n. 5
0
        public static string ToMySqlTime(DateTime dt)
        {
            string ampm = dt.ToLongTimeString().Contains("PM") ? "PM" : "AM";

            string[] strTime = dt.ToLongTimeString().Split(' ')[0].Split(':');
            int      hr      = AppHandler.ToInt(strTime[0]);

            if (hr < 10 && ampm == "AM")
            {
                return("0" + Implode(strTime, ":"));
            }
            else if (hr < 10 && ampm == "PM")
            {
                return((12 + hr) + ":" + strTime[1] + ":" + strTime[2]);
            }
            else if (hr == 12 && ampm == "PM")
            {
                return("00:" + strTime[1] + ":" + strTime[2]);
            }
            return(Implode(strTime, ":"));
        }
Esempio n. 6
0
        //Methods
        public bool Add()
        {
            string strQuery = String.Format("INSERT INTO [Users]([Name],[Phone],[Email],[Username],[Password],[UserType],[Status],[Logs],[DateAdded]) " +
                                            "VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', 0, 0, '{6}')", _name, _phone, _email, _username, AppHandler.Sha1(_password), _usertype, _date_added);

            try
            {
                return(db.ExecuteQuery(strQuery));
            }
            catch (Exception ex)
            {
                ExecutionError = ex.Message;
            }
            return(false);
        }
Esempio n. 7
0
        public bool DoLogin()
        {
            bool loggedIn = false;

            try
            {
                DataTable userTable = db.ReadTable("Users", String.Format("SELECT Name FROM Users WHERE Username='******' AND Password='******'", _username, AppHandler.Sha1(_password)));
                loggedIn = userTable.Rows.Count > 0;
            }
            catch (Exception ex)
            {
                ExecutionError = ex.Message;
            }
            return(loggedIn);
        }
Esempio n. 8
0
 public bool ChangePassword(string pswd)
 {
     return(db.ExecuteQuery("UPDATE Users SET Password='******' WHERE Username='******'"));
 }