public bool Create(Patient t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("Insert into patient (id, name, idCardNo, address, birthDate) VALUES('{0}', '{1}', '{2}', '{3}', '{4}'); ", t.GetId(), t.GetName(), t.GetIdCardNo(), t.GetAddress(), t.GetBirthDate().ToString("yyyy-MM-dd HH:mm:ss"));
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
 public bool Create(Consultation t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("Insert into consultation (id, appointmentDate, user_id, patient_id) VALUES('{0}', '{1}', '{2}', '{3}'); ", t.GetId(), t.GetAppointmentDate().ToString("yyyy-MM-dd HH:mm:ss"), t.GetDoctorId(), t.GetPatientId());
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
Example #3
0
 public bool Create(Book t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("INSERT INTO book (id,title,author,genre,quantity,price) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}');", t.GetId(), t.GetTitle(), t.GetAuthor(), t.GetGenre(), t.GetQuantity(), t.GetPrice());
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
 public bool Create(Event t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("Insert into event (id, title, genre, date, description, noTickets, ticketPrice) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}'); ", t.GetId(), t.GetTitle(), t.GetGenre(), t.GetDate().ToString("yyyy-MM-dd HH:mm:ss"), t.GetDescription(), t.GetNoTickets(), t.GetTicketPrice());
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
 public bool Create(User t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("Insert into user(id, name, type, username, password) VALUES('{0}', '{1}', '{2}', '{3}', '{4}'); ", t.GetId(), t.GetName(), t.GetType(), t.GetUsername(), t.GetPassword());
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
Example #6
0
 public bool Create(Ticket t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             command.CommandText = String.Format("Insert into ticket (id, user_id, event_id) VALUES('{0}', '{1}', '{2}'); ", t.GetId(), t.GetUserId(), t.GetEventId());
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }
 public bool Create(User t)
 {
     if (t == null)
     {
         return(false);
     }
     using (MySqlConnection connection = connectionWrapper.GetConnection())
     {
         connection.Open();
         using (MySqlCommand command = connection.CreateCommand())
         {
             bool isAdmin = false;
             if (t.GetRole().RoleName == Database.Constants.Roles.ADMIN)
             {
                 isAdmin = true;
             }
             command.CommandText = String.Format("Insert into user(id, name, username, password, isAdmin) VALUES('{0}', '{1}', '{2}', '{3}', '{4}'); ", t.GetId(), t.GetName(), t.GetUsername(), t.GetPassword(), isAdmin ? 1 : 0);
             command.ExecuteNonQuery();
         }
         connection.Close();
     }
     return(true);
 }