Ejemplo n.º 1
0
        public static Cuser Getuser(string path, Cuser usr)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "SELECT  `PASSWORD`, `ENTERTIME`,`EXITTIME` FROM `bsuser` WHERE `USER`=@USER";
                sqlcmd.Parameters.AddWithValue("USER", usr.USER);
                MySqlDataReader sdr = sqlcmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                if (sdr.Read())
                {
                    usr.PASSWORD  = sdr.GetString(0);
                    usr.ENTERTIME = sdr.GetString(1);
                    usr.EXITTIME  = sdr.GetString(2);
                    return(usr);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static bool Delete(string path, Cuser usr)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "DELETE FROM `bsuser` WHERE `USER`=@USER";
                sqlcmd.Parameters.AddWithValue("USER", usr.USER);

                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static bool Update(string path, Cuser usr)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "UPDATE bsuser SET PASSWORD=@PASSWORD,EXITTIME=@EXITTIME where USER=@USER;";
                sqlcmd.Parameters.Add(new MySqlParameter("USER", usr.USER));
                sqlcmd.Parameters.Add(new MySqlParameter("PASSWORD", usr.PASSWORD));
                sqlcmd.Parameters.Add(new MySqlParameter("EXITTIME", usr.EXITTIME));
                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static bool Insert(string path, Cuser usr)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "INSERT INTO bsuser(ID, USER, PASSWORD, ENTERTIME, EXITTIME) VALUES(uuid(),@USER, @PASSWORD, @ENTERTIME, @EXITTIME);";
                sqlcmd.Parameters.Add(new MySqlParameter("USER", usr.USER));
                sqlcmd.Parameters.Add(new MySqlParameter("PASSWORD", usr.PASSWORD));
                sqlcmd.Parameters.Add(new MySqlParameter("ENTERTIME", usr.ENTERTIME));
                sqlcmd.Parameters.Add(new MySqlParameter("EXITTIME", usr.EXITTIME));
                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }