private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { previousYear = new PreviousYear(); PreviousYearDataHelper previousYearDataHelper = new PreviousYearDataHelper(selectedIndex); previousYear = previousYearDataHelper.GetPreviousYearData(selectedYear); }
private void button5_Click(object sender, EventArgs e) { GenericHelper helper = new GenericHelper(0); string serverAddress = "http://" + Session.Properties.Settings.Default.RemoteDatabaseAddress; if (helper.CheckInternet(serverAddress)) { int year = Convert.ToInt32(comboBox1.Text); int output11 = (int)numericUpDown1.Value; int output12 = (int)numericUpDown2.Value; int output13 = (int)numericUpDown3.Value; int output21 = (int)numericUpDown6.Value; int output22 = (int)numericUpDown5.Value; int output23 = (int)numericUpDown4.Value; int output24 = (int)numericUpDown8.Value; int output25 = (int)numericUpDown7.Value; int output31 = (int)numericUpDown11.Value; int output32 = (int)numericUpDown10.Value; previousYear = new PreviousYear(); previousYear.Year = year; previousYear.Output11 = output11; previousYear.Output12 = output12; previousYear.Output13 = output13; previousYear.Output21 = output21; previousYear.Output22 = output22; previousYear.Output23 = output23; previousYear.Output24 = output24; previousYear.Output25 = output25; previousYear.Output31 = output31; previousYear.Output32 = output32; previousYear.Uid = Properties.Settings.Default.UID; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; statusLabel1.Text = "Adding previous year data - " + year + "..."; statusLabel1.Visible = true; statusProgressBar.Visible = true; accountAddBackgroundWorker.RunWorkerAsync(); } else { MessageBox.Show("Previous year data addition failed! There is no internet connection or there is a problem with the server address. Please check your server settings.", "Previous year data addition Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public int UpdateYearsData(PreviousYear previousYear) { string tableName = "years"; if (databaseIndex == DATABASE_DATA) { tableName += "data"; } else { tableName += "target"; } int resultValue = -1; MySqlCommand myCommand; //connect to remote database MySqlHelper mySqlHelper = new MySqlHelper(); try { if (mySqlHelper.OpenConnection()) { MySqlConnection myConnection = mySqlHelper.Connection; myCommand = myConnection.CreateCommand(); myCommand.CommandText = "UPDATE " + tableName + " SET `output11`=@output11, `output12`=@output12,`output13`=@output13,`output21`=@output21,`output22`=@output22,`output23`=@output23,`output24`=@output24,`output25`=@output25,`output31`=@output31,`output32`=@output32, `uid`=@uid WHERE `oyear`=@year"; myCommand.Parameters.AddWithValue("@output11", previousYear.Output11); myCommand.Parameters.AddWithValue("@output12", previousYear.Output12); myCommand.Parameters.AddWithValue("@output13", previousYear.Output13); myCommand.Parameters.AddWithValue("@output21", previousYear.Output21); myCommand.Parameters.AddWithValue("@output22", previousYear.Output22); myCommand.Parameters.AddWithValue("@output23", previousYear.Output23); myCommand.Parameters.AddWithValue("@output24", previousYear.Output24); myCommand.Parameters.AddWithValue("@output25", previousYear.Output25); myCommand.Parameters.AddWithValue("@output31", previousYear.Output31); myCommand.Parameters.AddWithValue("@output32", previousYear.Output32); myCommand.Parameters.AddWithValue("@uid", previousYear.Uid); myCommand.Parameters.AddWithValue("@year", previousYear.Year); resultValue = myCommand.ExecuteNonQuery(); mySqlHelper.CloseConnection(); } } catch { throw; } return(resultValue); }
private void PopulateFields(PreviousYear previousYear) { numericUpDown1.Value = previousYear.Output11; numericUpDown2.Value = previousYear.Output12; numericUpDown3.Value = previousYear.Output13; numericUpDown6.Value = previousYear.Output21; numericUpDown5.Value = previousYear.Output22; numericUpDown4.Value = previousYear.Output23; numericUpDown8.Value = previousYear.Output24; numericUpDown7.Value = previousYear.Output25; numericUpDown11.Value = previousYear.Output31; numericUpDown10.Value = previousYear.Output32; }
public PreviousYear GetPreviousYearData(int year) { string tableName = "years"; if (databaseIndex == DATABASE_DATA) { tableName += "data"; } else { tableName += "target"; } MySqlCommand myCommand; //connect to remote database MySqlHelper mySqlHelper = new MySqlHelper(); PreviousYear previousYear = new PreviousYear(); if (mySqlHelper.OpenConnection()) { MySqlConnection myConnection = mySqlHelper.Connection; myCommand = myConnection.CreateCommand(); myCommand.CommandText = "SELECT * FROM " + tableName + " WHERE `oyear`=" + year; Organization organization = null; MySqlDataReader dr = myCommand.ExecuteReader(); while (dr.Read()) { previousYear.Pid = Convert.ToInt32(dr[0].ToString()); previousYear.Year = Convert.ToInt32(dr[1].ToString()); previousYear.Output11 = Convert.ToInt32(dr[2].ToString()); previousYear.Output12 = Convert.ToInt32(dr[3].ToString()); previousYear.Output13 = Convert.ToInt32(dr[4].ToString()); previousYear.Output21 = Convert.ToInt32(dr[5].ToString()); previousYear.Output22 = Convert.ToInt32(dr[6].ToString()); previousYear.Output23 = Convert.ToInt32(dr[7].ToString()); previousYear.Output24 = Convert.ToInt32(dr[8].ToString()); previousYear.Output25 = Convert.ToInt32(dr[9].ToString()); previousYear.Output31 = Convert.ToInt32(dr[10].ToString()); previousYear.Output32 = Convert.ToInt32(dr[11].ToString()); previousYear.Uid = Convert.ToInt32(dr[12].ToString()); } dr.Close(); mySqlHelper.CloseConnection(); } return(previousYear); }