Beispiel #1
0
        public void hapusJenisSurat(string idJenis)
        {
            Database        db   = new Database();
            MySqlConnection conn = db.connect(db.getString());

            conn.Open();

            string       query = "DELETE FROM jenis_surat WHERE id_jenis = @id_jenis";
            MySqlCommand cmd   = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@id_jenis", idJenis);
            //MessageBox.Show(query);
            int sukses = cmd.ExecuteNonQuery();

            if (sukses > 0)
            {
                JenisSurat jenis_surat = new JenisSurat();
                MessageBox.Show("Data berhasil dihapus.", "Sukses");
            }
            else
            {
                MessageBox.Show("Data gagal dihapus", "Gagal");
            }
            conn.Close();
        }
        private void tambahJenisSurat()
        {
            JenisSurat j = new JenisSurat();
            j.setJenis(textBoxJenis.Text);
            string jenis = j.getJenis();

            Database db = new Database();
            string strconn = db.getString();
            MySqlConnection conn = new MySqlConnection(strconn);
            conn.Open();
            string query = "INSERT INTO jenis_surat VALUES(NULL, @jenis)";
            MySqlCommand cmd = new MySqlCommand(query, conn);
            cmd.Parameters.AddWithValue("@jenis", jenis);
            int hasil = cmd.ExecuteNonQuery();
            if (hasil > 0)
            {
                MessageBox.Show("Data berhasil ditambah", "Sukses");
                frm1.getAllJenisSurat();

            }
            else
            {
                MessageBox.Show("Data gagal ditambah", "Gagal");
            }

            conn.Close();
        }
        private void tambahJenisSurat()
        {
            JenisSurat j = new JenisSurat();

            j.setJenis(textBoxJenis.Text);
            string jenis = j.getJenis();

            Database        db      = new Database();
            string          strconn = db.getString();
            MySqlConnection conn    = new MySqlConnection(strconn);

            conn.Open();
            string       query = "INSERT INTO jenis_surat VALUES(NULL, @jenis)";
            MySqlCommand cmd   = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@jenis", jenis);
            int hasil = cmd.ExecuteNonQuery();

            if (hasil > 0)
            {
                MessageBox.Show("Data berhasil ditambah", "Sukses");
                frm1.getAllJenisSurat();
            }
            else
            {
                MessageBox.Show("Data gagal ditambah", "Gagal");
            }

            conn.Close();
        }
        private void FormKlasifikasiSurat_Load(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.getAllJenisSurat());
            //comboBoxJenisSurat.SelectedIndex = 0;
            loadComboBox();
        }
Beispiel #5
0
        private void buttonEditJenisSurat_Click(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            jenis_surat.id_jenis   = id_jenis;
            jenis_surat.nama_jenis = textBoxEditJenisSurat.Text;
            jenis_surat.editJenisSurat();
            frm1.setDataTable(jenis_surat.getAllJenisSurat());
            frm1.loadComboBox();
        }
Beispiel #6
0
        private void buttonTambah_Click(object sender, EventArgs e)
        {
            JenisSurat j = new JenisSurat();

            j.nama_jenis = textBoxJenis.Text;
            j.tambahJenisSurat();
            frm1.setDataTable(j.getAllJenisSurat());

            frm1.loadComboBox();
        }
        public void loadComboBox()
        {
            JenisSurat jenis_surat = new JenisSurat();
            DataTable  tabel       = new DataTable();

            tabel.Load(jenis_surat.getAllJenisSurat());
            List <string> jenis = new List <string>();

            comboBoxJenisSurat.Items.Clear();
            for (int i = 0; i < tabel.Rows.Count; i++)
            {
                comboBoxJenisSurat.Items.Add(tabel.Rows[i][1].ToString());
            }
        }
        private void buttonHapusJenisSurat_Click(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();
            string     title       = "Konfirmasi Penghapusan Data";
            string     konten      = "Apakah Anda yakin ingin menghapus data?";

            DialogResult result = MessageBox.Show(konten, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                jenis_surat.hapusJenisSurat(id_jenis);
                setDataTable(jenis_surat.getAllJenisSurat());
                loadComboBox();
            }
        }
Beispiel #9
0
        public MySqlDataReader cariJenisSurat(string cari)
        {
            JenisSurat jenis_surat = new JenisSurat();

            Database        db     = new Database();
            MySqlConnection conn   = db.connect(db.getString());
            MySqlDataReader reader = null;

            conn.Open();

            string query = "SELECT * FROM jenis_surat WHERE nama_jenis LIKE '%" + cari + "%'";
            //MessageBox.Show(query);
            MySqlCommand cmd = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@cari", cari);
            reader = cmd.ExecuteReader();

            return(reader);
        }
        private void cariJenisSurat()
        {
            JenisSurat jenis = new JenisSurat();
            string     cari  = textBoxCari.Text;

            Database        db      = new Database();
            string          strconn = db.getString();
            MySqlConnection conn    = new MySqlConnection(strconn);

            conn.Open();

            string query = "SELECT * FROM jenis_surat WHERE nama_jenis LIKE '%" + cari + "%'";
            //MessageBox.Show(query);
            MySqlCommand cmd = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@cari", cari);
            MySqlDataReader reader = cmd.ExecuteReader();

            setDataTable(reader);
            conn.Close();
        }
        private void cariJenisSurat()
        {
            JenisSurat jenis = new JenisSurat();
            string cari = textBoxCari.Text;

            Database db = new Database();
            string strconn =  db.getString();
            MySqlConnection conn = new MySqlConnection(strconn);
            conn.Open();

            string query = "SELECT * FROM jenis_surat WHERE nama_jenis LIKE '%"+cari+"%'";
            //MessageBox.Show(query);
            MySqlCommand cmd = new MySqlCommand(query, conn);
            cmd.Parameters.AddWithValue("@cari", cari);
            MySqlDataReader reader = cmd.ExecuteReader();

            setDataTable(reader);
            conn.Close();
        }
        private void textBoxCari_TextChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.cariJenisSurat(textBoxCari.Text));
        }
        private void comboBoxJenisSurat_TextChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.cariJenisSurat(comboBoxJenisSurat.Text));
        }
        private void comboBoxJenisSurat_SelectedIndexChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.cariJenisSurat(comboBoxJenisSurat.GetItemText(comboBoxJenisSurat.SelectedItem)));
        }