Example #1
0
        public string login(string username, string pass)
        {
            if (username == "")
            {
                MessageBox.Show("Please enter username");
                return("");
            }
            if (pass == "")
            {
                MessageBox.Show("Please enter password");
                return("");
            }

            string sql = String.Format(@"SELECT * FROM useraccounts  WHERE  Binary Username= '******' and Password = '******'", username, pass);
            //crud.ExecuteQuery(sql);
            MySqlDataReader reader = null;

            crud.RetrieveRecords(sql, ref reader);
            if (reader.Read())
            {
                MessageBox.Show("Login Success");
                role = reader.GetString(6);
                UserLog user = new UserLog(reader["Firstname"].ToString(),
                                           reader["Lastname"].ToString(),
                                           reader["MiddleName"].ToString(),
                                           role,
                                           username,
                                           reader["acc_id"].ToString(),
                                           int.Parse(reader["isPaswordChanged"].ToString()));
            }



            crud.CloseConnection();
            return(role);
        }
Example #2
0
        public void addAudit(string dateTime, string action)
        {
            string sql = String.Format(@"INSERT INTO audit_trail( Username, Date_Time, Action, User_type,User) VALUES ('{0}','{1}','{2}','{3}','{4}')",
                                       UserLog.getUserName(), dateTime, action, UserLog.getRole(), UserLog.getFullName());

            cs.ExecuteQuery(sql);
        }