private void button1_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, "Are you sure you want to update this register?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // Tratamento das Datas EntitiesContext context = new EntitiesContext(); EventDAO edao = new EventDAO(); aBeg = DateTime.Parse(mdtDateBegin.Text); bBeg = aBeg.ToString("dd/MM/yyyy"); cBeg = bBeg + " " + txtTimeBegin.Text; aEnd = DateTime.Parse(mdtDateEnd.Text); bEnd = aEnd.ToString("dd/MM/yyyy"); cEnd = bEnd + " " + txtTimeEnd.Text; //Tratamento da Combo Box Artista ArtistDAO adao = new ArtistDAO(); idart = adao.FindIdByCb(mcbArtEvent.Text); //Tratamento da Combo Box Menu MenuDAO mdao = new MenuDAO(); idmenu = mdao.FindIdByCb(mcbMenuEvent.Text); Event eve = edao.FindId(global.ideve); eve.Name = txtNameEvent.Text; eve.Desc = txtDescEvent.Text; eve.TimeBegin = DateTime.Parse(cBeg); eve.TimeEnd = DateTime.Parse(cEnd); eve.ArtistId = idart; eve.MenuId = idmenu; edao.Update(); MetroMessageBox.Show(this, "Register Successfully Updated", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); } }
private void btnRegister_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, Strings.ConfRegister, Strings.Register, MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // Tratamento das Datas EntitiesContext context = new EntitiesContext(); EventDAO edao = new EventDAO(); aBeg = DateTime.Parse(mdtDateBegin.Text); bBeg = aBeg.ToString("dd/MM/yyyy"); cBeg = bBeg + " " + txtTimeBegin.Text; aEnd = DateTime.Parse(mdtDateEnd.Text); bEnd = aEnd.ToString("dd/MM/yyyy"); cEnd = bEnd + " " + txtTimeEnd.Text; //Tratamento da Combo Box Artista ArtistDAO adao = new ArtistDAO(); idart = adao.FindIdByCb(mcbArtEvent.Text); //Tratamento da Combo Box Menu MenuDAO mdao = new MenuDAO(); idmenu = mdao.FindIdByCb(mcbMenuEvent.Text); Event even = new Event() { Name = txtNameEvent.Text, Desc = txtDescEvent.Text, TimeBegin = DateTime.Parse(cBeg), TimeEnd = DateTime.Parse(cEnd), ArtistId = idart, MenuId = idmenu }; edao.Add(even); MetroMessageBox.Show(this, Strings.SuccessRegistered, Strings.Registered, MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); } }
private void ucAddEvent_Load(object sender, EventArgs e) { lblNameEvent.Text = Strings.EventName; lblDescEvent.Text = Strings.Desc; lblArtEvent.Text = Strings.Artist; lblMenuEvent.Text = Strings.Menu; lblBeginEvent.Text = Strings.Date; lblEndEvent.Text = Strings.Time; btnRegistrer.Text = Strings.Register; btnClear.Text = Strings.ClearFields; ArtistDAO adao = new ArtistDAO(); foreach (var a in adao.List()) { mcbArtEvent.Items.Add(a.Id + "-" + a.Name); } MenuDAO mdao = new MenuDAO(); foreach (var m in mdao.List()) { mcbMenuEvent.Items.Add(m.Id + "-" + m.Name); } }
private void ucEditEvent1_VisibleChanged(object sender, EventArgs e) { try { ucEditEvent21.Visible = true; ucEditEvent21.mcbArtEvent.Items.Clear(); ucEditEvent21.mcbMenuEvent.Items.Clear(); ArtistDAO adao = new ArtistDAO(); foreach (var a in adao.List()) { ucEditEvent21.mcbArtEvent.Items.Add(a.Id + "-" + a.Name); } Artist artista = adao.FindId(int.Parse(global.idarteve)); art = artista.Id.ToString() + "-" + artista.Name.ToString(); MenuDAO mdao = new MenuDAO(); foreach (var m in mdao.List()) { ucEditEvent21.mcbMenuEvent.Items.Add(m.Id + "-" + m.Name); } Entity.Menu menu = mdao.FindId(int.Parse(global.idmenueve)); men = menu.Id.ToString() + "-" + menu.Name.ToString(); subdatebegin = global.begineve.Substring(0, 10); subdateend = global.endeve.Substring(0, 10); subtimebegin1 = global.begineve.Substring(11, 2); subtimebegin2 = global.begineve.Substring(13, 3); subtimebeginf = subtimebegin1 + subtimebegin2; subtimeend1 = global.endeve.Substring(11, 2); subtimeend2 = global.endeve.Substring(13, 3); subtimeendf = subtimeend1 + subtimeend2; ucEditEvent21.txtNameEvent.Text = global.nameeve; ucEditEvent21.txtDescEvent.Text = global.desceve; ucEditEvent21.mdtDateBegin.Text = subdatebegin; ucEditEvent21.mdtDateEnd.Text = subdateend; ucEditEvent21.txtTimeBegin.Text = subtimebeginf; ucEditEvent21.txtTimeEnd.Text = subtimeendf; ucEditEvent21.mcbArtEvent.SelectedItem = art; ucEditEvent21.mcbMenuEvent.SelectedItem = men; } catch (NullReferenceException) { ucEditEvent21.Visible = false; } catch (ArgumentNullException) { ucEditEvent21.Visible = false; } }
// Maps Artist PO to an Artist DO using the IArtistDO interface. public static IArtistDO MapArtistPOtoDO(ArtistPO iArtist) { IArtistDO oArtist = new ArtistDAO(); oArtist.ArtistBandID = iArtist.ArtistBandID; oArtist.ArtistBandName = iArtist.ArtistBandName; oArtist.ArtistBandLocation = iArtist.ArtistBandLocation; oArtist.ArtistBandDebutDate = iArtist.ArtistBandDebutDate; oArtist.ArtistBandBiography = iArtist.ArtistBandBiography; return(oArtist); }
// Updates the Artist based off the form data public void UpdateArtistInformation(IArtistDO iArtist) { var selectedArtist = new ArtistDAO(); try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RockersUnite"].ConnectionString)) { using (SqlCommand updateComm = new SqlCommand("UpdateArtistInformation", conn)) { try { updateComm.CommandType = CommandType.StoredProcedure; updateComm.CommandTimeout = 35; updateComm.Parameters.AddWithValue("@ArtistBandID", SqlDbType.Int).Value = iArtist.ArtistBandID; updateComm.Parameters.AddWithValue("@ArtistBandName", SqlDbType.VarChar).Value = iArtist.ArtistBandName; updateComm.Parameters.AddWithValue("@ArtistBandLocation", SqlDbType.VarChar).Value = iArtist.ArtistBandLocation; updateComm.Parameters.AddWithValue("@ArtistBandDebutDate", SqlDbType.DateTime).Value = iArtist.ArtistBandDebutDate; updateComm.Parameters.AddWithValue("@ArtistBandBiography", SqlDbType.VarChar).Value = iArtist.ArtistBandBiography; var artistBandID = selectedArtist.ArtistBandID; var id = 0; // Ensures the ArtistBandID is a valid number before executing the request // This is known as whitelisting; pretty much says what to expect that is trusted if (!int.TryParse(artistBandID.ToString(), out id)) { throw new ApplicationException("Artist ID was not an integer"); } conn.Open(); updateComm.ExecuteNonQuery(); } catch (Exception ex) { throw; } finally { conn.Close(); conn.Dispose(); updateComm.Dispose(); } } } } catch (Exception ex) { throw; } }
public ArtistDAO ArtistDetails(int id) { var selectedArtist = new ArtistDAO(); var adapter = new SqlDataAdapter(); var myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["RockersUnite"].ConnectionString); var cmd = new SqlCommand("ViewArtistInformation", myConn); try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ArtistBandID", SqlDbType.Int).Value = id; var artistBandID = selectedArtist.ArtistBandID; // Ensures the ArtistBandID is a valid number or throws an exception // This is known as whitelisting; pretty much says what to expect that is trusted if (!int.TryParse(artistBandID.ToString(), out id)) { throw new ApplicationException("Artist ID was not an integer"); } myConn.Open(); adapter.SelectCommand = cmd; using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { selectedArtist.ArtistBandID = reader.GetInt32(0); selectedArtist.ArtistBandName = reader.GetString(1); selectedArtist.ArtistBandLocation = reader.GetString(2); selectedArtist.ArtistBandDebutDate = reader.GetDateTime(3); selectedArtist.ArtistBandBiography = reader.GetString(4); } } } catch { throw; } finally { myConn.Close(); myConn.Dispose(); cmd.Dispose(); } return(selectedArtist); }
// Retrieves Artist Information from DB by ID public IArtistDO ViewArtistByID(int IArtistID) { IArtistDO artistDO = new ArtistDAO(); try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RockersUnite"].ConnectionString)) { using (SqlCommand viewComm = new SqlCommand("ViewArtistInformation", conn)) { viewComm.CommandType = CommandType.StoredProcedure; viewComm.CommandTimeout = 35; viewComm.Parameters.AddWithValue("@ArtistBandID", SqlDbType.Int).Value = IArtistID; conn.Open(); using (SqlDataReader reader = viewComm.ExecuteReader()) { while (reader.Read()) { artistDO.ArtistBandID = reader.GetInt32(0); artistDO.ArtistBandName = reader.GetString(1); artistDO.ArtistBandLocation = reader.GetString(2); artistDO.ArtistBandDebutDate = reader.GetDateTime(3); artistDO.ArtistBandBiography = reader.GetString(4); var artistBandID = artistDO.ArtistBandID; // Ensures the ArtistBandID is a valid number or throws an exception // This is known as whitelisting; pretty much says what to expect that is trusted if (!int.TryParse(artistBandID.ToString(), out IArtistID)) { throw new ApplicationException("Artist ID was not an integer"); } } } } } } catch (Exception ex) { throw; } return(artistDO); }
public AlbumGUI(MainGUI m) { this.m = m; this.a = m.A; dt_list.Columns.Add(new DataColumn("albumid", typeof(int))); dt_list.Columns.Add(new DataColumn("title", typeof(string))); dt_list.Columns.Add(new DataColumn("price", typeof(float))); dt_list.Columns.Add(new DataColumn("albumurl", typeof(string))); dt_list.Columns.Add(new DataColumn("amount", typeof(int))); InitializeComponent(); //get Genres DataTable dt = GenreDAO.getAllGenres(); DataRow r = dt.NewRow(); r["genreid"] = -1; r["name"] = "----- ALL -----"; dt.Rows.Add(r); comboBox1.DataSource = dt; comboBox1.DisplayMember = "name"; comboBox1.ValueMember = "genreid"; comboBox1.SelectedIndex = dt.Rows.Count - 1; // get Arits DataTable dt1 = ArtistDAO.getAllArtist(); DataRow r1 = dt1.NewRow(); r1["artistid"] = -1; r1["name"] = "----- ALL -----"; dt1.Rows.Add(r1); comboBox2.DataSource = dt1; comboBox2.DisplayMember = "name"; comboBox2.ValueMember = "artistid"; comboBox2.SelectedIndex = dt1.Rows.Count - 1; loadData(); }
public List <IArtistDO> ViewAllArtists() { var listOfArtistDOs = new List <IArtistDO>(); try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RockersUnite"].ConnectionString)) { using (SqlCommand viewComm = new SqlCommand("ViewAllArtistsInformation", conn)) { viewComm.CommandType = CommandType.StoredProcedure; viewComm.CommandTimeout = 35; conn.Open(); using (SqlDataReader reader = viewComm.ExecuteReader()) { while (reader.Read()) { IArtistDO artistDO = new ArtistDAO(); artistDO.ArtistBandID = reader.GetInt32(0); artistDO.ArtistBandName = reader.GetString(1); artistDO.ArtistBandLocation = reader.GetString(2); artistDO.ArtistBandDebutDate = reader.GetDateTime(3); artistDO.ArtistBandBiography = reader.GetString(4); listOfArtistDOs.Add(artistDO); } } } } } catch (Exception ex) { throw; } return(listOfArtistDOs); }
public ArtistsController() { daoArtist = new ArtistDAO(); }
static void Main(string[] args) { GigLogin prog = new GigLogin(); ArtistDAO ado = new ArtistDAO(); UserADO user = new UserADO(); string uname = null; string aname = null; bool isWholeFalse = true; while (isWholeFalse) { Console.WriteLine("Please select from the following options:"); Console.WriteLine("1. To create account"); Console.WriteLine("2. Login to your account"); Console.WriteLine("3. To exit from the applicatom"); int ch = Convert.ToInt32(Console.ReadLine()); switch (ch) { case 1: Console.WriteLine("Register as 1.user or 2.artist"); int ch2 = Convert.ToInt32(Console.ReadLine()); bool isFalse = true; while (isFalse) { switch (ch2) { case 1: Console.WriteLine("Enter your username"); string username = Console.ReadLine(); Console.WriteLine("Enter your name"); string name = Console.ReadLine(); string password; do { Console.WriteLine("Enter your password(Must Contain a number)"); password = Console.ReadLine(); } while (!IsValidPassword(password)); try { if (prog.CreateUserAccount(new Model.CreateUser() { username = username, name = name, password = password })) { Console.WriteLine("Account Created! Welcome, {0}", name); isFalse = false; } else { throw new UserExistsException(); } } catch (UserExistsException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } break; case 2: Console.WriteLine("Enter your username"); string username1 = Console.ReadLine(); Console.WriteLine("Enter your name"); string name1 = Console.ReadLine(); string password1; do { Console.WriteLine("Enter your password(Must Contain a number)"); password1 = Console.ReadLine(); } while (!IsValidPassword(password1)); try { if (prog.CreateArtistAccount(new Model.CreateArtist() { artist_username = username1, name = name1, password = password1 })) { Console.WriteLine("Account Created! Welcome, {0}", name1); isFalse = false; } else { throw new UserExistsException(); } } catch (UserExistsException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } break; } } break; case 2: Console.WriteLine("Login as \n 1. User \n 2. Artist"); int ch3 = Convert.ToInt32(Console.ReadLine()); switch (ch3) { case 1: Console.WriteLine("Enter your username:"******"Enter your password"); string password2 = Console.ReadLine(); try { if (prog.UserLogin(username2, password2)) { Console.WriteLine("Login Success"); uname = username2; bool isUserQuit = true; while (isUserQuit) { Console.WriteLine("Welcome {0}, Choose one of the following:", uname); Console.WriteLine("1. View a Gig"); Console.WriteLine("2. Search a gig"); Console.WriteLine("3. Add Gig to calender"); Console.WriteLine("4. View your Calender"); Console.WriteLine("5. Follow an artist"); Console.WriteLine("6. View Following List"); Console.WriteLine("7. Log out"); int user_choice = Convert.ToInt32(Console.ReadLine()); switch (user_choice) { case 1: Console.WriteLine("Here are your following Gigs"); DataTable dt = user.Getgigs(); foreach (DataRow r in dt.Rows) { Console.WriteLine($"GigName:{r["gig_name"]} GigDate:{r["gig_date"]} GigVenue:{r["venue"]}"); } break; case 2: Console.WriteLine("Choose one of the method to search a Gig:"); Console.WriteLine("1. Search Gig using Gig Name"); Console.WriteLine("2. Search Gig using Gig Venue"); Console.WriteLine("3. Search Gig using Gig Date"); int search_choice = Convert.ToInt32(Console.ReadLine()); switch (search_choice) { case 1: Console.WriteLine("Enter the Gig Name"); string gig_name = Console.ReadLine(); DataRow row = user.SearchGigByName(gig_name); if (row != null) { Console.WriteLine($"GigName:{row["gig_name"]} GigDate:{row["gig_date"]} GigVenue:{row["venue"]}"); } else { Console.WriteLine("Invalid Gig_Name"); } break; case 2: Console.WriteLine("Enter the Gig Venue"); string gig_venue = Console.ReadLine(); DataRow row2 = user.SearchGigByVenue(gig_venue); if (row2 != null) { Console.WriteLine($"GigName:{row2["gig_name"]} GigDate:{row2["gig_date"]} GigVenue:{row2["venue"]}"); } else { Console.WriteLine("Invalid Gig_Name"); } break; case 3: Console.WriteLine("Enter the Gig Date"); DateTime gig_date = DateTime.Parse(Console.ReadLine()); DataRow row1 = user.SearchGigByDate(gig_date); if (row1 != null) { Console.WriteLine($"GigName:{row1["gig_name"]} GigDate:{row1["gig_date"]} GigVenue:{row1["venue"]}"); } else { Console.WriteLine("Invalid Gig_Name"); } break; default: Console.WriteLine("Kindly Enter a proper choice"); break; } break; case 3: try { Console.WriteLine("enter username "); string username = Console.ReadLine(); Console.WriteLine("enter gig id "); int gigid = Convert.ToInt32(Console.ReadLine()); if (user.AddToCalender(username, gigid)) { Console.WriteLine(" Gig added to Calender"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case 4: dt = user.ViewCalender(); foreach (DataRow r in dt.Rows) { Console.WriteLine($"Username:{r["username"]} GigId:{r["gig_id"]} GigName:{r["gig_name"]} ArtistName:{r["artist_name"]} isCancelled:{r["isCancelled"]} GigDate:{r["gig_date"]}"); } break; case 5: Console.WriteLine("Enter the Artist Name you want to follow"); string follow_artist = Console.ReadLine(); user.followArtist(uname, follow_artist); Console.WriteLine(uname + " " + "following " + follow_artist); break; case 6: user.DisplayFollows(uname); break; case 7: isUserQuit = false; break; default: Console.WriteLine("Kinndly, choose the Options from the following list"); break; } } } else { throw new UserNotFoundException(); } } catch (UserNotFoundException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } break; case 2: Console.WriteLine("Enter your username:"******"Enter your password"); string password3 = Console.ReadLine(); try { if (prog.ArtistLogin(username3, password3)) { Console.WriteLine("Login Success"); aname = username3; bool isArtistQuit = true; while (isArtistQuit) { Console.WriteLine("Welcome {0}, Choose one of the following:", aname); Console.WriteLine("1. Add a Gig"); Console.WriteLine("2. Edit a Gig"); Console.WriteLine("3. Remove a Gig"); Console.WriteLine("4. Logout"); int artist_choice = Convert.ToInt32(Console.ReadLine()); switch (artist_choice) { case 1: try { Console.WriteLine("enter gig id "); int gigid = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the Gig name"); string gig_name = Console.ReadLine(); Console.WriteLine("Enter the Artist name"); string artist_name = Console.ReadLine(); Console.WriteLine("Enter the venue name"); string venue = Console.ReadLine(); Console.WriteLine("Enter the Gig Date"); DateTime date = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Enter the Genre: "); string gig_genre = Console.ReadLine(); if (ado.AddGig(new Model.CreateGigs() { gigid = gigid, gig_name = gig_name, artist = artist_name, venue = venue, gigdate = date, genre = gig_genre })) { Console.WriteLine("New gig added "); } } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case 2: Console.WriteLine("Choose an option on how you want to edit the Gig:"); Console.WriteLine("1. Update Gig Venue"); Console.WriteLine("2. Update Gig Date"); Console.WriteLine("3. Cancel a Gig"); int edit_choice = Convert.ToInt32(Console.ReadLine()); switch (edit_choice) { case 1: Console.WriteLine("Enter the Gig ID: "); int gig_id = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the updated venue: "); string updated_venue = Console.ReadLine(); if (ado.UpdateGigbyVenue(gig_id, updated_venue)) { Console.WriteLine("Venue updated "); } else { Console.WriteLine("Invalid gig id "); } break; case 2: Console.WriteLine("Enter the Gig ID: "); int gig_id1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the updated Date: "); DateTime updated_date = DateTime.Parse(Console.ReadLine()); if (ado.UpdateGigbyDate(gig_id1, updated_date)) { Console.WriteLine("Date updated"); } else { Console.WriteLine("Invalid gig id "); } break; case 3: Console.WriteLine("Enter the Gig ID: "); int gig_id2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Do you want to cancel the Gig?"); string isCancelled = Console.ReadLine(); if (ado.isCancelled(gig_id2, isCancelled)) { Console.WriteLine("Gig Status Modified"); } else { Console.WriteLine("Invalid gig id "); } break; default: Console.WriteLine("Please choose a proper option"); break; } break; case 3: Console.WriteLine("Enter gig Id you want to delete"); int gigId = Convert.ToInt32(Console.ReadLine()); if (ado.deleteGig(gigId)) { Console.WriteLine("Gig deleted"); } else { Console.WriteLine("will implement throw"); } break; default: break; } } } else { throw new UserNotFoundException(); } } catch (UserNotFoundException ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message, Console.ForegroundColor); Console.ForegroundColor = ConsoleColor.White; } break; } break; case 3: isWholeFalse = false; break; default: Console.WriteLine("Kindly Enter a proper option"); break; } } }