public void RetrieveOne(string SearchString) { flowLayoutPanel1.Controls.Clear(); MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { String query = "select * from loghistory where " + SearchString + " = @Search"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.CommandTimeout = 500; cmd.Parameters.AddWithValue("@Search", TxtSearch.Text); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { ViewLogHistory a = new ViewLogHistory(); a.lbllogid.Text = dt.Rows[i]["log_id"].ToString(); a.lblaccountid.Text = dt.Rows[i]["account_id"].ToString(); a.lblaccounttype.Text = dt.Rows[i]["account_type"].ToString(); a.lblusername.Text = dt.Rows[i]["username"].ToString(); a.lbllog.Text = dt.Rows[i]["log"].ToString(); a.lbllastupdate.Text = dt.Rows[i]["last_update"].ToString(); flowLayoutPanel1.Controls.Add(a); } da.Dispose(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
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(); } }
public void Retrieve() { flowLayoutPanel1.Controls.Clear(); MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { String query = "select votes.candidate_id, candidate.first_name, candidate.middle_name, candidate.last_name, votes.position from votes inner join candidate on votes.candidate_id = candidate.candidate_id where votes.voters_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.CommandTimeout = 500; cmd.Parameters.AddWithValue("@id", GlobalVar.voters_id); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { ViewVoteFinal a = new ViewVoteFinal(); String last_name = dt.Rows[i]["last_name"].ToString(); String first_name = dt.Rows[i]["first_name"].ToString(); String middle_name = dt.Rows[i]["middle_name"].ToString(); a.lblvote.Text = last_name + " " + first_name + " " + middle_name[0]; a.lblposition.Text = dt.Rows[i]["position"].ToString(); flowLayoutPanel1.Controls.Add(a); } da.Dispose(); } 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 BtnEdit_Click(object sender, EventArgs e) { TransparentPosition b = new TransparentPosition(); FrmAddPosition a = new FrmAddPosition(); try { a.label8.Text = "Edit Position"; a.lblpositionid.Text = lblpositionid.Text; a.BtnAddPosition.Visible = false; con.Open(); String query = "select * from position where position_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", lblpositionid.Text); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { a.TxtPosition.Text = (dr["position"]).ToString(); } dr.Close(); con.Close(); b.Show(); a.ShowDialog(); b.Hide(); } catch { NotificationConnectionError c = new NotificationConnectionError(); c.ShowDialog(); } }
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(); } } }
public void RetrieveTitle() { try { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); con.Open(); String query = "select title from title"; MySqlCommand cmd = new MySqlCommand(query, con); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { label2.Text = (dr["title"]).ToString(); } else { label2.Text = "Voting Management System"; } dr.Close(); con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.Show(); } }
public void Retrieve() { flowLayoutPanel1.Controls.Clear(); MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { String query = "select * from partylist"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.CommandTimeout = 500; MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { ViewPartylist a = new ViewPartylist(); a.lblpartylistid.Text = dt.Rows[i]["partylist_id"].ToString(); a.lblpartylist.Text = dt.Rows[i]["partylist"].ToString(); flowLayoutPanel1.Controls.Add(a); } da.Dispose(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void RetrieveVote() { try { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); con.Open(); String query = "select candidate_id from votes where voters_id = @voters_id and position = @position"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@voters_id", GlobalVar.voters_id); cmd.Parameters.AddWithValue("@position", lblposition.Text); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { String candidate = dr["candidate_id"].ToString(); if (candidate == lblcandidateid.Text) { BtnUnVote.Visible = true; BtnVote.Visible = false; } else { BtnVote.Visible = true; BtnUnVote.Visible = false; } } dr.Close(); con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.Show(); } }
public void RetrieveOne(string CandidateSearch) { flowLayoutPanel1.Controls.Clear(); MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { String query = "select * from candidate where " + CandidateSearch + " = @Search"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.CommandTimeout = 500; cmd.Parameters.AddWithValue("@Search", TxtSearch.Text); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { ViewCandidate a = new ViewCandidate(); try { byte[] img = (byte[])(dt.Rows[i]["img"]); MemoryStream ms = new MemoryStream(img); a.pictureBox1.Image = Image.FromStream(ms); } catch { } a.lblcandidate.Text = dt.Rows[i]["candidate_id"].ToString(); a.lblastname.Text = dt.Rows[i]["last_name"].ToString(); a.lblfirstname.Text = dt.Rows[i]["first_name"].ToString(); a.lblmiddlename.Text = dt.Rows[i]["middle_name"].ToString(); a.lblgender.Text = dt.Rows[i]["gender"].ToString(); a.lblage.Text = dt.Rows[i]["age"].ToString(); a.lblgrade.Text = dt.Rows[i]["grade"].ToString(); String Track = dt.Rows[i]["track"].ToString(); String Strand = dt.Rows[i]["strand"].ToString(); a.lbltrackstrand.Text = Track + " " + Strand; a.lblpartylist.Text = dt.Rows[i]["partylist"].ToString(); a.lblposition.Text = dt.Rows[i]["position"].ToString(); a.lblplatform.Text = dt.Rows[i]["platform"].ToString(); flowLayoutPanel1.Controls.Add(a); } da.Dispose(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
private void TxtPosition_SelectedIndexChanged(object sender, EventArgs e) { flowLayoutPanel1.Controls.Clear(); MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { String query = "select * from candidate where position = @Search"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.CommandTimeout = 500; cmd.Parameters.AddWithValue("@Search", TxtPosition.Text); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int i = 0; i < dt.Rows.Count; i++) { ViewTallyVote a = new ViewTallyVote(); try { byte[] img = (byte[])(dt.Rows[i]["img"]); MemoryStream ms = new MemoryStream(img); a.StudentPicture.Image = Image.FromStream(ms); } catch { } a.lblcandidateid.Text = dt.Rows[i]["candidate_id"].ToString(); String last_name = dt.Rows[i]["last_name"].ToString(); String first_name = dt.Rows[i]["first_name"].ToString(); String middle_name = dt.Rows[i]["middle_name"].ToString(); a.lblfullname.Text = last_name + " " + first_name + " " + middle_name[0]; a.lblgender.Text = dt.Rows[i]["gender"].ToString(); String Track = dt.Rows[i]["track"].ToString(); String Strand = dt.Rows[i]["strand"].ToString(); a.lbltrackstrand.Text = Track + " " + Strand; a.lblpartylist.Text = dt.Rows[i]["partylist"].ToString(); a.lblposition.Text = dt.Rows[i]["position"].ToString(); a.lblplatform.Text = dt.Rows[i]["platform"].ToString(); flowLayoutPanel1.Controls.Add(a); } da.Dispose(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void CountVoterVote() { try { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); con.Open(); string query = "select count(*) from voters where status = 'voted'"; MySqlCommand cmd = new MySqlCommand(query, con); string getValue = cmd.ExecuteScalar().ToString(); label5.Text = getValue; } catch { NotificationConnectionError a = new NotificationConnectionError(); a.Show(); } }
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(); } }
public void DeleteVote() { try { con.Open(); String query = "delete from votes where voters_id = @voters_id and position = @position"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@voters_id", GlobalVar.voters_id); cmd.Parameters.AddWithValue("@position", GlobalVar.position); cmd.ExecuteNonQuery(); con.Close(); LogHistoryVote(GlobalVar.account_id, GlobalVar.user_type, GlobalVar.user); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
private void BtnEdit_Click(object sender, EventArgs e) { TransparentVoters b = new TransparentVoters(); FrmAddVoters a = new FrmAddVoters(); try { a.lblvotersrid.Text = lblvotersid.Text; a.BtnAddPosition.Visible = false; con.Close(); con.Open(); String query = "select voters.voters_id, voters.first_name, voters.last_name, voters.middle_name, voters.grade, voters.strand, voters.track, account.username from voters inner join account on voters.account_id = account.account_id where voters_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", lblvotersid.Text); MySqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { a.label8.Text = "Edit Voter"; a.lblvotersrid.Text = (dr["voters_id"]).ToString(); a.TxtFirstName.Text = (dr["first_name"]).ToString(); a.TxtLastName.Text = (dr["last_name"]).ToString(); a.TxtMiddleName.Text = (dr["middle_name"]).ToString(); a.TxtFirstName.Enabled = false; a.TxtLastName.Enabled = false; a.TxtMiddleName.Enabled = false; a.TxtGrade.Text = (dr["grade"]).ToString(); a.TxtStrand.Text = (dr["strand"]).ToString(); a.TxtTrack.Text = (dr["track"]).ToString(); a.TxtUsername.Text = (dr["username"]).ToString(); } dr.Close(); con.Close(); b.Show(); a.ShowDialog(); b.Hide(); } catch { NotificationConnectionError c = new NotificationConnectionError(); c.ShowDialog(); } }
public void InserAccount() { try { con.Open(); String query = "INSERT INTO `account` (`username`, `password`, `account_type`) VALUES (@username, @password, @account_type)"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@username", TxtUsername.Text); cmd.Parameters.AddWithValue("@password", SHA256Hasher.ComputeSha256Hash(TxtPassword.Text)); cmd.Parameters.AddWithValue("@account_type", "Voter"); cmd.ExecuteNonQuery(); con.Close(); LogHistoryAddAccount(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void UpdateAccount() { try { con.Open(); String query = "update account set username = @username, password= @password where account_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", user_id); cmd.Parameters.AddWithValue("@username", TxtUsername.Text); cmd.Parameters.AddWithValue("@password", SHA256Hasher.ComputeSha256Hash(TxtPassword.Text)); cmd.ExecuteNonQuery(); con.Close(); LogHistoryEditAccount(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
void RetrievePosition() { try { con.Open(); String query = "select * from position"; MySqlCommand cmd = new MySqlCommand(query, con); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TxtPosition.Items.Add(reader.GetString("position")); } con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void RetrieveVote() { try { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); con.Open(); String query = "select count(*) from votes where candidate_id = @candidate_id and position = @position"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@candidate_id", lblcandidateid.Text); cmd.Parameters.AddWithValue("@position", lblposition.Text); string getValue = cmd.ExecuteScalar().ToString(); lbltotalvotes.Text = "Total Votes: " + getValue; con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.Show(); } }
private void BtnEditTeacher_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 = "update candidate set img = @img, gender = @gender, age = @age, grade = @grade, track = @track, strand = @strand, partylist = @partylist, position = @position, platform = @platform where candidate_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", lblcandidateid.Text); cmd.Parameters.Add("@img", MySqlDbType.LongBlob).Value = a; 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(); LogHistoryEdit(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); NotificationEditSuccess d = new NotificationEditSuccess(); d.ShowDialog(); 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(); } } }
private void BtnDelete_Click(object sender, EventArgs e) { try { con.Open(); String query = "delete from " + GlobalVar.Delete + " where " + GlobalVar.Delete + "_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", lblid.Text); cmd.ExecuteNonQuery(); con.Close(); LogHistoryDelete(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); this.Hide(); NotificationDeleteSuccess a = new NotificationDeleteSuccess(); a.ShowDialog(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
void LogHistoryEdit(string user_id, string user_type, string user) { try { con.Open(); //Query to log history string query3 = "INSERT INTO `loghistory`(`account_id`, `account_type`,`username`, `log`) VALUES (@id, @accid,@user, @logs)"; MySqlCommand cmd3 = new MySqlCommand(query3, con); cmd3.Parameters.AddWithValue("id", user_id); cmd3.Parameters.AddWithValue("accid", user_type); cmd3.Parameters.AddWithValue("user", user); cmd3.Parameters.AddWithValue("logs", user + " has been succesfully edit candidate."); cmd3.ExecuteNonQuery(); con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void GetAccountInfo() { try { con.Open(); String query = "SELECT account_id FROM account WHERE username = @user "; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@user", TxtUsername.Text); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { user_id = reader["account_id"].ToString(); } con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
private void BtnChangePassword_Click(object sender, EventArgs e) { try { con.Open(); String query = "update title set title = @title where title_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", "1"); cmd.Parameters.AddWithValue("@title", TxtTitle.Text); cmd.ExecuteNonQuery(); con.Close(); LogHistoryEdit(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); NotificationEditSuccess a = new NotificationEditSuccess(); a.ShowDialog(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void RetrieveTrackid() { try { con.Open(); String query = "select * from track where track = @track "; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@track", TxtTrack.Text); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { GlobalVar.track_id = reader["track_id"].ToString(); } con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
void LogHistoryUnVote(string user_id, string user_type, string user) { try { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); con.Open(); //Query to log history string query3 = "INSERT INTO `loghistory`(`account_id`, `account_type`,`username`, `log`) VALUES (@id, @accid,@user, @logs)"; MySqlCommand cmd3 = new MySqlCommand(query3, con); cmd3.Parameters.AddWithValue("@id", user_id); cmd3.Parameters.AddWithValue("@accid", user_type); cmd3.Parameters.AddWithValue("@user", user); cmd3.Parameters.AddWithValue("@logs", user + " has been succesfully un - vote " + GlobalVar.candidate_id + " in " + GlobalVar.position); cmd3.ExecuteNonQuery(); con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
private void BtnChangePassword_Click(object sender, EventArgs e) { try { con.Open(); String query = "update partylist set partylist = @partylist where position_id = @id"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@id", lblpartylistid.Text); cmd.Parameters.AddWithValue("@position", TxtPosition.Text); cmd.ExecuteNonQuery(); con.Close(); CloseTransparent(); LogHistoryEdit(GlobalVar.user_id, GlobalVar.user_type, GlobalVar.user); NotificationEditSuccess a = new NotificationEditSuccess(); a.ShowDialog(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
void RetrieveStrand(string track) { TxtStrand.Items.Clear(); try { con.Open(); String query = "select * from strand where track_id = @track "; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.AddWithValue("@track", track); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { TxtStrand.Items.Add(reader.GetString("strand")); } con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.ShowDialog(); } }
public void LogHistoryLogout() { MySqlConnection con = new MySqlConnection(Connection.GetConnectionStr()); try { con.Open(); //Query to log history string query3 = "INSERT INTO `loghistory`(`account_id`, `account_type`,`username`, `log`) VALUES (@id, @accid,@user, @logs)"; MySqlCommand cmd3 = new MySqlCommand(query3, con); cmd3.Parameters.AddWithValue("id", GlobalVar.user_id); cmd3.Parameters.AddWithValue("accid", GlobalVar.user_type); cmd3.Parameters.AddWithValue("user", GlobalVar.user); cmd3.Parameters.AddWithValue("logs", GlobalVar.user + " has been succesfully logout."); cmd3.ExecuteNonQuery(); con.Close(); } catch { NotificationConnectionError a = new NotificationConnectionError(); a.Show(); } }