Exemplo n.º 1
0
        public Utente Register(Utente U)
        {
            DataTable dt = new DataTable();
            DBEntity  db = new DBEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = String.Format(@"INSERT INTO utenti (nome,cognome,telefono,email,password)
                                                            VALUES('{0}','{1}','{2}','{3}')",
                                            U.Nome, U.Cognome, U.Telefono, U.Email, U.Password);

            int id = db.eseguiInsertIDreturn(cmd);

            U.ID = id;

            return(U);
        }
        public Prenotazione AddPrenotazione(Prenotazione P)
        {
            DataTable dt = new DataTable();
            DBEntity  db = new DBEntity();

            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            Int64 now = Convert.ToInt64(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);

            cmd.CommandText = String.Format(@"INSERT INTO prenotazioni (qta, data, fk_utente, fk_replica)
                                                         VALUES({0},{1},{2},{3});SELECT SCOPE_IDENTITY()", P.Biglietti, now, P.IDUtente, P.IDReplica);

            int id = db.eseguiInsertIDreturn(cmd);

            P.ID      = id;
            P.Replica = new daoReplica().GetByID(P.IDReplica);

            return(P);
        }