SlideShare a Scribd company logo
1 of 20
Download to read offline
Classes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chord_Reader.NewClasses
{
class Playlist
{
public int PlaylistID { get; set; }
public string Title { get; set; }
public List<Song> Song { get; set; }
public string Username { get; set; }
public Playlist(int playlistID, string title,string username)
{
PlaylistID = playlistID;
Title = title;
Username = username;
Song = new List<Song>();
}
public Playlist()
{
Song = new List<Song>();
}
public void AddSong(Song song)
{
Song.Add(song);
}
public void MoveSongUp(int i)
{
if (i > 0)
{
Song s = Song[i];
Song[i] = Song[i - 1];
Song[i - 1] = s;
}
}
public void MoveSongDown(int i)
{
if (i > 0 && i < Song.Count)
{
Song s = Song[i];
Song[i] = Song[i + 1];
Song[i + 1] = s;
}
}
}
}
using Chord_Reader.NewClasses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chord_Reader.NewClasses
{
class Song
{
public int SongID { get; set; }
public string Title { get; set; }
public string Artist { get; set; }
public string Album { get; set; }
public string Genre { get; set; }
public string Text { get; set; }
public string Mode { get; set; }
public string KeyOf { get; set; }
public string Username { get; set; }
public int Trans { get; set; }
public Song(int songID, string title, string artist, string album, string genre, string text, string keyOf, string
mode, string username)
{
SongID = songID;
Title = title;
Artist = artist;
Album = album;
Genre = genre;
Text = text;
Mode = mode;
KeyOf = keyOf;
Username = username;
Trans = 0;
}
public void Transpose(bool a)
{
if (a == false)
{
Text = Text.Replace("*B*", "+A#+");
Text = Text.Replace("*A#*", "+A+");
Text = Text.Replace("*A*", "+G#+");
Text = Text.Replace("*G#*", "+G+");
Text = Text.Replace("*G*", "+F#+");
Text = Text.Replace("*F#*", "+F+");
Text = Text.Replace("*F*", "+E+");
Text = Text.Replace("*E*", "+D#+");
Text = Text.Replace("*D#*", "+D+");
Text = Text.Replace("*D*", "+C#+");
Text = Text.Replace("*C#*", "+C+");
Text = Text.Replace("*C*", "+B+");
Text = Text.Replace("+", "*");
KeyOf = KeyOf.Replace("*B*", "+A#+");
KeyOf = KeyOf.Replace("*A#*", "+A+");
KeyOf = KeyOf.Replace("*A*", "+G#+");
KeyOf = KeyOf.Replace("*G#*", "+G+");
KeyOf = KeyOf.Replace("*G*", "+F#+");
KeyOf = KeyOf.Replace("*F#*", "+F+");
KeyOf = KeyOf.Replace("*F*", "+E+");
KeyOf = KeyOf.Replace("*E*", "+D#+");
KeyOf = KeyOf.Replace("*D#*", "+D+");
KeyOf = KeyOf.Replace("*D*", "+C#+");
KeyOf = KeyOf.Replace("*C#*", "+C+");
KeyOf = KeyOf.Replace("*C*", "+B+");
KeyOf = KeyOf.Replace("*Bm*", "+A#m+");
KeyOf = KeyOf.Replace("*A#m*", "+Am+");
KeyOf = KeyOf.Replace("*Am*", "+G#m+");
KeyOf = KeyOf.Replace("*G#m*", "+Gm+");
KeyOf = KeyOf.Replace("*Gm*", "+F#m+");
KeyOf = KeyOf.Replace("*F#m*", "+Fm+");
KeyOf = KeyOf.Replace("*Fm*", "+Em+");
KeyOf = KeyOf.Replace("*Em*", "+D#m+");
KeyOf = KeyOf.Replace("*D#*", "+Dm+");
KeyOf = KeyOf.Replace("*Dm*", "+C#m+");
KeyOf = KeyOf.Replace("*C#m*", "+Cm+");
KeyOf = KeyOf.Replace("*Cm*", "+Bm+");
KeyOf = KeyOf.Replace("+", "*");
if (Trans == -5)
Trans = 6;
else
Trans--;
}
else
{
Text = Text.Replace("*B*", "+C+");
Text = Text.Replace("*A#*", "+B+");
Text = Text.Replace("*A*", "+A#+");
Text = Text.Replace("*G#*", "+A+");
Text = Text.Replace("*G*", "+G#+");
Text = Text.Replace("*F#*", "+G+");
Text = Text.Replace("*F*", "+F#+");
Text = Text.Replace("*E*", "+F+");
Text = Text.Replace("*D#*", "+E+");
Text = Text.Replace("*D*", "+D#+");
Text = Text.Replace("*C#*", "+D+");
Text = Text.Replace("*C*", "+C#+");
Text = Text.Replace("+", "*");
KeyOf = KeyOf.Replace("*B*", "+C+");
KeyOf = KeyOf.Replace("*A#*", "+B+");
KeyOf = KeyOf.Replace("*A*", "+A#+");
KeyOf = KeyOf.Replace("*G#*", "+A+");
KeyOf = KeyOf.Replace("*G*", "+G#+");
KeyOf = KeyOf.Replace("*F#*", "+G+");
KeyOf = KeyOf.Replace("*F*", "+F#+");
KeyOf = KeyOf.Replace("*E*", "+F+");
KeyOf = KeyOf.Replace("*D#*", "+E+");
KeyOf = KeyOf.Replace("*D*", "+D#+");
KeyOf = KeyOf.Replace("*C#*", "+D+");
KeyOf = KeyOf.Replace("*C*", "+C#+");
KeyOf = KeyOf.Replace("*Bm*", "+Cm+");
KeyOf = KeyOf.Replace("*A#m*", "+Bm+");
KeyOf = KeyOf.Replace("*Am*", "+A#m+");
KeyOf = KeyOf.Replace("*G#m*", "+Am+");
KeyOf = KeyOf.Replace("*Gm*", "+G#m+");
KeyOf = KeyOf.Replace("*F#m*", "+Gm+");
KeyOf = KeyOf.Replace("*Fm*", "+F#m+");
KeyOf = KeyOf.Replace("*Em*", "+Fm+");
KeyOf = KeyOf.Replace("*D#m*", "+Em+");
KeyOf = KeyOf.Replace("*Dm*", "+D#m+");
KeyOf = KeyOf.Replace("*C#m*", "+Dm+");
KeyOf = KeyOf.Replace("*Cm*", "+C#m+");
KeyOf = KeyOf.Replace("+", "*");
if (Trans == 6)
Trans = -5;
else
Trans++;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chord_Reader.NewClasses
{
class User
{
public int UserID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Username { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public User(int userID, string firstName, string lastName, string username, string email, string password)
{
UserID = userID;
FirstName = firstName;
LastName = lastName;
Username = username;
Email = email;
Password = password;
}
}
}
MAIN FORM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using Chord_Reader.NewClasses;
using Chord_Reader.Properties;
namespace Chord_Reader
{
public partial class Main_form : OfficeForm
{
public Main_form()
{
InitializeComponent();
}
#region SQL Declare
SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS;
AttachDbFilename=C:ProgramDataLiveChordPlayerChordLivePlayer.mdf; Connect Timeout=30; User Instance=True; integrated
security=true");
SqlDataAdapter returnVal;
DataTable dt;
SqlCommand cmd;
string query;
#endregion
#region Object Declare
List<Song> songs = new List<Song>();
List<Song> plSongs = new List<Song>();
List<Playlist> playlists = new List<Playlist>();
User CurrentUser;
#endregion
#region LOAD
private void Main_form_Load(object sender, EventArgs e)
{
SQL("SELECT * FROM Songs");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
songs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(),
d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString()));
ReaderList_lbx.Items.Add(d[1].ToString());
}
}
SQL("SELECT * FROM PlSongs");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
plSongs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(),
d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString()));
}
}
SQL("SELECT * FROM Playlists");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
playlists.Add(new Playlist(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString()));
}
foreach (Playlist p in playlists)
{
SelectPlaylist_cbx.Items.Add(p.Title);
Playlist_lbx.Items.Add(p.Title);
SQL("SELECT songID FROM Songlists WHERE playlistID='" + p.PlaylistID.ToString() + "' ORDER BY
orderID");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
foreach (Song s in plSongs)
{
if (s.SongID == Int32.Parse(d[0].ToString()))
{
p.AddSong(s);
}
}
}
}
}
}
}
#endregion
#region ACCOUNT
private void SignUp_btn_Click(object sender, EventArgs e)
{
if (SPassword_tbx.Text == RePassword_tbx.Text)
{
SQL("SELECT * FROM Users WHERE username='" + SUsername_tbx.Text + "' OR email='" + Email_tbx.Text + "'");
if (dt.Rows.Count != 0)
{
MessageBox.Show("Username od Email already exists!");
SUsername_tbx.Text = "";
Email_tbx.Text = "";
SPassword_tbx.Text = "";
RePassword_tbx.Text = "";
}
else
{
SQL("INSERT INTO Users(fName, lName, username, email, password) VALUES('" + FName_tbx.Text + "', '" +
LName_tbx.Text + "', '" + SUsername_tbx.Text + "', '" + Email_tbx.Text + "', '" + SPassword_tbx.Text + "')");
MessageBox.Show("Account Created!");
SQL("SELECT * FROM Users WHERE username='" + SUsername_tbx.Text + "' AND password='" +
SPassword_tbx.Text + "'");
CurrentUser = new User(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(),
dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString());
FName_tbx.Text = "";
LName_tbx.Text = "";
SUsername_tbx.Text = "";
Email_tbx.Text = "";
SPassword_tbx.Text = "";
RePassword_tbx.Text = "";
FName_lbl.Text = " <b>" + CurrentUser.FirstName + "</b>";
LName_lbl.Text = " <b>" + CurrentUser.LastName + "</b>";
Username_lbl.Text = " <b>" + CurrentUser.Username + "</b>";
Email_lbl.Text = " <b>" + CurrentUser.Email + "</b>";
panelEx2.Visible = true;
panelEx1.Visible = false;
Writer_tab.Enabled = true;
Live_tab.Enabled = true;
AddLive_btn.Enabled = true;
SelectPlaylist_cbx.Enabled = true;
this.Text += " - " + CurrentUser.Username;
}
}
else
{
MessageBox.Show("Passwords doesn't match! Try Again!");
SPassword_tbx.Text = "";
RePassword_tbx.Text = "";
}
}
private void LogIn_btn_Click(object sender, EventArgs e)
{
SQL("SELECT * FROM Users WHERE username='" + Username_tbx.Text + "' AND password='" + Password_tbx.Text +
"'");
if (dt.Rows.Count != 0)
{
CurrentUser = new User(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(),
dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString());
Username_tbx.Text = "";
Password_tbx.Text = "";
FName_lbl.Text = " <b>" + CurrentUser.FirstName + "</b>";
LName_lbl.Text = " <b>" + CurrentUser.LastName + "</b>";
Username_lbl.Text = " <b>" + CurrentUser.Username + "</b>";
Email_lbl.Text = " <b>" + CurrentUser.Email + "</b>";
panelEx2.Visible = true;
panelEx1.Visible = false;
Writer_tab.Enabled = true;
Live_tab.Enabled = true;
AddLive_btn.Enabled = true;
SelectPlaylist_cbx.Enabled = true;
this.Text += " - " + CurrentUser.Username;
}
else
{
MessageBox.Show("Username or Password is invalid!");
}
}
#endregion
#region WRITER
private void WriterSave_btn_Click(object sender, EventArgs e)
{
if (Title_tbx.Text != "" && Artist_tbx.Text != "" && Genre_cbx.Text != "" && WriterText_tbx.Text != "" &&
KeyOf_cbx.Text != "")
{
SQL("SELECT * FROM Songs WHERE title='" + Title_tbx.Text + "'");
if (dt.Rows.Count != 0)
{
MessageBox.Show("Song already exists!");
Title_tbx.Text = "";
Artist_tbx.Text = "";
Genre_cbx.Text = "";
Album_tbx.Text = "";
KeyOf_cbx.Text = "";
WriterText_tbx.Text = "";
}
else
{
SQL("INSERT INTO Songs(title, artist, album, genre, text, keyOf, mode, username) VALUES('" +
Title_tbx.Text + "', '" + Artist_tbx.Text + "', '" + Album_tbx.Text + "', '" + Genre_cbx.Text + "', '" +
WriterText_tbx.Text + "', '*" + KeyOf_cbx.Text + "*', '" + ReaderMode_swbtn.Value.ToString() + "', '" +
CurrentUser.Username + "')");
MessageBox.Show("Song Created!");
SQL("SELECT * FROM Songs WHERE title='" + Title_tbx.Text + "'");
songs.Add(new Song(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(),
dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString(),
dt.Rows[0][6].ToString(), dt.Rows[0][7].ToString(), dt.Rows[0][8].ToString()));
ReaderList_lbx.Items.Add(dt.Rows[0][1].ToString());
Title_tbx.Text = "";
Artist_tbx.Text = "";
Genre_cbx.Text = "";
Album_tbx.Text = "";
KeyOf_cbx.Text = "";
WriterText_tbx.Text = "";
}
}
else
{
MessageBox.Show("Fill all fields!");
}
}
private void WriterDiscard_btn_Click(object sender, EventArgs e)
{
Title_tbx.Text = "";
Artist_tbx.Text = "";
Genre_cbx.Text = "";
Album_tbx.Text = "";
KeyOf_cbx.Text = "";
WriterText_tbx.Text = "";
MessageBox.Show("You have just discarded your song!");
}
#endregion
#region READER
private void ReaderList_lbx_SelectedIndexChanged(object sender, EventArgs e)
{
Main_pnl.Visible = true;
foreach (Song s in songs)
{
if (ReaderList_lbx.SelectedItems.Count > 0)
{
if (s.Title == ReaderList_lbx.SelectedItems[0].Text)
{
ReaderText_tbx.Text = "";
List<string> list = new List<string>(s.Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach(string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
TransMinus_btn.Enabled = true;
TransPlus_btn.Enabled = true;
Trans_lbl.Enabled = true;
if (s.Trans > 0)
Trans_lbl.Text = "+" + s.Trans.ToString();
else
Trans_lbl.Text = s.Trans.ToString();
Title_lbl.Text = s.Title;
Album_lbl.Text = "Album: " + s.Album;
KeyOf_lbl.Text = s.KeyOf.Replace("*", "");
Artist_lbl.Text = s.Artist;
CreatedBy_lbl.Text = "Created by: " + s.Username;
}
}
}
}
private void AddLive_btn_Click(object sender, EventArgs e)
{
if (SelectPlaylist_cbx.Text != "")
{
foreach (Song s in songs)
{
foreach (Playlist p in playlists)
{
if (ReaderList_lbx.SelectedItems.Count > 0)
{
if (s.Title == ReaderList_lbx.SelectedItems[0].Text && p.Title == SelectPlaylist_cbx.Text)
{
if (string.Compare(p.Username, CurrentUser.Username) == -1)
{
SQL("INSERT INTO PlSongs(title, artist, album, genre, text, keyOf, mode, username)
VALUES('" + s.Title + "', '" + s.Artist + "', '" + s.Album + "', '" + s.Genre + "', '" + s.Text + "', '" + s.KeyOf + "',
'False', '" + CurrentUser.Username + "')");
SQL("SELECT * FROM Songlists WHERE songID=" + s.SongID.ToString() + " AND
playlistID='" + p.PlaylistID.ToString() + "'");
if (dt.Rows.Count != 0)
{
MessageBox.Show("Song is already in this playlist!");
}
else
{
SQL("SELECT songID FROM PlSongs WHERE title='" + s.Title + "' AND username='" +
CurrentUser.Username + "'");
p.AddSong(s);
int z = Int32.Parse(dt.Rows[0][0].ToString());
SQL("INSERT INTO Songlists(songID, playlistID, orderID) VALUES('" + z + "', '" +
p.PlaylistID + "', '" + p.Song.Count + "')");
MessageBox.Show("Song Added!");
}
}
else MessageBox.Show("You are not allowed to add song to another user's playlist!");
}
}
}
}
}
else MessageBox.Show("Select playlist to add song!");
}
private void Search_tbx_TextChanged(object sender, EventArgs e)
{
string value = Search_tbx.Text.ToLower();
ReaderList_lbx.Items.Clear();
foreach (Song s in songs)
{
ReaderList_lbx.Items.Add(s.Title);
}
foreach (ListViewItem it in ReaderList_lbx.Items)
{
if (it.Text.ToLower().StartsWith(value) == false)
{
it.Remove();
}
}
}
private void TransMinus_btn_Click(object sender, EventArgs e)
{
foreach (Song s in songs)
{
if (ReaderList_lbx.SelectedItems.Count > 0)
{
if (s.Title == ReaderList_lbx.SelectedItems[0].Text)
{
s.Transpose(false);
string temp = s.KeyOf;
KeyOf_lbl.Text = temp.Replace("*", "");
ReaderText_tbx.Text = "";
List<string> list = new List<string>(s.Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
if (s.Trans > 0)
Trans_lbl.Text = "+" + s.Trans.ToString();
else
Trans_lbl.Text = s.Trans.ToString();
}
}
}
}
private void TransPlus_btn_Click(object sender, EventArgs e)
{
foreach (Song s in songs)
{
if (ReaderList_lbx.SelectedItems.Count > 0)
{
if (s.Title == ReaderList_lbx.SelectedItems[0].Text)
{
s.Transpose(true);
string temp = s.KeyOf;
KeyOf_lbl.Text = temp.Replace("*", "");
ReaderText_tbx.Text = "";
List<string> list = new List<string>(s.Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
if (s.Trans > 0)
Trans_lbl.Text = "+" + s.Trans.ToString();
else
Trans_lbl.Text = s.Trans.ToString();
}
}
}
}
#endregion
#region LIVE PLAYER
private void NewPlaylist_btn_Click(object sender, EventArgs e)
{
if (PlaylistTitle_tbx.Text != "")
{
SQL("SELECT * FROM Playlists WHERE title='" + Title_tbx.Text + "'");
if (dt.Rows.Count != 0)
{
MessageBox.Show("Playlists already exists!");
}
else
{
SQL("INSERT INTO Playlists(title, username) VALUES('" + PlaylistTitle_tbx.Text + "', '" +
CurrentUser.Username + "')");
MessageBox.Show("Playlist Created!");
SQL("SELECT * FROM Playlists WHERE title='" + PlaylistTitle_tbx.Text + "'");
playlists.Add(new Playlist(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(),
dt.Rows[0][2].ToString()));
int plNum = playlists.Count();
SelectPlaylist_cbx.Items.Add(playlists[plNum - 1].Title);
Playlist_lbx.Items.Add(playlists[plNum - 1].Title);
PlaylistTitle_tbx.Text = "";
}
}
else
{
MessageBox.Show("Fill all fields!");
}
}
private void Playlist_lbx_SelectedIndexChanged(object sender, EventArgs e)
{
if (Playlist_lbx.SelectedItems.Count > 0)
{
foreach (Playlist p in playlists)
{
if (p.Title == Playlist_lbx.SelectedItems[0].Text)
{
PlaylistSong_lbx.Enabled = true;
PlaylistSong_lbx.Clear();
PlaylistTitle_lbx.Text = p.Title;
foreach (Song s in p.Song)
{
PlaylistSong_lbx.Items.Add(s.Title);
}
}
}
}
}
private void SearchPlaylist_tbx_TextChanged(object sender, EventArgs e)
{
string value = SearchPlaylist_tbx.Text.ToLower();
Playlist_lbx.Items.Clear();
foreach (Playlist p in playlists)
{
Playlist_lbx.Items.Add(p.Title);
}
foreach (ListViewItem it in Playlist_lbx.Items)
{
if (it.Text.ToLower().StartsWith(value) == false)
{
it.Remove();
}
}
}
private void Play_btn_Click(object sender, EventArgs e)
{
if (Playlist_lbx.SelectedItems.Count > 0)
{
foreach (Playlist p in playlists)
{
if (p.Title == Playlist_lbx.SelectedItems[0].Text)
{
Live f = new Live(p.PlaylistID);
f.WindowState = FormWindowState.Maximized;
f.ShowDialog();
}
}
}
else
MessageBox.Show("Chose Playlist you want to play!");
}
#endregion
private void SQL(string a)
{
con.Open();
query = a;
cmd = new SqlCommand(query, con);
returnVal = new SqlDataAdapter(query, con);
dt = new DataTable();
returnVal.Fill(dt);
con.Close();
}
}
}
Live Form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using Chord_Reader.NewClasses;
using Chord_Reader.Properties;
namespace Chord_Reader
{
public partial class Live : OfficeForm
{
int id;
public Live(int ID)
{
InitializeComponent();
id = ID;
}
#region Object Declare
Playlist CurrPlaylist;
List<Song> songs = new List<Song>();
int x = 0;
#endregion
#region SQL Declare
SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS;
AttachDbFilename=C:ProgramDataLiveChordPlayerChordLivePlayer.mdf; Connect Timeout=30; User Instance=True; integrated
security=true");
SqlDataAdapter returnVal;
DataTable dt;
SqlCommand cmd;
string query;
#endregion
private void Live_Load(object sender, EventArgs e)
{
SQL("SELECT * FROM PlSongs");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
songs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(),
d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString()));
}
}
SQL("SELECT * FROM Playlists WHERE playlistID='" + id + "'");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
CurrPlaylist = new Playlist(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString());
}
SQL("SELECT songID FROM Songlists WHERE playlistID='" + CurrPlaylist.PlaylistID.ToString() + "' ORDER BY
orderID");
if (dt.Rows.Count != 0)
{
foreach (DataRow d in dt.Rows)
{
foreach (Song s in songs)
{
if (s.SongID == Int32.Parse(d[0].ToString()))
{
CurrPlaylist.AddSong(s);
}
}
}
}
}
List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
Title_lbl.Text = CurrPlaylist.Song[0].Title;
Artist_lbl.Text = CurrPlaylist.Song[0].Artist;
Album_lbl.Text = CurrPlaylist.Song[0].Album;
PlaylistTitle_lbl.Text = CurrPlaylist.Title;
}
private void Live_SizeChanged(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
private void Next_btn_Click(object sender, EventArgs e)
{
x++;
Prev_btn.Enabled = true;
ReaderText_tbx.Text = "";
List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
Title_lbl.Text = CurrPlaylist.Song[x].Title;
Artist_lbl.Text = CurrPlaylist.Song[x].Artist;
Album_lbl.Text = CurrPlaylist.Song[x].Album;
if (x == CurrPlaylist.Song.Count -1)
Next_btn.Enabled = false;
}
private void Prev_btn_Click(object sender, EventArgs e)
{
x--;
Next_btn.Enabled = true;
ReaderText_tbx.Text = "";
List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" },
StringSplitOptions.RemoveEmptyEntries));
foreach (string str in list)
{
if (str.Contains("*"))
{
ReaderText_tbx.SelectionColor = Color.Maroon;
ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14);
}
else
{
ReaderText_tbx.SelectionColor = Color.Black;
}
ReaderText_tbx.AppendText(str.Replace("*", "") + "rn");
}
Title_lbl.Text = CurrPlaylist.Song[x].Title;
Artist_lbl.Text = CurrPlaylist.Song[x].Artist;
Album_lbl.Text = CurrPlaylist.Song[x].Album;
if (x == 0)
Prev_btn.Enabled = false;
}
private void SQL(string a)
{
con.Open();
query = a;
cmd = new SqlCommand(query, con);
returnVal = new SqlDataAdapter(query, con);
dt = new DataTable();
returnVal.Fill(dt);
con.Close();
}
}
}
MAIN FORM
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code
LIVE FORM

More Related Content

What's hot

Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingYury Chemerkin
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitTobias Pfeiffer
 
TDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hypeTDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hypetdc-globalcode
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181Mahmoud Samir Fayed
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutinesFreddie Wang
 
Python tutorial
Python tutorialPython tutorial
Python tutorialRajiv Risi
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPlotly
 
Palestra sobre Collections com Python
Palestra sobre Collections com PythonPalestra sobre Collections com Python
Palestra sobre Collections com Pythonpugpe
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークTsuyoshi Yamamoto
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012Shani729
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesOXUS 20
 

What's hot (20)

Gareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzingGareth hayes. non alphanumeric javascript-php and shared fuzzing
Gareth hayes. non alphanumeric javascript-php and shared fuzzing
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
Pdxpugday2010 pg90
Pdxpugday2010 pg90Pdxpugday2010 pg90
Pdxpugday2010 pg90
 
Elixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicitElixir & Phoenix – fast, concurrent and explicit
Elixir & Phoenix – fast, concurrent and explicit
 
TDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hypeTDC2016SP - Código funcional em Java: superando o hype
TDC2016SP - Código funcional em Java: superando o hype
 
What's new in C# 6?
What's new in C# 6?What's new in C# 6?
What's new in C# 6?
 
The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181The Ring programming language version 1.5.2 book - Part 45 of 181
The Ring programming language version 1.5.2 book - Part 45 of 181
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutines
 
Kotlin coroutines
Kotlin coroutines Kotlin coroutines
Kotlin coroutines
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Good Code
Good CodeGood Code
Good Code
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of Wrangling
 
The ABCs of OTP
The ABCs of OTPThe ABCs of OTP
The ABCs of OTP
 
Palestra sobre Collections com Python
Palestra sobre Collections com PythonPalestra sobre Collections com Python
Palestra sobre Collections com Python
 
Codes
CodesCodes
Codes
 
Groovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトークGroovy ネタ NGK 忘年会2009 ライトニングトーク
Groovy ネタ NGK 忘年会2009 ライトニングトーク
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 

Similar to FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code

Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6Moaid Hathot
 
Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#priya Nithya
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesNebojša Vukšić
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to GroovyAnton Arhipov
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaJevgeni Kabanov
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxDIPESH30
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfDEEPAKSONI562
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdfanandatalapatra
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesAbdul Rahman Sherzad
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfakshpatil4
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersSaeid Zebardast
 
Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec SpockCARA_Lyon
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 

Similar to FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code (20)

Best of build 2021 - C# 10 & .NET 6
Best of build 2021 -  C# 10 & .NET 6Best of build 2021 -  C# 10 & .NET 6
Best of build 2021 - C# 10 & .NET 6
 
Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#Creating a Name seperator Custom Control using C#
Creating a Name seperator Custom Control using C#
 
First few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examplesFirst few months with Kotlin - Introduction through android examples
First few months with Kotlin - Introduction through android examples
 
Dotnet 18
Dotnet 18Dotnet 18
Dotnet 18
 
Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
Groovy
GroovyGroovy
Groovy
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
Embedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for JavaEmbedded Typesafe Domain Specific Languages for Java
Embedded Typesafe Domain Specific Languages for Java
 
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docxlab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
lab08build.bat@echo offclsset DRIVE_LETTER=1s.docx
 
Team public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdfTeam public class Team {    private String teamId;    priva.pdf
Team public class Team {    private String teamId;    priva.pdf
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
 
can do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdfcan do this in java please thanks in advance The code that y.pdf
can do this in java please thanks in advance The code that y.pdf
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
 
Swing database(mysql)
Swing database(mysql)Swing database(mysql)
Swing database(mysql)
 
Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec Spock
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 

More from Педагошко друштво информатичара Србије

More from Педагошко друштво информатичара Србије (20)

Takmicenje Dabar 2017 Agenda 18-02-2016 Nis
Takmicenje Dabar 2017 Agenda 18-02-2016 NisTakmicenje Dabar 2017 Agenda 18-02-2016 Nis
Takmicenje Dabar 2017 Agenda 18-02-2016 Nis
 
Forum naprednih tehnologija 2016 - Agenda
Forum naprednih tehnologija 2016 - AgendaForum naprednih tehnologija 2016 - Agenda
Forum naprednih tehnologija 2016 - Agenda
 
FNT 2016 Agenda
FNT 2016 AgendaFNT 2016 Agenda
FNT 2016 Agenda
 
Takmicenje Infomanija 2016 Poziv
Takmicenje Infomanija 2016 PozivTakmicenje Infomanija 2016 Poziv
Takmicenje Infomanija 2016 Poziv
 
EPA Konferencija - zakljicc 2016-02-24
EPA Konferencija - zakljicc 2016-02-24EPA Konferencija - zakljicc 2016-02-24
EPA Konferencija - zakljicc 2016-02-24
 
PDIS pismo podrske 2016-03-24
PDIS pismo podrske 2016-03-24PDIS pismo podrske 2016-03-24
PDIS pismo podrske 2016-03-24
 
Slobodan softver 2016 - Zbornik radova 30.01.2016.
Slobodan softver 2016 - Zbornik radova 30.01.2016.Slobodan softver 2016 - Zbornik radova 30.01.2016.
Slobodan softver 2016 - Zbornik radova 30.01.2016.
 
Onlajn nedelja 2016 saopstenje za javnost
Onlajn nedelja 2016 saopstenje za javnostOnlajn nedelja 2016 saopstenje za javnost
Onlajn nedelja 2016 saopstenje za javnost
 
Zbornik radova UPIS 2016
Zbornik radova UPIS 2016Zbornik radova UPIS 2016
Zbornik radova UPIS 2016
 
OA 2016 Uputstvo Oracle Academy
OA 2016 Uputstvo Oracle AcademyOA 2016 Uputstvo Oracle Academy
OA 2016 Uputstvo Oracle Academy
 
Forum mladih naucnika 2016 satnica
Forum mladih naucnika 2016 satnicaForum mladih naucnika 2016 satnica
Forum mladih naucnika 2016 satnica
 
Epa konferencija 2016_agenda_160224
Epa konferencija 2016_agenda_160224Epa konferencija 2016_agenda_160224
Epa konferencija 2016_agenda_160224
 
FNT 2015 Panel 2 1 Visoko obrazovanje - Prof dr Dragan Jankovic
FNT 2015 Panel 2 1 Visoko obrazovanje - Prof dr Dragan JankovicFNT 2015 Panel 2 1 Visoko obrazovanje - Prof dr Dragan Jankovic
FNT 2015 Panel 2 1 Visoko obrazovanje - Prof dr Dragan Jankovic
 
FNT 2015 Panel 2 4 Potencijali privrede - Goran Mladenovic
FNT 2015 Panel 2 4 Potencijali privrede - Goran MladenovicFNT 2015 Panel 2 4 Potencijali privrede - Goran Mladenovic
FNT 2015 Panel 2 4 Potencijali privrede - Goran Mladenovic
 
FNT 2015 Panel 2 2 Visoko strucno obrazovanje - dr Dejan Blagojevic
FNT 2015 Panel 2 2 Visoko strucno obrazovanje - dr Dejan BlagojevicFNT 2015 Panel 2 2 Visoko strucno obrazovanje - dr Dejan Blagojevic
FNT 2015 Panel 2 2 Visoko strucno obrazovanje - dr Dejan Blagojevic
 
FNT 2015 Panel 2 3 - Srednjoskolsko obrazovanje - Dragan Ilic
FNT 2015 Panel 2 3 - Srednjoskolsko obrazovanje - Dragan IlicFNT 2015 Panel 2 3 - Srednjoskolsko obrazovanje - Dragan Ilic
FNT 2015 Panel 2 3 - Srednjoskolsko obrazovanje - Dragan Ilic
 
FNT 2015 Panel 2 5 Primeri dobre prakse ICT - Feniks BB - Bratislav Blagojevic
FNT 2015 Panel 2 5 Primeri dobre prakse ICT - Feniks BB - Bratislav BlagojevicFNT 2015 Panel 2 5 Primeri dobre prakse ICT - Feniks BB - Bratislav Blagojevic
FNT 2015 Panel 2 5 Primeri dobre prakse ICT - Feniks BB - Bratislav Blagojevic
 
FNT 2015 Panel 2 7 Olimpijski tim - Ivan Stosic
FNT 2015 Panel 2 7 Olimpijski tim - Ivan StosicFNT 2015 Panel 2 7 Olimpijski tim - Ivan Stosic
FNT 2015 Panel 2 7 Olimpijski tim - Ivan Stosic
 
FNT 2015 Panel 2 6 Primeri dobre prakse ICT - Atomia i Troxo
FNT 2015 Panel 2 6 Primeri dobre prakse ICT - Atomia i TroxoFNT 2015 Panel 2 6 Primeri dobre prakse ICT - Atomia i Troxo
FNT 2015 Panel 2 6 Primeri dobre prakse ICT - Atomia i Troxo
 
Forum naprednih tehnologija - Oni su deo budućnosti
Forum naprednih tehnologija - Oni su deo budućnosti Forum naprednih tehnologija - Oni su deo budućnosti
Forum naprednih tehnologija - Oni su deo budućnosti
 

Recently uploaded

CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17Celine George
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptxSandy Millin
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxraviapr7
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...Nguyen Thanh Tu Collection
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxKatherine Villaluna
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptxraviapr7
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfMohonDas
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesMohammad Hassany
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 

Recently uploaded (20)

CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17How to Use api.constrains ( ) in Odoo 17
How to Use api.constrains ( ) in Odoo 17
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
2024.03.23 What do successful readers do - Sandy Millin for PARK.pptx
 
Education and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptxEducation and training program in the hospital APR.pptx
Education and training program in the hospital APR.pptx
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
CHUYÊN ĐỀ DẠY THÊM TIẾNG ANH LỚP 11 - GLOBAL SUCCESS - NĂM HỌC 2023-2024 - HK...
 
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptxPractical Research 1: Lesson 8 Writing the Thesis Statement.pptx
Practical Research 1: Lesson 8 Writing the Thesis Statement.pptx
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptxClinical Pharmacy  Introduction to Clinical Pharmacy, Concept of clinical pptx
Clinical Pharmacy Introduction to Clinical Pharmacy, Concept of clinical pptx
 
Prelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quizPrelims of Kant get Marx 2.0: a general politics quiz
Prelims of Kant get Marx 2.0: a general politics quiz
 
HED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdfHED Office Sohayok Exam Question Solution 2023.pdf
HED Office Sohayok Exam Question Solution 2023.pdf
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Human-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming ClassesHuman-AI Co-Creation of Worked Examples for Programming Classes
Human-AI Co-Creation of Worked Examples for Programming Classes
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 

FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_chord_player2 - Code

  • 1. Classes using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chord_Reader.NewClasses { class Playlist { public int PlaylistID { get; set; } public string Title { get; set; } public List<Song> Song { get; set; } public string Username { get; set; } public Playlist(int playlistID, string title,string username) { PlaylistID = playlistID; Title = title; Username = username; Song = new List<Song>(); } public Playlist() { Song = new List<Song>(); } public void AddSong(Song song) { Song.Add(song); } public void MoveSongUp(int i) { if (i > 0) { Song s = Song[i]; Song[i] = Song[i - 1]; Song[i - 1] = s; } } public void MoveSongDown(int i) { if (i > 0 && i < Song.Count) { Song s = Song[i]; Song[i] = Song[i + 1]; Song[i + 1] = s; } } } }
  • 2. using Chord_Reader.NewClasses; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chord_Reader.NewClasses { class Song { public int SongID { get; set; } public string Title { get; set; } public string Artist { get; set; } public string Album { get; set; } public string Genre { get; set; } public string Text { get; set; } public string Mode { get; set; } public string KeyOf { get; set; } public string Username { get; set; } public int Trans { get; set; } public Song(int songID, string title, string artist, string album, string genre, string text, string keyOf, string mode, string username) { SongID = songID; Title = title; Artist = artist; Album = album; Genre = genre; Text = text; Mode = mode; KeyOf = keyOf; Username = username; Trans = 0; } public void Transpose(bool a) { if (a == false) { Text = Text.Replace("*B*", "+A#+"); Text = Text.Replace("*A#*", "+A+"); Text = Text.Replace("*A*", "+G#+"); Text = Text.Replace("*G#*", "+G+"); Text = Text.Replace("*G*", "+F#+"); Text = Text.Replace("*F#*", "+F+"); Text = Text.Replace("*F*", "+E+"); Text = Text.Replace("*E*", "+D#+"); Text = Text.Replace("*D#*", "+D+"); Text = Text.Replace("*D*", "+C#+"); Text = Text.Replace("*C#*", "+C+"); Text = Text.Replace("*C*", "+B+"); Text = Text.Replace("+", "*"); KeyOf = KeyOf.Replace("*B*", "+A#+"); KeyOf = KeyOf.Replace("*A#*", "+A+"); KeyOf = KeyOf.Replace("*A*", "+G#+"); KeyOf = KeyOf.Replace("*G#*", "+G+"); KeyOf = KeyOf.Replace("*G*", "+F#+"); KeyOf = KeyOf.Replace("*F#*", "+F+"); KeyOf = KeyOf.Replace("*F*", "+E+"); KeyOf = KeyOf.Replace("*E*", "+D#+"); KeyOf = KeyOf.Replace("*D#*", "+D+"); KeyOf = KeyOf.Replace("*D*", "+C#+"); KeyOf = KeyOf.Replace("*C#*", "+C+"); KeyOf = KeyOf.Replace("*C*", "+B+"); KeyOf = KeyOf.Replace("*Bm*", "+A#m+"); KeyOf = KeyOf.Replace("*A#m*", "+Am+"); KeyOf = KeyOf.Replace("*Am*", "+G#m+"); KeyOf = KeyOf.Replace("*G#m*", "+Gm+"); KeyOf = KeyOf.Replace("*Gm*", "+F#m+"); KeyOf = KeyOf.Replace("*F#m*", "+Fm+"); KeyOf = KeyOf.Replace("*Fm*", "+Em+"); KeyOf = KeyOf.Replace("*Em*", "+D#m+"); KeyOf = KeyOf.Replace("*D#*", "+Dm+"); KeyOf = KeyOf.Replace("*Dm*", "+C#m+");
  • 3. KeyOf = KeyOf.Replace("*C#m*", "+Cm+"); KeyOf = KeyOf.Replace("*Cm*", "+Bm+"); KeyOf = KeyOf.Replace("+", "*"); if (Trans == -5) Trans = 6; else Trans--; } else { Text = Text.Replace("*B*", "+C+"); Text = Text.Replace("*A#*", "+B+"); Text = Text.Replace("*A*", "+A#+"); Text = Text.Replace("*G#*", "+A+"); Text = Text.Replace("*G*", "+G#+"); Text = Text.Replace("*F#*", "+G+"); Text = Text.Replace("*F*", "+F#+"); Text = Text.Replace("*E*", "+F+"); Text = Text.Replace("*D#*", "+E+"); Text = Text.Replace("*D*", "+D#+"); Text = Text.Replace("*C#*", "+D+"); Text = Text.Replace("*C*", "+C#+"); Text = Text.Replace("+", "*"); KeyOf = KeyOf.Replace("*B*", "+C+"); KeyOf = KeyOf.Replace("*A#*", "+B+"); KeyOf = KeyOf.Replace("*A*", "+A#+"); KeyOf = KeyOf.Replace("*G#*", "+A+"); KeyOf = KeyOf.Replace("*G*", "+G#+"); KeyOf = KeyOf.Replace("*F#*", "+G+"); KeyOf = KeyOf.Replace("*F*", "+F#+"); KeyOf = KeyOf.Replace("*E*", "+F+"); KeyOf = KeyOf.Replace("*D#*", "+E+"); KeyOf = KeyOf.Replace("*D*", "+D#+"); KeyOf = KeyOf.Replace("*C#*", "+D+"); KeyOf = KeyOf.Replace("*C*", "+C#+"); KeyOf = KeyOf.Replace("*Bm*", "+Cm+"); KeyOf = KeyOf.Replace("*A#m*", "+Bm+"); KeyOf = KeyOf.Replace("*Am*", "+A#m+"); KeyOf = KeyOf.Replace("*G#m*", "+Am+"); KeyOf = KeyOf.Replace("*Gm*", "+G#m+"); KeyOf = KeyOf.Replace("*F#m*", "+Gm+"); KeyOf = KeyOf.Replace("*Fm*", "+F#m+"); KeyOf = KeyOf.Replace("*Em*", "+Fm+"); KeyOf = KeyOf.Replace("*D#m*", "+Em+"); KeyOf = KeyOf.Replace("*Dm*", "+D#m+"); KeyOf = KeyOf.Replace("*C#m*", "+Dm+"); KeyOf = KeyOf.Replace("*Cm*", "+C#m+"); KeyOf = KeyOf.Replace("+", "*"); if (Trans == 6) Trans = -5; else Trans++; } } } }
  • 4. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Chord_Reader.NewClasses { class User { public int UserID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Username { get; set; } public string Email { get; set; } public string Password { get; set; } public User(int userID, string firstName, string lastName, string username, string email, string password) { UserID = userID; FirstName = firstName; LastName = lastName; Username = username; Email = email; Password = password; } } }
  • 5. MAIN FORM using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DevComponents.DotNetBar; using System.Data.SqlClient; using Chord_Reader.NewClasses; using Chord_Reader.Properties; namespace Chord_Reader { public partial class Main_form : OfficeForm { public Main_form() { InitializeComponent(); } #region SQL Declare SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; AttachDbFilename=C:ProgramDataLiveChordPlayerChordLivePlayer.mdf; Connect Timeout=30; User Instance=True; integrated security=true"); SqlDataAdapter returnVal; DataTable dt; SqlCommand cmd; string query; #endregion #region Object Declare List<Song> songs = new List<Song>(); List<Song> plSongs = new List<Song>(); List<Playlist> playlists = new List<Playlist>(); User CurrentUser; #endregion #region LOAD private void Main_form_Load(object sender, EventArgs e) { SQL("SELECT * FROM Songs"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { songs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(), d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString())); ReaderList_lbx.Items.Add(d[1].ToString()); } } SQL("SELECT * FROM PlSongs"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { plSongs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(), d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString())); } } SQL("SELECT * FROM Playlists"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { playlists.Add(new Playlist(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString())); } foreach (Playlist p in playlists) { SelectPlaylist_cbx.Items.Add(p.Title); Playlist_lbx.Items.Add(p.Title); SQL("SELECT songID FROM Songlists WHERE playlistID='" + p.PlaylistID.ToString() + "' ORDER BY orderID"); if (dt.Rows.Count != 0)
  • 6. { foreach (DataRow d in dt.Rows) { foreach (Song s in plSongs) { if (s.SongID == Int32.Parse(d[0].ToString())) { p.AddSong(s); } } } } } } } #endregion #region ACCOUNT private void SignUp_btn_Click(object sender, EventArgs e) { if (SPassword_tbx.Text == RePassword_tbx.Text) { SQL("SELECT * FROM Users WHERE username='" + SUsername_tbx.Text + "' OR email='" + Email_tbx.Text + "'"); if (dt.Rows.Count != 0) { MessageBox.Show("Username od Email already exists!"); SUsername_tbx.Text = ""; Email_tbx.Text = ""; SPassword_tbx.Text = ""; RePassword_tbx.Text = ""; } else { SQL("INSERT INTO Users(fName, lName, username, email, password) VALUES('" + FName_tbx.Text + "', '" + LName_tbx.Text + "', '" + SUsername_tbx.Text + "', '" + Email_tbx.Text + "', '" + SPassword_tbx.Text + "')"); MessageBox.Show("Account Created!"); SQL("SELECT * FROM Users WHERE username='" + SUsername_tbx.Text + "' AND password='" + SPassword_tbx.Text + "'"); CurrentUser = new User(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString()); FName_tbx.Text = ""; LName_tbx.Text = ""; SUsername_tbx.Text = ""; Email_tbx.Text = ""; SPassword_tbx.Text = ""; RePassword_tbx.Text = ""; FName_lbl.Text = " <b>" + CurrentUser.FirstName + "</b>"; LName_lbl.Text = " <b>" + CurrentUser.LastName + "</b>"; Username_lbl.Text = " <b>" + CurrentUser.Username + "</b>"; Email_lbl.Text = " <b>" + CurrentUser.Email + "</b>"; panelEx2.Visible = true; panelEx1.Visible = false; Writer_tab.Enabled = true; Live_tab.Enabled = true; AddLive_btn.Enabled = true; SelectPlaylist_cbx.Enabled = true; this.Text += " - " + CurrentUser.Username; } } else { MessageBox.Show("Passwords doesn't match! Try Again!"); SPassword_tbx.Text = ""; RePassword_tbx.Text = ""; } } private void LogIn_btn_Click(object sender, EventArgs e) { SQL("SELECT * FROM Users WHERE username='" + Username_tbx.Text + "' AND password='" + Password_tbx.Text + "'"); if (dt.Rows.Count != 0) { CurrentUser = new User(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString()); Username_tbx.Text = ""; Password_tbx.Text = "";
  • 7. FName_lbl.Text = " <b>" + CurrentUser.FirstName + "</b>"; LName_lbl.Text = " <b>" + CurrentUser.LastName + "</b>"; Username_lbl.Text = " <b>" + CurrentUser.Username + "</b>"; Email_lbl.Text = " <b>" + CurrentUser.Email + "</b>"; panelEx2.Visible = true; panelEx1.Visible = false; Writer_tab.Enabled = true; Live_tab.Enabled = true; AddLive_btn.Enabled = true; SelectPlaylist_cbx.Enabled = true; this.Text += " - " + CurrentUser.Username; } else { MessageBox.Show("Username or Password is invalid!"); } } #endregion #region WRITER private void WriterSave_btn_Click(object sender, EventArgs e) { if (Title_tbx.Text != "" && Artist_tbx.Text != "" && Genre_cbx.Text != "" && WriterText_tbx.Text != "" && KeyOf_cbx.Text != "") { SQL("SELECT * FROM Songs WHERE title='" + Title_tbx.Text + "'"); if (dt.Rows.Count != 0) { MessageBox.Show("Song already exists!"); Title_tbx.Text = ""; Artist_tbx.Text = ""; Genre_cbx.Text = ""; Album_tbx.Text = ""; KeyOf_cbx.Text = ""; WriterText_tbx.Text = ""; } else { SQL("INSERT INTO Songs(title, artist, album, genre, text, keyOf, mode, username) VALUES('" + Title_tbx.Text + "', '" + Artist_tbx.Text + "', '" + Album_tbx.Text + "', '" + Genre_cbx.Text + "', '" + WriterText_tbx.Text + "', '*" + KeyOf_cbx.Text + "*', '" + ReaderMode_swbtn.Value.ToString() + "', '" + CurrentUser.Username + "')"); MessageBox.Show("Song Created!"); SQL("SELECT * FROM Songs WHERE title='" + Title_tbx.Text + "'"); songs.Add(new Song(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), dt.Rows[0][4].ToString(), dt.Rows[0][5].ToString(), dt.Rows[0][6].ToString(), dt.Rows[0][7].ToString(), dt.Rows[0][8].ToString())); ReaderList_lbx.Items.Add(dt.Rows[0][1].ToString()); Title_tbx.Text = ""; Artist_tbx.Text = ""; Genre_cbx.Text = ""; Album_tbx.Text = ""; KeyOf_cbx.Text = ""; WriterText_tbx.Text = ""; } } else { MessageBox.Show("Fill all fields!"); } } private void WriterDiscard_btn_Click(object sender, EventArgs e) { Title_tbx.Text = ""; Artist_tbx.Text = ""; Genre_cbx.Text = ""; Album_tbx.Text = ""; KeyOf_cbx.Text = ""; WriterText_tbx.Text = ""; MessageBox.Show("You have just discarded your song!"); } #endregion #region READER private void ReaderList_lbx_SelectedIndexChanged(object sender, EventArgs e) {
  • 8. Main_pnl.Visible = true; foreach (Song s in songs) { if (ReaderList_lbx.SelectedItems.Count > 0) { if (s.Title == ReaderList_lbx.SelectedItems[0].Text) { ReaderText_tbx.Text = ""; List<string> list = new List<string>(s.Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach(string str in list) { if (str.Contains("*")) { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } TransMinus_btn.Enabled = true; TransPlus_btn.Enabled = true; Trans_lbl.Enabled = true; if (s.Trans > 0) Trans_lbl.Text = "+" + s.Trans.ToString(); else Trans_lbl.Text = s.Trans.ToString(); Title_lbl.Text = s.Title; Album_lbl.Text = "Album: " + s.Album; KeyOf_lbl.Text = s.KeyOf.Replace("*", ""); Artist_lbl.Text = s.Artist; CreatedBy_lbl.Text = "Created by: " + s.Username; } } } } private void AddLive_btn_Click(object sender, EventArgs e) { if (SelectPlaylist_cbx.Text != "") { foreach (Song s in songs) { foreach (Playlist p in playlists) { if (ReaderList_lbx.SelectedItems.Count > 0) { if (s.Title == ReaderList_lbx.SelectedItems[0].Text && p.Title == SelectPlaylist_cbx.Text) { if (string.Compare(p.Username, CurrentUser.Username) == -1) { SQL("INSERT INTO PlSongs(title, artist, album, genre, text, keyOf, mode, username) VALUES('" + s.Title + "', '" + s.Artist + "', '" + s.Album + "', '" + s.Genre + "', '" + s.Text + "', '" + s.KeyOf + "', 'False', '" + CurrentUser.Username + "')"); SQL("SELECT * FROM Songlists WHERE songID=" + s.SongID.ToString() + " AND playlistID='" + p.PlaylistID.ToString() + "'"); if (dt.Rows.Count != 0) { MessageBox.Show("Song is already in this playlist!"); } else { SQL("SELECT songID FROM PlSongs WHERE title='" + s.Title + "' AND username='" + CurrentUser.Username + "'"); p.AddSong(s); int z = Int32.Parse(dt.Rows[0][0].ToString()); SQL("INSERT INTO Songlists(songID, playlistID, orderID) VALUES('" + z + "', '" + p.PlaylistID + "', '" + p.Song.Count + "')"); MessageBox.Show("Song Added!"); } } else MessageBox.Show("You are not allowed to add song to another user's playlist!"); }
  • 9. } } } } else MessageBox.Show("Select playlist to add song!"); } private void Search_tbx_TextChanged(object sender, EventArgs e) { string value = Search_tbx.Text.ToLower(); ReaderList_lbx.Items.Clear(); foreach (Song s in songs) { ReaderList_lbx.Items.Add(s.Title); } foreach (ListViewItem it in ReaderList_lbx.Items) { if (it.Text.ToLower().StartsWith(value) == false) { it.Remove(); } } } private void TransMinus_btn_Click(object sender, EventArgs e) { foreach (Song s in songs) { if (ReaderList_lbx.SelectedItems.Count > 0) { if (s.Title == ReaderList_lbx.SelectedItems[0].Text) { s.Transpose(false); string temp = s.KeyOf; KeyOf_lbl.Text = temp.Replace("*", ""); ReaderText_tbx.Text = ""; List<string> list = new List<string>(s.Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string str in list) { if (str.Contains("*")) { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } if (s.Trans > 0) Trans_lbl.Text = "+" + s.Trans.ToString(); else Trans_lbl.Text = s.Trans.ToString(); } } } } private void TransPlus_btn_Click(object sender, EventArgs e) { foreach (Song s in songs) { if (ReaderList_lbx.SelectedItems.Count > 0) { if (s.Title == ReaderList_lbx.SelectedItems[0].Text) { s.Transpose(true); string temp = s.KeyOf; KeyOf_lbl.Text = temp.Replace("*", ""); ReaderText_tbx.Text = ""; List<string> list = new List<string>(s.Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string str in list) { if (str.Contains("*"))
  • 10. { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 12); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } if (s.Trans > 0) Trans_lbl.Text = "+" + s.Trans.ToString(); else Trans_lbl.Text = s.Trans.ToString(); } } } } #endregion #region LIVE PLAYER private void NewPlaylist_btn_Click(object sender, EventArgs e) { if (PlaylistTitle_tbx.Text != "") { SQL("SELECT * FROM Playlists WHERE title='" + Title_tbx.Text + "'"); if (dt.Rows.Count != 0) { MessageBox.Show("Playlists already exists!"); } else { SQL("INSERT INTO Playlists(title, username) VALUES('" + PlaylistTitle_tbx.Text + "', '" + CurrentUser.Username + "')"); MessageBox.Show("Playlist Created!"); SQL("SELECT * FROM Playlists WHERE title='" + PlaylistTitle_tbx.Text + "'"); playlists.Add(new Playlist(Int32.Parse(dt.Rows[0][0].ToString()), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString())); int plNum = playlists.Count(); SelectPlaylist_cbx.Items.Add(playlists[plNum - 1].Title); Playlist_lbx.Items.Add(playlists[plNum - 1].Title); PlaylistTitle_tbx.Text = ""; } } else { MessageBox.Show("Fill all fields!"); } } private void Playlist_lbx_SelectedIndexChanged(object sender, EventArgs e) { if (Playlist_lbx.SelectedItems.Count > 0) { foreach (Playlist p in playlists) { if (p.Title == Playlist_lbx.SelectedItems[0].Text) { PlaylistSong_lbx.Enabled = true; PlaylistSong_lbx.Clear(); PlaylistTitle_lbx.Text = p.Title; foreach (Song s in p.Song) { PlaylistSong_lbx.Items.Add(s.Title); } } } } } private void SearchPlaylist_tbx_TextChanged(object sender, EventArgs e) { string value = SearchPlaylist_tbx.Text.ToLower(); Playlist_lbx.Items.Clear(); foreach (Playlist p in playlists) { Playlist_lbx.Items.Add(p.Title); }
  • 11. foreach (ListViewItem it in Playlist_lbx.Items) { if (it.Text.ToLower().StartsWith(value) == false) { it.Remove(); } } } private void Play_btn_Click(object sender, EventArgs e) { if (Playlist_lbx.SelectedItems.Count > 0) { foreach (Playlist p in playlists) { if (p.Title == Playlist_lbx.SelectedItems[0].Text) { Live f = new Live(p.PlaylistID); f.WindowState = FormWindowState.Maximized; f.ShowDialog(); } } } else MessageBox.Show("Chose Playlist you want to play!"); } #endregion private void SQL(string a) { con.Open(); query = a; cmd = new SqlCommand(query, con); returnVal = new SqlDataAdapter(query, con); dt = new DataTable(); returnVal.Fill(dt); con.Close(); } } }
  • 12. Live Form using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DevComponents.DotNetBar; using System.Data.SqlClient; using Chord_Reader.NewClasses; using Chord_Reader.Properties; namespace Chord_Reader { public partial class Live : OfficeForm { int id; public Live(int ID) { InitializeComponent(); id = ID; } #region Object Declare Playlist CurrPlaylist; List<Song> songs = new List<Song>(); int x = 0; #endregion #region SQL Declare SqlConnection con = new SqlConnection("Data Source=.SQLEXPRESS; AttachDbFilename=C:ProgramDataLiveChordPlayerChordLivePlayer.mdf; Connect Timeout=30; User Instance=True; integrated security=true"); SqlDataAdapter returnVal; DataTable dt; SqlCommand cmd; string query; #endregion private void Live_Load(object sender, EventArgs e) { SQL("SELECT * FROM PlSongs"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { songs.Add(new Song(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString(), d[3].ToString(), d[4].ToString(), d[5].ToString(), d[6].ToString(), d[7].ToString(), d[8].ToString())); } } SQL("SELECT * FROM Playlists WHERE playlistID='" + id + "'"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { CurrPlaylist = new Playlist(Int32.Parse(d[0].ToString()), d[1].ToString(), d[2].ToString()); } SQL("SELECT songID FROM Songlists WHERE playlistID='" + CurrPlaylist.PlaylistID.ToString() + "' ORDER BY orderID"); if (dt.Rows.Count != 0) { foreach (DataRow d in dt.Rows) { foreach (Song s in songs) { if (s.SongID == Int32.Parse(d[0].ToString())) { CurrPlaylist.AddSong(s); } } } } }
  • 13. List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string str in list) { if (str.Contains("*")) { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } Title_lbl.Text = CurrPlaylist.Song[0].Title; Artist_lbl.Text = CurrPlaylist.Song[0].Artist; Album_lbl.Text = CurrPlaylist.Song[0].Album; PlaylistTitle_lbl.Text = CurrPlaylist.Title; } private void Live_SizeChanged(object sender, EventArgs e) { this.WindowState = FormWindowState.Maximized; } private void Next_btn_Click(object sender, EventArgs e) { x++; Prev_btn.Enabled = true; ReaderText_tbx.Text = ""; List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string str in list) { if (str.Contains("*")) { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } Title_lbl.Text = CurrPlaylist.Song[x].Title; Artist_lbl.Text = CurrPlaylist.Song[x].Artist; Album_lbl.Text = CurrPlaylist.Song[x].Album; if (x == CurrPlaylist.Song.Count -1) Next_btn.Enabled = false; } private void Prev_btn_Click(object sender, EventArgs e) { x--; Next_btn.Enabled = true; ReaderText_tbx.Text = ""; List<string> list = new List<string>(CurrPlaylist.Song[x].Text.Split(new string[] { "rn" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string str in list) { if (str.Contains("*")) { ReaderText_tbx.SelectionColor = Color.Maroon; ReaderText_tbx.SelectionFont = new System.Drawing.Font("Arial Rounded MT Bold", 14); } else { ReaderText_tbx.SelectionColor = Color.Black; } ReaderText_tbx.AppendText(str.Replace("*", "") + "rn"); } Title_lbl.Text = CurrPlaylist.Song[x].Title; Artist_lbl.Text = CurrPlaylist.Song[x].Artist; Album_lbl.Text = CurrPlaylist.Song[x].Album; if (x == 0) Prev_btn.Enabled = false;
  • 14. } private void SQL(string a) { con.Open(); query = a; cmd = new SqlCommand(query, con); returnVal = new SqlDataAdapter(query, con); dt = new DataTable(); returnVal.Fill(dt); con.Close(); } } }