Esempio n. 1
0
 private void BtnAddPosition_Click(object sender, EventArgs e)
 {
     if (TxtPosition.Text == "")
     {
         NotificationFillBlank a = new NotificationFillBlank();
         a.ShowDialog();
     }
     else
     {
         try
         {
             con.Open();
             String       query = "insert into partylist (partylist) values (@partylist)";
             MySqlCommand cmd   = new MySqlCommand(query, con);
             cmd.Parameters.AddWithValue("@partylist", TxtPosition.Text);
             cmd.ExecuteNonQuery();
             con.Close();
             LogHistory(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user);
             CloseTransparent();
             NotificationAddedSuccess a = new NotificationAddedSuccess();
             a.ShowDialog();
         }
         catch
         {
             NotificationConnectionError a = new NotificationConnectionError();
             a.ShowDialog();
         }
     }
 }
 private void BtnChangePassword_Click(object sender, EventArgs e)
 {
     if (TxtGrade.Text == "" || TxtStrand.Text == "" || TxtTrack.Text == "")
     {
         NotificationFillBlank a = new NotificationFillBlank();
         a.ShowDialog();
     }
     else
     {
         try
         {
             GetAccountInfo();
             UpdateAccount();
             con.Open();
             String       query = "update voters set grade = @grade, track = @track, strand = @strand where account_id = @id";
             MySqlCommand cmd   = new MySqlCommand(query, con);
             cmd.Parameters.AddWithValue("@id", user_id);
             cmd.Parameters.AddWithValue("@grade", TxtGrade.Text);
             cmd.Parameters.AddWithValue("@track", TxtTrack.Text);
             cmd.Parameters.AddWithValue("@strand", TxtStrand.Text);
             cmd.ExecuteNonQuery();
             con.Close();
             LogHistoryEdit(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user);
             CloseTransparent();
             NotificationEditSuccess a = new NotificationEditSuccess();
             a.ShowDialog();
         }
         catch
         {
             NotificationConnectionError a = new NotificationConnectionError();
             a.ShowDialog();
         }
     }
 }
 private void BtnAddPosition_Click(object sender, EventArgs e)
 {
     if (TxtFirstName.Text == "" || TxtMiddleName.Text == "" || TxtLastName.Text == "" || TxtUsername.Text == "" || TxtPassword.Text == "")
     {
         NotificationFillBlank a = new NotificationFillBlank();
         a.ShowDialog();
     }
     else if (TxtFirstName.Text == "E.G. MERCADO RIZAL" || TxtMiddleName.Text == "E.G. JOSE PROTASIO JR." || TxtLastName.Text == "E.G. ALONSO REALONDA" || TxtUsername.Text == "Username" || TxtPassword.Text == "Password")
     {
         NotificationFillBlank a = new NotificationFillBlank();
         a.ShowDialog();
     }
     else
     {
         InserAccount();
         GetAccountInfo();
         try
         {
             con.Open();
             String       query = "insert into voters(account_id, last_name, first_name, middle_name, track, strand) values (@voters_id, @last_name, @first_name, @middle_name, @track, @strand)";
             MySqlCommand cmd   = new MySqlCommand(query, con);
             cmd.Parameters.AddWithValue("@voters_id", user_id);
             cmd.Parameters.AddWithValue("@last_name", TxtLastName.Text);
             cmd.Parameters.AddWithValue("@first_name", TxtFirstName.Text);
             cmd.Parameters.AddWithValue("@middle_name", TxtMiddleName.Text);
             cmd.Parameters.AddWithValue("@track", TxtTrack.Text);
             cmd.Parameters.AddWithValue("@strand", TxtStrand.Text);
             cmd.ExecuteNonQuery();
             con.Close();
             LogHistory(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user);
             CloseTransparent();
             NotificationAddedSuccess a = new NotificationAddedSuccess();
             a.ShowDialog();
         }
         catch
         {
             NotificationConnectionError a = new NotificationConnectionError();
             a.ShowDialog();
         }
     }
 }
Esempio n. 4
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     if (TxtServer.Text == "" || TxtDatabase.Text == "" || TxtDatabaseUsername.Text == "" || TxtDatabasePort.Text == "")
     {
         NotificationFillBlank a = new NotificationFillBlank();
         a.Show();
     }
     else
     {
         if (RememberMeCheckBox.Checked)
         {
             GlobalVar.DatabaseServer   = TxtServer.Text;
             GlobalVar.Database         = TxtDatabase.Text;
             GlobalVar.DatabaseUsername = TxtDatabaseUsername.Text;
             GlobalVar.DatabasePassword = TxtDatabasePassword.Text;
             GlobalVar.DatabasePort     = TxtDatabasePort.Text;
             Connection.SetServer(GlobalVar.DatabaseServer);
             Connection.SetDatabase(GlobalVar.Database);
             Connection.SetUid(GlobalVar.DatabaseUsername);
             Connection.SetPassword(GlobalVar.DatabasePassword);
             Connection.SetPort(GlobalVar.DatabasePort);
             try
             {
                 MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr());
                 Properties.Settings.Default.DatabaseServer   = TxtServer.Text;
                 Properties.Settings.Default.Database         = TxtDatabase.Text;
                 Properties.Settings.Default.DatabaseUsername = TxtDatabaseUsername.Text;
                 Properties.Settings.Default.DatabasePassword = TxtDatabasePassword.Text;
                 Properties.Settings.Default.DatabasePort     = TxtDatabasePort.Text;
                 Properties.Settings.Default.Save();
                 con.Open();
                 this.Hide();
                 NotificationConnectionSuccess a = new NotificationConnectionSuccess();
                 a.ShowDialog();
             }
             catch
             {
                 NotificationConnectionError a = new NotificationConnectionError();
                 a.Show();
             }
         }
         else
         {
             GlobalVar.DatabaseServer   = TxtServer.Text;
             GlobalVar.Database         = TxtDatabase.Text;
             GlobalVar.DatabaseUsername = TxtDatabaseUsername.Text;
             GlobalVar.DatabasePassword = TxtDatabasePassword.Text;
             GlobalVar.DatabasePort     = TxtDatabasePort.Text;
             Connection.SetServer(GlobalVar.DatabaseServer);
             Connection.SetDatabase(GlobalVar.Database);
             Connection.SetUid(GlobalVar.DatabaseUsername);
             Connection.SetPassword(GlobalVar.DatabasePassword);
             Connection.SetPort(GlobalVar.DatabasePort);
             try
             {
                 MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr());
                 con.Open();
                 this.Hide();
                 NotificationConnectionSuccess a = new NotificationConnectionSuccess();
                 a.Show();
             }
             catch
             {
                 NotificationConnectionError a = new NotificationConnectionError();
                 a.Show();
             }
         }
     }
 }