public void AddNew(SeriesNumber newSeriesNumber) { MySqlConnection conn = new MySqlConnection(MyConnection.connectionStringforSystem); MySqlCommand comm = new MySqlCommand(); String strQuery = null; try { conn.Open(); strQuery = "INSERT INTO tblSeriesNumber(Year,BaptismalSeries,ConfirmationSeries,DeathSeries,MarriageSeries,Status) VALUES" + " ('" + newSeriesNumber.Year + "','" + newSeriesNumber.BaptismalSeries + "','" + newSeriesNumber.ConfirmationSeries + "','" + newSeriesNumber.DeathSeries + "','" + newSeriesNumber.MarriageSeries + "','" + newSeriesNumber.Status + "')"; comm.Connection = conn; comm.CommandText = strQuery; comm.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error); } conn.Close(); }
public bool YearExist(SeriesNumber newSeriesNumber) { MySqlConnection conn = new MySqlConnection(MyConnection.connectionStringforSystem); MySqlCommand comm = new MySqlCommand(); MySqlDataReader reader = null; String strQuery = null; //default bool value = false; strQuery = "SELECT Year FROM tblSeriesNumber WHERE Year='" + newSeriesNumber.Year + "'"; try { conn.Open(); comm.Connection = conn; comm.CommandText = strQuery; reader = comm.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { value = true; } reader.Close(); value = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error); value = false; } conn.Close(); return value; }
public void UpdateStatus(SeriesNumber currSeriesNumber) { MySqlConnection conn = new MySqlConnection(MyConnection.connectionStringforSystem); MySqlCommand comm = new MySqlCommand(); String strQuery = null; try { conn.Open(); strQuery = "UPDATE tblSeriesNumber SET Status ='" + currSeriesNumber.Status + "' WHERE Year=" + currSeriesNumber.Year + ""; comm.Connection = conn; comm.CommandText = strQuery; comm.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message, SystemVariable.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Error); } conn.Close(); }