Ejemplo n.º 1
0
        public bool DeleteThisCandidate(ManageCandidate aManageCandidate)
        {
            aSqlConnection.Open();
            string     query       = "DELETE FROM t_candidate WHERE candidate_name = '" + aManageCandidate.DeleteCandidate + "'";
            SqlCommand aCommand    = new SqlCommand(query, aSqlConnection);
            int        affectedRow = aCommand.ExecuteNonQuery();

            if (affectedRow > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool SaveNewCandidate(ManageCandidate aManageCandidate)
        {
            aSqlConnection.Open();
            string query = " INSERT INTO t_candidate (candidate_name , candidate_password, candidate_symbol, number_of_vote) VALUES ('" +
                           aManageCandidate.CandidateName + "' , '" + aManageCandidate.CandidatePassword + "' ,'" + aManageCandidate.CandidateSymbol + "', '0') ";
            SqlCommand aCommand    = new SqlCommand(query, aSqlConnection);
            int        affectedRow = aCommand.ExecuteNonQuery();

            aSqlConnection.Close();
            if (affectedRow > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public bool IsThisDataExist(ManageCandidate aManageCandidate)
        {
            aSqlConnection.Open();
            string        selectQuery = "SELECT * FROM t_candidate where candidate_name = '" + aManageCandidate.CandidateName + "'";
            SqlCommand    aSqlCommand = new SqlCommand(selectQuery, aSqlConnection);
            SqlDataReader aReader     = aSqlCommand.ExecuteReader();

            while (aReader.Read())
            {
                aSqlConnection.Close();
                return(true);
            }
            aSqlConnection.Close();
            return(false);
        }
Ejemplo n.º 4
0
        public List <DAL.DAO.ManageCandidate> FillComboBox()
        {
            aSqlConnection.Open();
            string                 query          = "SELECT * FROM t_candidate";
            SqlCommand             command        = new SqlCommand(query, aSqlConnection);
            SqlDataReader          aReader        = command.ExecuteReader();
            List <ManageCandidate> candidatesList = new List <ManageCandidate>();

            while (aReader.Read())
            {
                ManageCandidate aCandidate = new ManageCandidate();
                aCandidate.CandidateSymbol = aReader["candidate_symbol"].ToString();
                candidatesList.Add(aCandidate);
            }
            aSqlConnection.Close();

            return(candidatesList);
        }
Ejemplo n.º 5
0
        public List <ManageCandidate> LoadGridView()
        {
            aSqlConnection.Open();
            string                 query          = "SELECT * FROM t_candidate";
            SqlCommand             command        = new SqlCommand(query, aSqlConnection);
            SqlDataReader          aReader        = command.ExecuteReader();
            List <ManageCandidate> candidatesList = new List <ManageCandidate>();

            while (aReader.Read())
            {
                ManageCandidate aCandidate = new ManageCandidate();
                aCandidate.CandidateName     = aReader["candidate_name"].ToString();
                aCandidate.CandidateSymbol   = aReader["candidate_symbol"].ToString();
                aCandidate.CandidatePassword = aReader["candidate_password"].ToString();
                aCandidate.NumberOfVote      = (int)aReader["number_of_vote"];
                candidatesList.Add(aCandidate);
            }
            aSqlConnection.Close();

            return(candidatesList);
        }