/// <summary> /// Handles the CheckedChanged event of the chkMusician control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void chkMusician_CheckedChanged(object sender, EventArgs e) { if (this.chkMusician.Checked) { this._startSearch = false; this.chkActor.Checked = false; this.chkDirector.Checked = false; this.chkProducer.Checked = false; //this.chkMusician.Checked = false; this.chkCameraman.Checked = false; this.chkCutter.Checked = false; this.chkWriter.Checked = false; this._startSearch = true; if (this._startSearch) { //this._LoadData(MovieObjectType.Producer, ""); this._searchType = MovieObjectType.Musician; this._searchName = ""; this._searchTimer.Interval = 1; this._searchTimer.Start(); } } else { if (this._startSearch) { //this._LoadData(MovieObjectType.All, ""); this._searchType = MovieObjectType.All; this._searchName = ""; this._searchTimer.Interval = 1; this._searchTimer.Start(); } } }
/// <summary> /// Default Ctor /// </summary> /// <param name="mot"></param> public AddItemForm(MovieObjectType mot) { InitializeComponent(); this.DialogResult = DialogResult.Cancel; this._mot = mot; switch(this._mot) { case MovieObjectType.Actor: this.gbActor.Visible = true; this.lvItems.Height = 240; break; default: this.gbActor.Visible = false; this.lvItems.Height = 323; break; } this._LoadData(); }
/// <summary> /// Default Ctor /// </summary> /// <param name="mot"></param> public AddItemForm(MovieObjectType mot) { InitializeComponent(); this.DialogResult = DialogResult.Cancel; this._mot = mot; switch (this._mot) { case MovieObjectType.Actor: this.gbActor.Visible = true; this.lvItems.Height = 240; break; default: this.gbActor.Visible = false; this.lvItems.Height = 323; break; } this._LoadData(); }
/// <summary> /// Check if a object is also in list /// </summary> /// <param name="mot"></param> /// <param name="id"></param> /// <returns></returns> private bool _ObjectIsInListView(MovieObjectType mot, string id) { switch(mot) { case MovieObjectType.Genre: foreach(ListViewItem lvi in this.lvGenre.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Category: foreach(ListViewItem lvi in this.lvCategories.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Actor: foreach(ListViewItem lvi in this.lvActors.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Director: foreach(ListViewItem lvi in this.lvDirectors.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Producer: foreach(ListViewItem lvi in this.lvProducers.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Musician: foreach(ListViewItem lvi in this.lvMusician.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Cameraman: foreach(ListViewItem lvi in this.lvCameraman.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Cutter: foreach(ListViewItem lvi in this.lvCutter.Items) { if(lvi.Name == id) { return true; } } break; case MovieObjectType.Writer: foreach(ListViewItem lvi in this.lvWriters.Items) { if(lvi.Name == id) { return true; } } break; } return false; }
/// <summary> /// Get the index of a object in the movie list /// </summary> /// <param name="mot"></param> /// <param name="id"></param> /// <returns></returns> public int _GetObjectIndexFromMovieList(MovieObjectType mot, string id) { int index = 0; switch(mot) { case MovieObjectType.Genre: foreach(Genre g in this._mov.Genres) { if(g.ID == id) { return index; } index++; } break; case MovieObjectType.Category: foreach(Category c in this._mov.Categories) { if(c.ID == id) { return index; } index++; } break; case MovieObjectType.Actor: foreach(Person p in this._mov.Actors) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Director: foreach(Person p in this._mov.Directors) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Producer: foreach(Person p in this._mov.Producers) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Musician: foreach(Person p in this._mov.Musicians) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Cameraman: foreach(Person p in this._mov.Cameramans) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Cutter: foreach(Person p in this._mov.Cutters) { if(p.ID == id) { return index; } index++; } break; case MovieObjectType.Writer: foreach(Person p in this._mov.Writers) { if(p.ID == id) { return index; } index++; } break; } return index; }
/// <summary> /// Loadings the init. /// </summary> private void _LoadingInit() { if (!this.chkActor.Checked && !this.chkDirector.Checked && !this.chkProducer.Checked) { //this._LoadData( // MovieObjectType.All, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.All; } else { if (this.chkActor.Checked) { //this._LoadData( // MovieObjectType.Actor, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Actor; } else if (this.chkDirector.Checked) { //this._LoadData( // MovieObjectType.Director, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Director; } else if (this.chkProducer.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Producer; } else if (this.chkMusician.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Musician; } else if (this.chkCameraman.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Cameraman; } else if (this.chkCutter.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Cutter; } else if (this.chkWriter.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Writer; } else { //this._LoadData( // MovieObjectType.All, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.All; } } this._searchName = this.txtName.Text.Trim(); int intervall = 1; if (this._searchName.Length == 0) { intervall = 1; } else if (this._searchName.Length < 2) { intervall = 1000; } else if (this._searchName.Length < 4) { intervall = 750; } else if (this._searchName.Length < 6) { intervall = 500; } else if (this._searchName.Length < 8) { intervall = 250; } else if (this._searchName.Length < 10) { intervall = 100; } else { intervall = 1; } this._searchTimer.Interval = intervall; this._searchTimer.Start(); }
/// <summary> /// Load the data /// </summary> /// <param name="mot">The mot.</param> /// <param name="name">The name.</param> private void _LoadData(MovieObjectType mot, string name) { if (this.dgvPersons.InvokeRequired) { LoadDataCallback ldCall = new LoadDataCallback(_LoadData); this.Invoke(ldCall, new object[] { mot, name }); } else { this.Cursor = Cursors.WaitCursor; if (__useDataBind) { this.dgvPersons.DataSource = null; } else { this.dgvPersons.Rows.Clear(); } name = name.Replace("'", "´"); List <Person> list = this._db.GetPersonList( mot, name, this._sortExpression, (this._sortDirection == ListSortDirection.Ascending ? DataSortDirection.Ascending : DataSortDirection.Descending) ); //PersonCollection list = this._db.GetPersonList(mot, name); //list.Sort((IComparer<Person>)new Person.SortByFirstname()); this._currentAmount = list.Count; int count = 0; if (__useDataBind) { this.dgvPersons.AutoGenerateColumns = false; this.dgvPersons.DataSource = list; } else { foreach (Person p in list) { this.dgvPersons.Rows.Add(1); this.dgvPersons.Rows[count].Cells[0].Value = p.ID; this.dgvPersons.Rows[count].Cells[1].Value = p.Firstname + " " + p.Lastname; this.dgvPersons.Rows[count].Cells[2].Value = p.IsActor; this.dgvPersons.Rows[count].Cells[3].Value = p.IsDirector; this.dgvPersons.Rows[count].Cells[4].Value = p.IsProducer; this.dgvPersons.Rows[count].Cells[4].Value = p.IsMusician; this.dgvPersons.Rows[count].Cells[4].Value = p.IsCameraman; this.dgvPersons.Rows[count].Cells[4].Value = p.IsCutter; this.dgvPersons.Rows[count].Cells[4].Value = p.IsWriter; this.dgvPersons.Rows[count].Cells[5].Value = p.MovieQuantity; this.dgvPersons.Rows[count].Cells[6].Value = p.MovieQuantityAsActor; this.dgvPersons.Rows[count].Cells[7].Value = p.MovieQuantityAsDirector; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsProducer; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsMusician; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsCameraman; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsCutter; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsWriter; count++; } this.dgvPersons.Sort(this.dgvPersons.Columns[1], ListSortDirection.Ascending); } this._current_amount = list.Count; this.lblFound.Text = this._current_amount.ToString(); this.Cursor = Cursors.Default; } }
/// <summary> /// Load the data /// </summary> /// <param name="mot">The mot.</param> /// <param name="name">The name.</param> private void _LoadData(MovieObjectType mot, string name) { if(this.dgvPersons.InvokeRequired) { LoadDataCallback ldCall = new LoadDataCallback(_LoadData); this.Invoke(ldCall, new object[] { mot, name }); } else { this.Cursor = Cursors.WaitCursor; if(__useDataBind) { this.dgvPersons.DataSource = null; } else { this.dgvPersons.Rows.Clear(); } name = name.Replace("'", "´"); List<Person> list = this._db.GetPersonList( mot, name, this._sortExpression, ( this._sortDirection == ListSortDirection.Ascending ? DataSortDirection.Ascending : DataSortDirection.Descending ) ); //PersonCollection list = this._db.GetPersonList(mot, name); //list.Sort((IComparer<Person>)new Person.SortByFirstname()); this._currentAmount = list.Count; int count = 0; if(__useDataBind) { this.dgvPersons.AutoGenerateColumns = false; this.dgvPersons.DataSource = list; } else { foreach(Person p in list) { this.dgvPersons.Rows.Add(1); this.dgvPersons.Rows[count].Cells[0].Value = p.ID; this.dgvPersons.Rows[count].Cells[1].Value = p.Firstname + " " + p.Lastname; this.dgvPersons.Rows[count].Cells[2].Value = p.IsActor; this.dgvPersons.Rows[count].Cells[3].Value = p.IsDirector; this.dgvPersons.Rows[count].Cells[4].Value = p.IsProducer; this.dgvPersons.Rows[count].Cells[4].Value = p.IsMusician; this.dgvPersons.Rows[count].Cells[4].Value = p.IsCameraman; this.dgvPersons.Rows[count].Cells[4].Value = p.IsCutter; this.dgvPersons.Rows[count].Cells[4].Value = p.IsWriter; this.dgvPersons.Rows[count].Cells[5].Value = p.MovieQuantity; this.dgvPersons.Rows[count].Cells[6].Value = p.MovieQuantityAsActor; this.dgvPersons.Rows[count].Cells[7].Value = p.MovieQuantityAsDirector; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsProducer; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsMusician; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsCameraman; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsCutter; this.dgvPersons.Rows[count].Cells[8].Value = p.MovieQuantityAsWriter; count++; } this.dgvPersons.Sort(this.dgvPersons.Columns[1], ListSortDirection.Ascending); } this._current_amount = list.Count; this.lblFound.Text = this._current_amount.ToString(); this.Cursor = Cursors.Default; } }
/// <summary> /// Check if a person exist /// </summary> /// <param name="firstname"></param> /// <param name="lastname"></param> /// <param name="mot"></param> /// <returns></returns> public bool CheckPersonExist(string firstname, string lastname, MovieObjectType mot) { bool ret = false; StringBuilder str = new StringBuilder(); str.Append("SELECT * "); str.Append(" FROM tbl_persons"); //str.Append(" WHERE firstname LIKE = '{" + firstname + "}')"); //str.Append(" AND lastname LIKE = '{" + lastname + "}')"); if(this._cfg.ProviderType != ProviderType.SQLite) { str.Append(" WHERE ("); str.Append(" (firstname LIKE '%" + firstname + "%'"); str.Append(" AND lastname LIKE '%" + lastname + "%')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + firstname + "}')"); str.Append(" OR (firstname + ' ' + lastname LIKE '%" + firstname + ' ' + lastname + "%')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + ' ' + firstname + "}')"); str.Append(" )"); } else { str.Append(" WHERE ("); str.Append(" (firstname LIKE '{" + firstname + "}'"); str.Append(" AND lastname LIKE '{" + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + firstname + "}')"); str.Append(" OR (firstname + ' ' + lastname LIKE '{" + firstname + ' ' + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + ' ' + firstname + "}')"); str.Append(" )"); } switch(mot) { case MovieObjectType.Genre: break; case MovieObjectType.Actor: str.Append(" AND is_actor = 1"); break; case MovieObjectType.Director: str.Append(" AND is_director = 1"); break; case MovieObjectType.Producer: str.Append(" AND is_producer = 1"); break; case MovieObjectType.Musician: str.Append(" AND is_musician = 1"); break; case MovieObjectType.Cameraman: str.Append(" AND is_cameraman = 1"); break; case MovieObjectType.Cutter: str.Append(" AND is_cutter = 1"); break; case MovieObjectType.Writer: str.Append(" AND is_writer = 1"); break; case MovieObjectType.All: break; } if(this._cfg.ProviderType == ProviderType.SQLite) { str = str.Replace(" = 1", " = 'True'"); } DataSet data = this._db.ExecuteQuery(str.ToString()); if(data.Tables[0].Rows.Count > 0) { ret = true; } else { ret = false; } return ret; }
/// <summary> /// Get a list of persons /// </summary> /// <param name="mot">The MovieObjectType.</param> /// <param name="name">The name.</param> /// <returns></returns> public List<Person> GetPersonList(MovieObjectType mot, string name, string sortExpression, DataSortDirection sortDirection) { List<Person> list = new List<Person>(); //PersonCollection list = new PersonCollection(); StringBuilder str = new StringBuilder(); str.Append("SELECT p.*, "); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_actor = 1"); str.Append(" ) AS actorQuantity,"); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_director = 1"); str.Append(" ) AS directorQuantity,"); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_producer = 1"); str.Append(" ) AS producerQuantity, "); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_musician = 1"); str.Append(" ) AS musicianQuantity, "); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_cameraman = 1"); str.Append(" ) AS cameramanQuantity, "); str.Append(" ("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_cutter = 1"); str.Append(" ) AS cutterQuantity, "); str.Append("("); str.Append(" SELECT CAST(COUNT(pkid) AS int)"); str.Append(" FROM tbl_movies_to_persons"); str.Append(" WHERE person_pkid = p.pkid"); str.Append(" AND as_writer = 1"); str.Append(" ) AS writerQuantity, "); str.Append("("); str.Append(" SELECT CAST(COUNT(DISTINCT movie_pkid) AS int) "); str.Append(" FROM tbl_movies_to_persons "); str.Append(" WHERE person_pkid = p.pkid "); str.Append(" AND ( as_director = 1 OR as_producer = 1 OR as_actor = 1 OR as_musician = 1 OR as_cameraman = 1 OR as_cutter = 1 OR as_writer = 1 )"); str.Append(") AS movieQuantity "); str.Append(" FROM tbl_persons AS p"); switch(mot) { case MovieObjectType.Genre: break; case MovieObjectType.Actor: str.Append(" WHERE p.is_actor = 1"); break; case MovieObjectType.Director: str.Append(" WHERE p.is_director = 1"); break; case MovieObjectType.Producer: str.Append(" WHERE p.is_producer = 1"); break; case MovieObjectType.Musician: str.Append(" WHERE p.is_musician = 1"); break; case MovieObjectType.Cameraman: str.Append(" WHERE p.is_cameraman = 1"); break; case MovieObjectType.Cutter: str.Append(" WHERE p.is_cutter = 1"); break; case MovieObjectType.Writer: str.Append(" WHERE p.is_writer = 1"); break; case MovieObjectType.All: str.Append(" WHERE ( NOT (p.pkid IS NULL) )"); break; } if(name != null && name.Trim() != "") { if(this._cfg.ProviderType == ProviderType.SQLite) { str.Append(" AND ( "); str.Append(" ( LOWER(p.firstname) LIKE LOWER('{" + name + "}') AND LOWER(p.lastname) LIKE LOWER('{" + name + "}') ) "); str.Append(" OR ( LOWER(p.firstname) + ' ' + LOWER(p.lastname) LIKE LOWER('{" + name + "}') ) "); str.Append(" OR ( LOWER(p.lastname) + ' ' + LOWER(p.firstname) LIKE LOWER('{" + name + "}') ) "); str.Append(" ) "); } else { str.Append(" AND ( "); str.Append(" ( LOWER(p.firstname) LIKE LOWER('%" + name + "%') AND LOWER(p.lastname) LIKE LOWER('%" + name + "%') ) "); str.Append(" OR ( LOWER(p.firstname) + ' ' + LOWER(p.lastname) LIKE LOWER('%" + name + "%') ) "); str.Append(" OR ( LOWER(p.lastname) + ' ' + LOWER(p.firstname) LIKE LOWER('%" + name + "%') ) "); str.Append(" ) "); } } // add sort expression if(!string.IsNullOrEmpty(sortExpression)) { switch(sortExpression) { case "MovieQuantity": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "movieQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsActor": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "actorQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsDirector": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "directorQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsProducer": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "producerQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsMusician": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "musicianQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsCameraman": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "cameramanQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsCutter": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "cutterQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "MovieQuantityAsWriter": str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "writerQuantity", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.Append("\r\n"); str.AppendFormat( ", p.firstname {0}, p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; case "Fullname": default: str.Append("\r\n"); str.AppendFormat( SqlResources.GetPersonList_SortOrder, "p.firstname", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); str.AppendFormat( ", p.lastname {0}", ( sortDirection == DataSortDirection.Ascending ? "ASC" : "DESC" ) ); break; } } else { str.Append(" ORDER BY p.firstname ASC, p.lastname ASC"); } if(this._cfg.ProviderType == ProviderType.SQLite) { str = str.Replace(" = 1", " = 'True'"); } // TODO: Optimize for SQLite // new way using(DAL dal = new DAL(this._cfg)) { IDbCommand cmd = dal.CreateCommand(); cmd.CommandText = str.ToString(); dal.OpenConnection(); using(IDataReader reader = dal.ExecuteQueryForDataReader(cmd)) { while(reader.Read()) { list.Add( new Person( reader.GetSafeValue<Guid>("pkid").ToString(), reader.GetSafeValue<string>("firstname"), reader.GetSafeValue<string>("lastname"), reader.GetSafeValue<bool>("is_actor"), reader.GetSafeValue<bool>("is_director"), reader.GetSafeValue<bool>("is_producer"), ( reader["is_cameraman"] == DBNull.Value ? false : reader.GetSafeValue<bool>("is_cameraman") ), ( reader["is_cutter"] == DBNull.Value ? false : reader.GetSafeValue<bool>("is_cutter") ), ( reader["is_musician"] == DBNull.Value ? false : reader.GetSafeValue<bool>("is_musician") ), ( reader["is_writer"] == DBNull.Value ? false : reader.GetSafeValue<bool>("is_writer") ) ) { MovieQuantityAsActor = reader["actorQuantity"].ToString().ToInt32(), MovieQuantityAsDirector = reader["directorQuantity"].ToString().ToInt32(), MovieQuantityAsProducer = reader["producerQuantity"].ToString().ToInt32(), MovieQuantityAsCameraman = reader["cameramanQuantity"].ToString().ToInt32(), MovieQuantityAsCutter = reader["cutterQuantity"].ToString().ToInt32(), MovieQuantityAsMusician = reader["musicianQuantity"].ToString().ToInt32(), MovieQuantityAsWriter = reader["writerQuantity"].ToString().ToInt32(), MovieQuantity = reader["movieQuantity"].ToString().ToInt32() } ); } } } return list; }
/// <summary> /// Get a list of persons /// </summary> /// <param name="mot">The MovieObjectType.</param> /// <param name="sortExpression">The sort expression.</param> /// <param name="sortDirection">The sort direction.</param> /// <returns></returns> public List<Person> GetPersonList(MovieObjectType mot, string sortExpression, DataSortDirection sortDirection) { return this.GetPersonList(mot, "", sortExpression, sortDirection); }
/// <summary> /// Gets the person list. /// </summary> /// <param name="mot">The MovieObjectType.</param> /// <returns></returns> public List<Person> GetPersonList(MovieObjectType mot) { return this.GetPersonList(mot, "", "", DataSortDirection.Ascending); }
/// <summary> /// Gets the person by its name /// </summary> /// <param name="firstname">The firstname.</param> /// <param name="lastname">The lastname.</param> /// <param name="mot">The mot.</param> /// <returns></returns> public Person GetPersonByName(string firstname, string lastname, MovieObjectType mot) { StringBuilder str = new StringBuilder(); str.Append("SELECT * "); str.Append(" FROM tbl_persons"); if(this._cfg.ProviderType != ProviderType.SQLite) { str.Append(" WHERE ("); str.Append(" (firstname LIKE '%" + firstname.Trim() + "%'"); str.Append(" AND lastname LIKE '%" + lastname.Trim() + "%')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + firstname + "}')"); str.Append(" OR (firstname + ' ' + lastname LIKE '%" + (firstname + " " + lastname).Trim() + "%')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + ' ' + firstname + "}')"); str.Append(" )"); } else { str.Append(" WHERE ("); str.Append(" (firstname LIKE '{" + firstname.Trim() + "}'"); str.Append(" AND lastname LIKE '{" + lastname.Trim() + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + firstname + "}')"); str.Append(" OR (firstname + ' ' + lastname LIKE '{" + (firstname + " " + lastname).Trim() + "}')"); //str.Append(" OR (firstname + ' ' + lastname LIKE '{" + lastname + ' ' + firstname + "}')"); str.Append(" )"); } switch(mot) { case MovieObjectType.Genre: break; case MovieObjectType.Actor: str.Append(" AND is_actor = 1"); break; case MovieObjectType.Director: str.Append(" AND is_director = 1"); break; case MovieObjectType.Producer: str.Append(" AND is_producer = 1"); break; case MovieObjectType.Musician: str.Append(" AND is_musician = 1"); break; case MovieObjectType.Cameraman: str.Append(" AND is_cameraman = 1"); break; case MovieObjectType.Cutter: str.Append(" AND is_cutter = 1"); break; case MovieObjectType.Writer: str.Append(" AND is_writer = 1"); break; case MovieObjectType.All: break; } if(this._cfg.ProviderType == ProviderType.SQLite) { str = str.Replace(" = 1", " = 'True'"); } DataSet data = this._db.ExecuteQuery(str.ToString()); if(data.Tables[0].Rows.Count > 0) { DataTableReader reader = data.CreateDataReader(); reader.Read(); return this.GetPerson(reader["pkid"].ToString()); } else { return null; } }
/// <summary> /// Loadings the init. /// </summary> private void _LoadingInit() { if(!this.chkActor.Checked && !this.chkDirector.Checked && !this.chkProducer.Checked) { //this._LoadData( // MovieObjectType.All, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.All; } else { if(this.chkActor.Checked) { //this._LoadData( // MovieObjectType.Actor, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Actor; } else if(this.chkDirector.Checked) { //this._LoadData( // MovieObjectType.Director, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Director; } else if(this.chkProducer.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Producer; } else if(this.chkMusician.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Musician; } else if(this.chkCameraman.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Cameraman; } else if(this.chkCutter.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Cutter; } else if(this.chkWriter.Checked) { //this._LoadData( // MovieObjectType.Producer, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.Writer; } else { //this._LoadData( // MovieObjectType.All, // this.txtName.Text.Trim() //); this._searchType = MovieObjectType.All; } } this._searchName = this.txtName.Text.Trim(); int intervall = 1; if(this._searchName.Length == 0) { intervall = 1; } else if(this._searchName.Length < 2) { intervall = 1000; } else if(this._searchName.Length < 4) { intervall = 750; } else if(this._searchName.Length < 6) { intervall = 500; } else if(this._searchName.Length < 8) { intervall = 250; } else if(this._searchName.Length < 10) { intervall = 100; } else { intervall = 1; } this._searchTimer.Interval = intervall; this._searchTimer.Start(); }
// ------------------------------------------------------- // PUBLIC MEMBERS // ------------------------------------------------------- // ------------------------------------------------------- // PRIVATE MEMBERS // ------------------------------------------------------- /// <summary> /// Open a AddItemForm window /// </summary> /// <param name="mot"></param> private void _OpenAddForm(MovieObjectType mot) { AddItemForm agf = new AddItemForm(mot); DialogResult dr = agf.ShowDialog(this); if(dr == DialogResult.OK) { this.__hasChanges = true; if(mot == MovieObjectType.Genre) { foreach(Genre g in agf.SelectedGenreItems) { if(!this._ObjectIsInListView(mot, g.ID)) { ListViewItem lvi = new ListViewItem(); lvi.Text = g.Name; lvi.Name = g.ID; this.lvGenre.Items.Add(lvi); this._mov.Genres.Add(g); } } } else if(mot == MovieObjectType.Category) { foreach(Category c in agf.SelectedCategoryItems) { if(!this._ObjectIsInListView(mot, c.ID)) { ListViewItem lvi = new ListViewItem(); lvi.Text = c.Name; lvi.Name = c.ID; this.lvCategories.Items.Add(lvi); this._mov.Categories.Add(c); } } } else { foreach(Person p in agf.SelectedPersonItems) { if(!this._ObjectIsInListView(mot, p.ID)) { ListViewItem lvi = new ListViewItem(); lvi.Text = p.Firstname + " " + p.Lastname; lvi.Name = p.ID; switch(mot) { case MovieObjectType.Actor: // roleName ListViewItem.ListViewSubItem lviRN = new ListViewItem.ListViewSubItem(); lviRN.Text = p.Rolename; lvi.SubItems.Add(lviRN); // roleType ListViewItem.ListViewSubItem lviRT = new ListViewItem.ListViewSubItem(); if(!p.Roletype.IsNullOrTrimmedEmpty()) { Static stcRoleType = this._st.GetStaticItem("RT01", p.Roletype); if(stcRoleType != null) { lviRT.Text = stcRoleType.Content; lviRT.Name = stcRoleType.Value; } } lvi.SubItems.Add(lviRT); this.lvActors.Items.Add(lvi); this._mov.Actors.Add(p); this._SetQuantityLabel(this.lblActorAmount, this._mov.Actors.Count); break; case MovieObjectType.Director: this.lvDirectors.Items.Add(lvi); this._mov.Directors.Add(p); this._SetQuantityLabel(this.lblDirectorAmount, this._mov.Directors.Count); break; case MovieObjectType.Producer: this.lvProducers.Items.Add(lvi); this._mov.Producers.Add(p); this._SetQuantityLabel(this.lblProducerAmount, this._mov.Producers.Count); break; case MovieObjectType.Musician: this.lvMusician.Items.Add(lvi); this._mov.Musicians.Add(p); this._SetQuantityLabel(this.lblMusicianAmount, this._mov.Musicians.Count); break; case MovieObjectType.Cameraman: this.lvCameraman.Items.Add(lvi); this._mov.Cameramans.Add(p); this._SetQuantityLabel(this.lblCameramanAmount, this._mov.Cameramans.Count); break; case MovieObjectType.Cutter: this.lvCutter.Items.Add(lvi); this._mov.Cutters.Add(p); this._SetQuantityLabel(this.lblCutterAmount, this._mov.Cutters.Count); break; case MovieObjectType.Writer: this.lvWriters.Items.Add(lvi); this._mov.Writers.Add(p); this._SetQuantityLabel(this.lblWriterAmount, this._mov.Writers.Count); break; } } } } } }
/// <summary> /// Check if a object is also in the movie list /// </summary> /// <param name="mot"></param> /// <param name="id"></param> /// <returns></returns> public bool _ObjectIsInMovieList(MovieObjectType mot, string id) { switch(mot) { case MovieObjectType.Genre: foreach(Genre g in this._mov.Genres) { if(g.ID == id) { return true; } } break; case MovieObjectType.Category: foreach(Category c in this._mov.Categories) { if(c.ID == id) { return true; } } break; case MovieObjectType.Actor: foreach(Person p in this._mov.Actors) { if(p.ID == id) { return true; } } break; case MovieObjectType.Director: foreach(Person p in this._mov.Directors) { if(p.ID == id) { return true; } } break; case MovieObjectType.Producer: foreach(Person p in this._mov.Producers) { if(p.ID == id) { return true; } } break; case MovieObjectType.Musician: foreach(Person p in this._mov.Musicians) { if(p.ID == id) { return true; } } break; case MovieObjectType.Cameraman: foreach(Person p in this._mov.Cameramans) { if(p.ID == id) { return true; } } break; case MovieObjectType.Cutter: foreach(Person p in this._mov.Cutters) { if(p.ID == id) { return true; } } break; case MovieObjectType.Writer: foreach(Person p in this._mov.Writers) { if(p.ID == id) { return true; } } break; } return false; }
/// <summary> /// Handles the CheckedChanged event of the chkWriter control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void chkWriter_CheckedChanged(object sender, EventArgs e) { if(this.chkWriter.Checked) { this._startSearch = false; this.chkActor.Checked = false; this.chkDirector.Checked = false; this.chkProducer.Checked = false; this.chkMusician.Checked = false; this.chkCameraman.Checked = false; this.chkCutter.Checked = false; //this.chkWriter.Checked = false; this._startSearch = true; if(this._startSearch) { //this._LoadData(MovieObjectType.Producer, ""); this._searchType = MovieObjectType.Writer; this._searchName = ""; this._searchTimer.Interval = 1; this._searchTimer.Start(); } } else { if(this._startSearch) { //this._LoadData(MovieObjectType.All, ""); this._searchType = MovieObjectType.All; this._searchName = ""; this._searchTimer.Interval = 1; this._searchTimer.Start(); } } }