Beispiel #1
0
        public bool validateUser(string ID)
        {
            koneksi       con   = new koneksi();
            SqlConnection sqcon = con.connection();

            using (sqcon)
            {
                sqcon.Open();
                string     com    = "select COUNT (*) from Pemilihan where NIM = @NIM";
                SqlCommand sqcomm = new SqlCommand(com, sqcon);
                int        result = 0;
                using (sqcomm)
                {
                    sqcomm.Parameters.AddWithValue("@NIM", ID);

                    result = (int)sqcomm.ExecuteScalar();
                    if (result > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                sqcon.Close();
            }
        }
Beispiel #2
0
        public int doVote(VoteInfo suara)
        {
            koneksi       con    = new koneksi();
            SqlConnection sqcon  = con.connection();
            int           result = 0;

            var d = DateTime.ParseExact(date, "YYYY-MM-dd", CultureInfo.InvariantCulture);

            using (sqcon)
            {
                sqcon.Open();

                string     com    = "INSERT INTO Pemilihan VALUES(@nim, @nomor, @tgl)";
                SqlCommand sqcomm = new SqlCommand(com, sqcon);

                using (sqcomm)
                {
                    sqcomm.Parameters.AddWithValue("@nomor", suara.Nomor_Urut);
                    sqcomm.Parameters.AddWithValue("@nim", suara.NIM);
                    sqcomm.Parameters.AddWithValue("@tgl", d);

                    result = sqcomm.ExecuteNonQuery();
                }
                sqcon.Close();
            }
            return(result);
        }
Beispiel #3
0
        public double VoteCount(int Nomor)
        {
            koneksi       con    = new koneksi();
            SqlConnection sqcon  = con.connection();
            double        result = 0;

            using (sqcon)
            {
                sqcon.Open();
                string     com    = "SELECT * from vHasil_suara where nomor_urut = @Nomor";
                SqlCommand sqcomm = new SqlCommand(com, sqcon);
                using (sqcomm)
                {
                    sqcomm.Parameters.AddWithValue("@Nomor", Nomor);
                    SqlDataReader dr = sqcomm.ExecuteReader();
                    dr.Read();
                    if (dr.HasRows)
                    {
                        double pemilih = dr.GetInt32(1);
                        double jSiswa  = dr.GetInt32(2);

                        double y = (pemilih / jSiswa) * 100;
                        result = Convert.ToDouble(String.Format("{0:0}", y));
                    }
                }

                return(result);

                sqcon.Close();
            }
        }
        public bool login(string ID, string Password)
        {
            koneksi       con   = new koneksi();
            SqlConnection sqcon = con.connection();

            using (sqcon)
            {
                sqcon.Open();
                string     com    = "select COUNT (*) from mahasiswa where NIM = @NIM AND password = @pwd";
                SqlCommand sqcomm = new SqlCommand(com, sqcon);
                int        result = 0;
                using (sqcomm)
                {
                    sqcomm.Parameters.AddWithValue("@pwd", Password);
                    sqcomm.Parameters.AddWithValue("@NIM", ID);

                    result = (int)sqcomm.ExecuteScalar();
                    if (result > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                sqcon.Close();
            }
        }
Beispiel #5
0
        public List <KandidatInfo> ShowKandidat()
        {
            koneksi             con    = new koneksi();
            SqlConnection       sqcon  = con.connection();
            List <KandidatInfo> lisKad = new List <KandidatInfo>();

            using (sqcon)
            {
                sqcon.Open();

                string     com     = "select * from vKandidat";
                SqlCommand sqlcomm = new SqlCommand(com, sqcon);

                using (sqlcomm)
                {
                    SqlDataReader dr = sqlcomm.ExecuteReader();
                    //kd.nomorUrut = dr.GetInt32(0);
                    //kd.nama = dr.GetString(1);
                    //kd.jurusan = dr.GetString(2);
                    //kd.prodi = dr.GetString(3);
                    //kd.visi = (dr["Visi"]).ToString();
                    //kd.misi = (dr["Misi"]).ToString();
                    //if (!Convert.IsDBNull(dr["Foto"]))
                    //{
                    //    kd.picture = (byte[])(dr["Foto"]);
                    //}

                    //lisKad.Add(kd);

                    while (dr.Read())
                    {
                        KandidatInfo kd = new KandidatInfo();
                        kd.nomorUrut = dr.GetInt32(0);
                        kd.nama      = dr.GetString(1);
                        kd.jurusan   = dr.GetString(2);
                        kd.prodi     = dr.GetString(3);
                        kd.visi      = (dr["Visi"]).ToString();
                        kd.misi      = (dr["Misi"]).ToString();
                        if (!Convert.IsDBNull((dr["Foto"])))
                        {
                            kd.picture = (byte[])(dr["Foto"]);
                        }
                        else
                        {
                            kd.picture = null;
                        }

                        lisKad.Add(kd);
                    }
                }
                sqcon.Close();
            }
            return(lisKad);
        }