コード例 #1
0
ファイル: JenisSurat.cs プロジェクト: hilmi-a/surat-master
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        private void FormKlasifikasiSurat_Load(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.getAllJenisSurat());
            //comboBoxJenisSurat.SelectedIndex = 0;
            loadComboBox();
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
ファイル: JenisSurat.cs プロジェクト: hilmi-a/surat-master
        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);
        }
コード例 #10
0
        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();
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        private void textBoxCari_TextChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.cariJenisSurat(textBoxCari.Text));
        }
コード例 #13
0
        private void comboBoxJenisSurat_TextChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

            setDataTable(jenis_surat.cariJenisSurat(comboBoxJenisSurat.Text));
        }
コード例 #14
0
        private void comboBoxJenisSurat_SelectedIndexChanged(object sender, EventArgs e)
        {
            JenisSurat jenis_surat = new JenisSurat();

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