public void SaveVoter(Voter voter) { if (voter.VoterId != "") { if (!centerGateway.HasThisVoterExists(voter.VoterId)) { centerGateway.InsertVoter(voter); } } }
public Voter VoterInformation(string votercode) { Voter voter = new Voter(); SqlConnection connection = new SqlConnection(connectionstring); string query = "SELECT * FROM Table_Voter WHERE voter_VoterId='" + votercode + "' "; SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { voter.Id = int.Parse(reader["voter_Id"].ToString()); voter.VoterId = reader["voter_VoterId"].ToString(); voter.Name = reader["voter_Name"].ToString(); voter.Address = reader["voter_Address"].ToString(); } reader.Close(); connection.Close(); return voter; }
protected void showDetailasButton_OnClick(object sender, EventArgs e) { string voterid = nationalIdTextBox.Text; voter = centerManager.GetVoterAccordingToId(voterid); nameTextBox.Text = voter.Name; addressTextBox.Text = voter.Address; CreateTreatmentHistoryControls(); CreateGridView(); //ServicesArea(); TreatmentHistoryPrintButton.Enabled = true; }
public int InsertVoter(Voter voter) { SqlConnection connection = new SqlConnection(connectionstring); string query = "INSERT INTO Table_Voter VALUES ('" + voter.VoterId + "','" + voter.Name + "','" + voter.Address + "','" + voter.Age + "')"; SqlCommand command = new SqlCommand(query, connection); connection.Open(); int rowsAffected = command.ExecuteNonQuery(); connection.Close(); return rowsAffected; }