Ejemplo n.º 1
0
        //Method for Adding an ItemDB
        public int Add(AccountDB accountDB)
        {
            int i;

            using (OracleConnection con = new OracleConnection(cs))
            {
                con.Open();
                string        query = "Insert into TOKO.Account(Username,Password) VALUES (:2, :3)";
                OracleCommand com   = con.CreateCommand();
                com.CommandText = query;
                com.CommandType = CommandType.Text;
                //com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("2", OracleDbType.Varchar2, 50).Value = accountDB.USERNAME.ToString();
                com.Parameters.Add("3", OracleDbType.Varchar2, 50).Value = encrypt(accountDB.PASSWORD.ToString());
                i = com.ExecuteNonQuery();
            }
            return(i);
        }
Ejemplo n.º 2
0
        //Method for Updating ItemDB record
        public int Update(AccountDB accountDB)
        {
            int i;

            using (OracleConnection con = new OracleConnection(cs))
            {
                con.Open();
                string        query = "Update TOKO.ACCOUNT SET username=:2, password=:3 WHERE id=:1";
                OracleCommand com   = con.CreateCommand();
                com.CommandText = query;
                com.CommandType = CommandType.Text;
                //com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("2", OracleDbType.Varchar2, 50).Value = accountDB.USERNAME.ToString();
                com.Parameters.Add("3", OracleDbType.Varchar2, 50).Value = encrypt(accountDB.PASSWORD.ToString());
                com.Parameters.Add("1", OracleDbType.Int32, 10).Value    = Convert.ToInt32(accountDB.ID);
                i = com.ExecuteNonQuery();
            }
            return(i);
        }
Ejemplo n.º 3
0
        public AccountDB Login(AccountDB account)
        {
            AccountDB lst = new AccountDB();

            using (OracleConnection con = new OracleConnection(cs))
            {
                con.Open();
                string        query = "select * from TOKO.account where username=:2 and password=:3";
                OracleCommand com   = con.CreateCommand();
                com.CommandText = query;
                com.CommandType = CommandType.Text;
                //com.CommandType = CommandType.StoredProcedure;
                com.Parameters.Add("2", OracleDbType.Varchar2, 50).Value = account.USERNAME.ToString();
                com.Parameters.Add("3", OracleDbType.Varchar2, 50).Value = encrypt(account.PASSWORD.ToString());
                OracleDataReader rdr = com.ExecuteReader();
                while (rdr.Read())
                {
                    lst.ID = Convert.ToInt16(rdr["ID"]);
                }
            }
            return(lst);
        }