public void LoginPengungjung(string nomorKtp, string nomorTahanan, IOnLoginPengunjungFinishedListener listener)
        {
            connection = ConnectDB.ConnectingDB();


            try
            {
                connection.Open();
                MySqlCommand command = connection.CreateCommand();
                query = "INSERT INTO `jenguk` (`NoKtp_member`, `NoTahanan_napi`, `Date`) VALUES ('" + nomorKtp + "', '" + nomorTahanan + "', CURRENT_TIMESTAMP)";
                command.CommandText = query;
                command.ExecuteNonQuery();
                listener.onSuccessKirim();
            }
            catch (Exception e)

            {
                listener.onErrorKirim();
                Console.WriteLine("Error:" + e);
            }



            connection.Close();
        }
        public void SearchIdNapi(string nomorTahanan, IOnLoginPengunjungFinishedListener listener)
        {
            connection = ConnectDB.ConnectingDB();


            try
            {
                string  query = "SELECT * FROM `napi` WHERE `noTahanan`= '" + nomorTahanan + "'";
                Boolean error = true;

                connection.Open();


                MySqlCommand command = connection.CreateCommand();
                command.CommandText = query;

                MySqlDataReader reader = command.ExecuteReader();


                while (reader.Read())
                {
                    if (reader.GetString(0).ToString() == nomorTahanan)
                    {
                        napiModel.setNomorTahanan(reader.GetString(0).ToString());

                        napiModel.setNamaTahanan(reader.GetString(1).ToString());

                        napiModel.setJenisKelaminTahanan(reader.GetString(2).ToString());

                        napiModel.setKewarganegaraanTahanan(reader.GetString(3).ToString());

                        napiModel.setTanggalLahirTahanan(reader.GetString(4).ToString());

                        napiModel.setAgamaTahanan(reader.GetString(5).ToString());



                        listener.onSuccessCariIdNapi(napiModel);



                        error = false;
                    }
                }

                if (error == true)
                {
                    listener.onErrorCariIdNapi();
                }
                connection.Close();
            }

            catch (Exception e)
            {
                Console.WriteLine("Error:" + e);
            }
        }
Beispiel #3
0
        public void LoginAdmin(String username, String password, IOnLoginAdminFinishedListener listener, AdminModel adminModel)
        {
            connection = ConnectDB.ConnectingDB();
            query      = "SELECT username , password FROM `login` WHERE username = '******' AND password = '******'";

            connection.Open();

            MySqlCommand command = connection.CreateCommand();

            command.CommandText = query;

            MySqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                adminModel.setUsername(reader.GetString(0).ToString());
                adminModel.setPassword(reader.GetString(1).ToString());
            }

            if (username == "" || password == "")
            {
                listener.onEmptyUsernameOrPassword();
            }
            else
            {
                if (username == adminModel.getUsername() && password == adminModel.getPassword())
                {
                    listener.onSuccess();
                }

                else
                {
                    listener.onUsernameAndPasswordError();
                }
            }

            connection.Close();
        }
Beispiel #4
0
 public LoginPengunjung()
 {
     connection = ConnectDB.ConnectingDB();
     InitializeComponent();
     presenter = new LoginPengunjungPresenterImpl(this);
 }
        public void SearchIdMember(string nomorKtp, IOnLoginPengunjungFinishedListener listener)
        {
            connection = ConnectDB.ConnectingDB();

            try
            {
                connection.Open();
                string query = "SELECT * FROM `member` WHERE `noKTP`= '" + nomorKtp + "'";

                Boolean error = true;

                MySqlCommand command = connection.CreateCommand();
                command.CommandText = query;

                MySqlDataReader reader = command.ExecuteReader();


                while (reader.Read())
                {
                    if (reader.GetString(0).ToString() == nomorKtp)
                    {
                        memberModel.setNomorKtp(reader.GetString(0).ToString());


                        memberModel.setNama(reader.GetString(1).ToString());


                        memberModel.setJenisKelamin(reader.GetString(2).ToString());

                        memberModel.setKewarganegaraan(reader.GetString(3).ToString());

                        memberModel.setTanggalLahir(reader.GetString(4).ToString());


                        memberModel.setAgama(reader.GetString(5).ToString());


                        memberModel.setNomorTlp(reader.GetString(6).ToString());

                        memberModel.setEmail(reader.GetString(7).ToString());



                        memberModel.setAlamat(reader.GetString(8).ToString());



                        memberModel.setKecamatan(reader.GetString(9).ToString());


                        memberModel.setRtRw(reader.GetString(10).ToString());

                        listener.onSuccessCariIdMember(memberModel);

                        error = false;
                    }
                }

                if (error == true)
                {
                    listener.onErrorCariIdMember();
                }
                connection.Close();
            }

            catch (Exception e)
            {
                Console.WriteLine("Error:" + e);
            }
        }
Beispiel #6
0
        public void Daftar(MemberModel memberModel, IOnDaftarFinishedListener listener)
        {
            MySqlConnection connection = ConnectDB.ConnectingDB();
            String          query;
            bool            gender;

            //Logic getGender
            {
                if (memberModel.getJenisKelamin() == bool.TrueString)
                {
                    memberModel.setJenisKelamin("Laki-laki");
                }

                else
                {
                    memberModel.setJenisKelamin("Perempuan");
                }
            }

            //Logic dataModel
            {
                //Logic empty dataModel
                if (
                    memberModel.getNomorKtp() == "" ||
                    memberModel.getNama() == "" ||
                    memberModel.getJenisKelamin() == "" ||
                    memberModel.getKewarganegaraan() == "" ||
                    memberModel.getTanggalLahir() == "" ||
                    memberModel.getAgama() == "" ||
                    memberModel.getNomorTlp() == "" ||
                    memberModel.getEmail() == "" ||
                    memberModel.getAlamat() == "" ||
                    memberModel.getKecamatan() == "" ||
                    memberModel.getRtRw() == "")
                {
                    listener.onEmptyInsertData();
                }

                else
                {
                    try
                    {
                        connection.Open();
                        query = "INSERT INTO `member` (`noKTP`, `nama`, `jenis kelamin`, `kewarganegaraan`, `tempat tanggal lahir`, `agama`, `nomor telepon`, `email`, `alamat`, `kecamatan`, `RT/RW`) VALUES (" +
                                "'" + memberModel.getNomorKtp() + "', " +
                                "'" + memberModel.getNama() + "', " +
                                "'" + memberModel.getJenisKelamin() + "', " +
                                "'" + memberModel.getKewarganegaraan() + "', " +
                                "'" + memberModel.getTanggalLahir() + "', " +
                                "'" + memberModel.getAgama() + "', " +
                                "'" + memberModel.getNomorTlp() + "', " +
                                "'" + memberModel.getEmail() + "', " +
                                "'" + memberModel.getAlamat() + "', " +
                                "'" + memberModel.getKecamatan() + "', " +
                                "'" + memberModel.getRtRw() + "'" +
                                ")";
                        MySqlCommand createCommand = new MySqlCommand(query, connection);


                        //Validasi Data di input atau tidak
                        DialogResult dialog = System.Windows.Forms.MessageBox.Show("Apakah Anda Yakin Data ini Valid?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        if (dialog == System.Windows.Forms.DialogResult.Yes)
                        {
                            createCommand.ExecuteNonQuery();
                            listener.onSuccesInsertData();
                        }
                    }
                    catch (Exception e)
                    {
                        listener.onErrorInsertData();

                        Console.WriteLine("Error:" + e);
                    }
                }
            }
        }