public static long Insert(Person person, bool isActor, bool isDirector) { try { long personID = 0; personID = AccessDatabase.Insert(QueryRepository.Person_Insert, "@PersonFName", person.PersonFName, "@PersonLName", person.PersonLName, "@IMDBLink", person.IMDBLink, "@PhotoLink", person.PhotoLink); if (personID <= 0) { throw new Exception(Messages.DatabaseError); } if (isActor == true) { AccessDatabase.Insert(QueryRepository.Actor_Insert, "@PersonID", personID); } if (isDirector == true) { AccessDatabase.Insert(QueryRepository.Director_Insert, "@PersonID", personID); } return(personID); } catch (Exception ex) { throw ex; } }
public static long Insert(Users user) { try { long count = 0; count = AccessDatabase.CountFunction(FunctionRepository.CountUsername, "@Username", user.Username); if (count > 0) { throw new Exception(Messages.UnavailableUsername); } long userID = 0; userID = AccessDatabase.Insert(QueryRepository.Users_Insert, "@Username", user.Username, "@PasswordHash", user.PasswordHash, "@FName", user.FName, "@LName", user.LName, "@Email", user.Email); if (userID <= 0) { throw new Exception(Messages.DatabaseError); } return(userID); } catch (Exception ex) { throw ex; } }
public static DataTable GetByName(string personName, bool isActor = false, bool isDirector = false) { try { string joinActor = string.Empty; string joinDirector = string.Empty; if (isActor == true) { joinActor = @"inner join Actor on Person.PersonID=Actor.PersonID" ; } if (isDirector == true) { joinDirector = @"inner join Director on Person.PersonID=Director.PersonID"; } string finalQuery = QueryRepository.Person_Get_By_Name.Replace("@JoinActor", joinActor); finalQuery = finalQuery.Replace("@JoinDirector", joinDirector); DataTable dtPersons = new DataTable(); dtPersons = AccessDatabase.Select(finalQuery, "@PersonFullName", personName); return(dtPersons); } catch (Exception ex) { throw ex; } }
public static long Insert(Language language) { try { long count = 0; count = AccessDatabase.CountFunction(FunctionRepository.CountLanguageName, "@LanguageName", language.LanguageName); if (count > 0) { throw new Exception(Messages.AlreadyExistLanguageName); } long languageID = 0; languageID = AccessDatabase.Insert(QueryRepository.Language_Insert, "@LanguageName", language.LanguageName); if (languageID <= 0) { throw new Exception(Messages.DatabaseError); } return(languageID); } catch (Exception ex) { throw ex; } }
public static long Insert(Genre genre) { try { long count = 0; count = AccessDatabase.CountFunction(FunctionRepository.CountGenreName, "@GenreName", genre.GenreName); if (count > 0) { throw new Exception(Messages.AlreadyExistGenreName); } long genreID = 0; genreID = AccessDatabase.Insert(QueryRepository.Genre_Insert, "@GenreName", genre.GenreName, "@IsMain", Genre.DetectIsMain(genre.GenreName)); if (genreID <= 0) { throw new Exception(Messages.DatabaseError); } return(genreID); } catch (Exception ex) { throw ex; } }
public static DataTable GetByName(string name) { name = name.Trim(); DataTable dtLanguages = new DataTable(); dtLanguages = AccessDatabase.Select(QueryRepository.Language_Get_By_Name, "@LanguageName", name); return(dtLanguages); }
public static long Delete(long personID) { try { long count = 0; count = AccessDatabase.Delete(QueryRepository.Person_Delete, "@PersonID", personID); return(count); } catch (Exception ex) { throw ex; } }
public static DataTable GetDirectorByMovieID(long movieID) { try { DataTable dtPerson = new DataTable(); dtPerson = AccessDatabase.Select(QueryRepository.Director_Get_By_MovieID, "@MovieID", movieID); return(dtPerson); } catch (Exception ex) { throw ex; } }
public static DataTable GetByID(long personID) { try { DataTable dtPerson = new DataTable(); dtPerson = AccessDatabase.Select(QueryRepository.Person_Get_By_PersonID, "@PersonID", personID); return(dtPerson); } catch (Exception ex) { throw ex; } }
public static long Delete(long genreID) { try { long count = 0; count = AccessDatabase.Delete(QueryRepository.Genre_Delete, "@GenreID", genreID); return(count); } catch (Exception ex) { throw ex; } }
public static DataTable GetByMovieID(long movieID) { try { DataTable dtLanguage = new DataTable(); dtLanguage = AccessDatabase.Select(QueryRepository.Language_Get_By_MovieID, "@MovieID", movieID); return(dtLanguage); } catch (Exception ex) { throw ex; } }
public static DataTable GetByID(long genreID) { try { DataTable dtGenre = new DataTable(); dtGenre = AccessDatabase.Select(QueryRepository.Genre_Get_By_GenreID, "@GenreID", genreID); return(dtGenre); } catch (Exception ex) { throw ex; } }
public static DataTable GetList() { try { DataTable dtLanguage = new DataTable(); dtLanguage = AccessDatabase.Select(QueryRepository.Language_Get_List); return(dtLanguage); } catch (Exception ex) { throw ex; } }
public static DataTable GetByNameExact(string personName) { try { DataTable dtPersons = new DataTable(); dtPersons = AccessDatabase.Select(QueryRepository.Person_Get_By_Name_Exact, "@FullName", personName); return(dtPersons); } catch (Exception ex) { throw ex; } }
public static DataTable GetByIMDBLink(string imdbLink) { try { DataTable dtPersons = new DataTable(); dtPersons = AccessDatabase.Select(QueryRepository.Person_Get_By_IMDBLink, "@IMDBLink", imdbLink); return(dtPersons); } catch (Exception ex) { throw ex; } }
public static DataTable GetByParamID(long paramID) { try { DataTable dt = new DataTable(); dt = AccessDatabase.Select(QueryRepository.Param_Get_By_ParamID, "@ParamID", paramID); return(dt); } catch (Exception ex) { throw ex; } }
public static void GetTypeByID(long personID, out bool isActor, out bool isDirector) { try { DataTable dtType = new DataTable(); dtType = AccessDatabase.Select(QueryRepository.Person_Get_Type_By_PersonID, "@PersonID", personID); isActor = Convert.ToBoolean(Convert.ToInt64(dtType.Rows[0]["IsValid"])); isDirector = Convert.ToBoolean(Convert.ToInt64(dtType.Rows[1]["IsValid"])); } catch (Exception ex) { throw ex; } }
public static long UpdatePhotoLinkByID(long personID, string photoLink) { try { long count = 0; count = AccessDatabase.Update(QueryRepository.Person_Update_PhotoLink_By_PersonID, "@PersonID", personID, "@PhotoLink", photoLink); return(count); } catch (Exception ex) { throw ex; } }
public static DataTable GetByName(string name) { try { name = name.Trim(); DataTable dtGenres = new DataTable(); dtGenres = AccessDatabase.Select(QueryRepository.Genre_Get_By_Name, "@GenreName", name); return(dtGenres); } catch (Exception ex) { throw ex; } }
public static DataTable Login(string username, string password) { try { DataTable dtUser = new DataTable(); dtUser = AccessDatabase.Select(QueryRepository.Users_Login, "@Username", username, "@PasswordHash", password.GetHashCode()); return(dtUser); } catch (Exception ex) { throw ex; } }
public static long Update(SystemParameter param) { try { long count = 0; count = AccessDatabase.Update(QueryRepository.Param_Update_By_ParamID, "@ParamID", param.ParamID, "@ParamValue", param.ParamValue); return(count); } catch (Exception ex) { throw ex; } }
public static long Insert(SystemParameter param) { try { long paramID = 0; paramID = AccessDatabase.Insert(QueryRepository.Param_Insert, "@ParamID", param.ParamID, "@ParamName", param.ParamName, "@ParamValue", param.ParamValue); if (paramID <= 0) { throw new Exception(Messages.DatabaseError); } return(paramID); } catch (Exception ex) { throw ex; } }
private void btnView_Click(object sender, EventArgs e) { try { string query = txtSQL.Text.Trim(); string temp = query.ToLower(); if (temp.Length > 0) { foreach (string forbid in this.forbidden) { if (temp.Contains(forbid) == true) { throw new Exception(Messages.ForbiddenKeywords); } } DataSet ds = AccessDatabase.SelectSet(query); if (ds.Tables.Count > 0) { RegistryManager.WriteValue(txtSQL.Text.Trim(), Messages.RootKey, Messages.SubKeyLastSQLReport); frmShowReport report = new frmShowReport(ds); report.ShowDialog(); } } else { MessageBox.Show(Messages.NoQuery, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, Messages.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }