Beispiel #1
0
 private void BtnVote_Click(object sender, EventArgs e)
 {
     BtnUnVote.Visible      = true;
     BtnVote.Visible        = false;
     GlobalVar.candidate_id = lblcandidateid.Text;
     GlobalVar.position     = lblposition.Text;
     GlobalVar.fullname     = lblfullname.Text;
     DeleteVote();
     try
     {
         con.Open();
         String       query = "insert into votes (voters_id,candidate_id,position) values (@voters_id, @candidate_id, @position)";
         MySqlCommand cmd   = new MySqlCommand(query, con);
         cmd.Parameters.AddWithValue("@voters_id", GlobalVar.voters_id);
         cmd.Parameters.AddWithValue("@candidate_id", GlobalVar.candidate_id);
         cmd.Parameters.AddWithValue("@position", GlobalVar.position);
         cmd.ExecuteNonQuery();
         con.Close();
         LogHistoryUnVote(GlobalVar.account_id, GlobalVar.user_type, GlobalVar.user);
         NotificationAddedSuccess a = new NotificationAddedSuccess();
         a.ShowDialog();
     }
     catch
     {
         NotificationConnectionError a = new NotificationConnectionError();
         a.ShowDialog();
     }
 }
Beispiel #2
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 BtnRegisterTeacher_Click(object sender, EventArgs e)
 {
     try
     {
         con.Open();
         MemoryStream ms = new MemoryStream();
         StudentPicture.Image.Save(ms, StudentPicture.Image.RawFormat);
         byte[] a = ms.GetBuffer();
         ms.Close();
         String       query = "insert into candidate(img, last_name, first_name, middle_name, birthdate, gender, age, grade, track, strand, partylist, position, platform) values (@img, @last_name, @first_name, @middle_name, @birthdate, @gender, @age, @grade, @track, @strand, @partylist, @position, @platform)";
         MySqlCommand cmd   = new MySqlCommand(query, con);
         cmd.Parameters.Add("@img", MySqlDbType.LongBlob).Value = a;
         cmd.Parameters.AddWithValue("@last_name", TxtStudentLName.Text);
         cmd.Parameters.AddWithValue("@first_name", TxtStudentFName.Text);
         cmd.Parameters.AddWithValue("@middle_name", TxtStudentMName.Text);
         cmd.Parameters.AddWithValue("@birthdate", TxtBirthdate.Text);
         if (GenderFemaleCheckBox.Checked)
         {
             cmd.Parameters.AddWithValue("@gender", "Female");
         }
         else if (GenderMaleCheckBox.Checked)
         {
             cmd.Parameters.AddWithValue("@gender", "Male");
         }
         cmd.Parameters.AddWithValue("@age", TxtAge.Text);
         cmd.Parameters.AddWithValue("@grade", TxtGrade.Text);
         cmd.Parameters.AddWithValue("@track", TxtTrack.Text);
         cmd.Parameters.AddWithValue("@strand", TxtStrand.Text);
         cmd.Parameters.AddWithValue("@partylist", TxtPartylist.Text);
         cmd.Parameters.AddWithValue("@position", TxtPosition.Text);
         cmd.Parameters.AddWithValue("@platform", TxtPlatform.Text);
         cmd.ExecuteNonQuery();
         con.Close();
         NotificationAddedSuccess b = new NotificationAddedSuccess();
         b.ShowDialog();
         LogHistory(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user);
         CloseTransparent();
     }
     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();
         }
     }
 }