private void spInsertEventKategori(ODEONEvent OE, Kategori Kat) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE spInsertEventKategori @Event, @Kategori"; command.Parameters.AddWithValue("@Event", OE.ID); command.Parameters.AddWithValue("@Kategori", Kat.ID); command.Connection = connection; command.Connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }
public void DownloadHeleEvent(ODEONEvent OE) { spGetEvent(OE); spGetEventKategorier(OE); spGetAfviklinger(OE); foreach (Afvikling afvikling in OE.Afviklinger) { spGetBilletTyper(afvikling); foreach (BilletType billet in afvikling.BilletTyper) { spGetSalgsTal(billet); } } }
private void spGetEventKategorier(ODEONEvent OE) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE [spGetEventKategorier] @EventID"; command.Parameters.AddWithValue("@EventID", OE.ID); command.Connection = connection; connection.Open(); SqlDataReader Reader = command.ExecuteReader(); while (Reader.Read()) { OE.Kategorier.Add(KatRepo.GetItem((int)Reader["Kategori"])); } } }
public void UploadEvent(ODEONEvent upload) { spInsertEvent(upload); foreach (Kategori item in upload.Kategorier) { spInsertEventKategori(upload, item); } foreach (Afvikling afvik in upload.Afviklinger) { spInsertAfvikling(upload, afvik); foreach (BilletType billet in afvik.BilletTyper) { spInsertBilletType(billet, afvik); } } }
//private void spInsertAfvikling(ODEONEvent OE, Afvikling afvikling) //{ // using (SqlConnection connection = new SqlConnection(ConnectionString)) // { // SqlCommand command = new SqlCommand(); // command.CommandText = "EXECUTE spInsertAfvikling @Dato, @Event, @Sal"; // command.Parameters.AddWithValue("@Dato", afvikling.Dato); // command.Parameters.AddWithValue("@Event", OE.ID); // command.Parameters.AddWithValue("@Sal", afvikling.Sal.ID); // command.Connection = connection; // command.Connection.Open(); // command.ExecuteNonQuery(); // connection.Close(); // } // using (SqlConnection connection = new SqlConnection(ConnectionString)) // { // SqlCommand command = new SqlCommand(); // command.CommandText = "EXECUTE spGetAfviklingId @Event, @Dato"; // command.Parameters.AddWithValue("@Event", OE.ID); // command.Parameters.AddWithValue("@Dato", afvikling.Dato); // command.Connection = connection; // command.Connection.Open(); // SqlDataReader sqlDataReader = command.ExecuteReader(); // sqlDataReader.Read(); // afvikling.ID = (int)sqlDataReader["DatoId"]; // sqlDataReader.Close(); // connection.Close(); // } //} private void spInsertAfvikling(ODEONEvent OE, Afvikling afvikling) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE spTest @Dato, @Event, @Sal"; command.Parameters.AddWithValue("@Dato", afvikling.Dato); command.Parameters.AddWithValue("@Event", OE.ID); command.Parameters.AddWithValue("@Sal", afvikling.Sal.ID); command.Connection = connection; command.Connection.Open(); SqlDataReader sqlDataReader = command.ExecuteReader(); sqlDataReader.Read(); afvikling.ID = (int)sqlDataReader["DatoId"]; sqlDataReader.Close(); connection.Close(); } }
private void spGetAfviklinger(ODEONEvent OE) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE [spGetAfviklinger] @EventID"; command.Parameters.AddWithValue("@EventID", OE.ID); command.Connection = connection; connection.Open(); SqlDataReader Reader = command.ExecuteReader(); while (Reader.Read()) { Afvikling afvikling = new Afvikling((DateTime)Reader["Dato"]); afvikling.ID = (int)Reader["DatoId"]; afvikling.Sal = SalRepo.GetItem((int)Reader["Sal"]); OE.Afviklinger.Add(afvikling); } } }
private void DownloadEventListe() { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand("spListOfEvents", connection); command.CommandType = System.Data.CommandType.StoredProcedure; //command.CommandText = "EXECUTE [spListOfEvents]"; //command.Connection = connection; command.Connection.Open(); SqlDataReader sqlDataReader = command.ExecuteReader(); while (sqlDataReader.Read()) { int id = (int)sqlDataReader["EventId"]; string navn = (string)sqlDataReader["EventNavn"]; ODEONEvent OE = new ODEONEvent(navn, id); OERepo.AddItem(OE); } sqlDataReader.Close(); connection.Close(); } }
private void spGetEvent(ODEONEvent OE) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE [spGetEvent] @ID"; command.Parameters.AddWithValue("@ID", OE.ID); command.Connection = connection; connection.Open(); SqlDataReader Reader = command.ExecuteReader(); Reader.Read(); decimal marked = (decimal)Reader["Markedsføring"]; double koda = (float)Reader["Koda"]; decimal garanti = (decimal)Reader["Garantisum"]; double split = (float)Reader["ArtistSplit"]; Omkostninger omkostninger = new Omkostninger(marked, koda, garanti, split); omkostninger.VariableOmkostninger = (decimal)Reader["VariableOmkostninger"]; omkostninger.Note = (string)Reader["OmkostningerNote"]; OE.Omkostninger = omkostninger; VariableIndtægter indtægter = new VariableIndtægter(); indtægter.Beløb = (decimal)Reader["VariableIndtægter"]; indtægter.Note = (string)Reader["IndtægterNote"]; OE.VariableIndtjening = indtægter; DateTime dateTime = (DateTime)Reader["UnderskudsGodtgørelse"]; foreach (UnderskudsGodtgørelse gg in GGRepo) { if (gg.UdløbsDato == dateTime) { OE.Godtgørelse = gg; break; } } } }
private void spInsertEvent(ODEONEvent target) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { SqlCommand command = new SqlCommand(); command.CommandText = "EXECUTE spInsertEvent @EventNavn, @Markedsføring, @Koda, @Garantisum, @ArtistSplit, @VariableOmkostninger, @OmkostningerNote, @VariableIndtægter, @IndtægterNote, @UnderskudsGodtgørelse"; command.Parameters.AddWithValue("@EventNavn", target.Navn); command.Parameters.AddWithValue("@Markedsføring", target.Omkostninger.MarkedsFøring); command.Parameters.AddWithValue("@Koda", target.Omkostninger.KODA); command.Parameters.AddWithValue("@Garantisum", target.Omkostninger.Garantisum); command.Parameters.AddWithValue("@ArtistSplit", target.Omkostninger.ArtistSplit); command.Parameters.AddWithValue("@VariableOmkostninger", target.Omkostninger.VariableOmkostninger); command.Parameters.AddWithValue("@OmkostningerNote", target.Omkostninger.Note); command.Parameters.AddWithValue("@VariableIndtægter", target.VariableIndtjening.Beløb); command.Parameters.AddWithValue("@IndtægterNote", target.VariableIndtjening.Note); command.Parameters.AddWithValue("@UnderskudsGodtgørelse", target.Godtgørelse.UdløbsDato); command.Connection = connection; command.Connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }