public void editUser() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { //MessageBox.Show(hak_akses); string query = "UPDATE user SET username = @username, password = @password, nama = @nama, hak_akses = @hak_akses WHERE id_user = @id_user"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@id_user", id_user); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@password", password); cmd.Parameters.AddWithValue("@nama", nama); cmd.Parameters.AddWithValue("@hak_akses", hak_akses); //MessageBox.Show(query); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil diupdate", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public void tambahUser() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "INSERT INTO user VALUES(NULL, @username, @password, @nama, @hak_akses)"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@password", password); cmd.Parameters.AddWithValue("@nama", nama); cmd.Parameters.AddWithValue("@hak_akses", hak_akses); int hasil = cmd.ExecuteNonQuery(); if (hasil > 0) { MessageBox.Show("Data berhasil ditambah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Data gagal ditambah.", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Warning); } conn.Close(); }
public void hapusSuratDisposisi(string nomor_surat) { DialogResult result = MessageBox.Show("Apakah Anda yakin ingin menghapus data?", "Konfirmasi Penghapusan Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { hapusDisposisiBidang(nomor_surat); string query = "DELETE FROM surat_disposisi WHERE nomor_surat = @nomor_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil dihapus.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); } }
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(); }
public void tambahKabag(List <string> list_kabag) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { foreach (var kabag in list_kabag) { string query = "INSERT INTO disposisi_bagian VALUES(@nomor_surat, (SELECT id_bagian_bidang FROM bagian_bidang WHERE nama_bagian_bidang = @bagian))"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.Parameters.AddWithValue("@bagian", kabag); cmd.ExecuteNonQuery(); } } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public Dictionary <string, string> lihatSuratMasuk(string nomor_surat) { Dictionary <string, string> surat_masuk = new Dictionary <string, string>(); Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "SELECT * FROM surat_masuk WHERE nomor_surat_masuk = @nomor_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { surat_masuk.Add("nomor_surat", nomor_surat); surat_masuk.Add("perihal", reader["perihal"].ToString()); surat_masuk.Add("perihal", reader["perihal"].ToString()); if (reader["tanggal_terima"].ToString().Equals("1/1/0001")) { textBoxTanggalTerima.Text = ""; } else { textBoxTanggalTerima.Text = reader["tanggal_terima"].ToString(); } if (reader["tanggal_surat"].ToString().Equals("1/1/0001")) { textBoxTanggalSurat.Text = ""; } else { textBoxTanggalSurat.Text = reader["tanggal_surat"].ToString(); } textBoxInstansiPengirimSuratMasuk.Text = reader["pengirim"].ToString(); textBoxAlamatPengirimSuratMasuk.Text = reader["alamat_pengirim"].ToString(); textBoxPenerimaSuratMasuk.Text = reader["penerima"].ToString(); textBoxJabatanTertandaSuratMasuk.Text = reader["jabatan_tertanda"].ToString(); textBoxTertandaPengirimSuratMasuk.Text = reader["tertanda"].ToString(); if (reader["distribusi_tanggal"].ToString().Equals("1/1/0001")) { textBoxTanggalDistribusi.Text = ""; } else { textBoxTanggalDistribusi.Text = reader["distribusi_tanggal"].ToString(); } textBoxKeteranganSuratMasuk.Text = reader["keterangan"].ToString(); textBoxIsiSuratMasuk.Text = reader["isi_singkat"].ToString(); pictureBoxGambarSuratMasuk.Image = new Bitmap(Application.StartupPath + "\\image_surat_masuk\\" + reader["gambar_surat"].ToString()); } } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); return(surat_masuk); }
public MySqlDataReader getAllJenisSurat() { Database db = new Database(); MySqlDataReader reader = null; MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "SELECT * FROM jenis_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); reader = cmd.ExecuteReader(); return(reader); }
public MySqlDataReader getAllUser() { Database db = new Database(); MySqlDataReader reader = null; MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "SELECT id_user, username, nama, hak_akses FROM user"; MySqlCommand cmd = new MySqlCommand(query, conn); reader = cmd.ExecuteReader(); return(reader); }
public void getJenisSurat() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "SELECT nama_jenis FROM jenis_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { comboBoxJenisSuratKeluar.Items.Add(reader[0]); } conn.Close(); }
public void tambahSuratMasuk() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "INSERT INTO surat_masuk(nomor_surat_masuk, perihal, tanggal_surat, tanggal_terima, id_jenis, " + "sifat_surat, pengirim, alamat_pengirim, penerima, " + "distribusi_tanggal, isi_singkat, keterangan, gambar_surat, tanggal_update) " + "VALUES(@nomor_surat, @perihal_surat, STR_TO_DATE(@tanggal_surat, '%d-%m-%Y'), " + "STR_TO_DATE(@tanggal_terima, '%d-%m-%Y'), @id_jenis, " + "@sifat_surat, @pengirim, @alamat_pengirim, @penerima, " + "STR_TO_DATE(@distribusi_tanggal, '%d-%m-%Y'), @isi_singkat, @keterangan, @gambar_surat, NOW())"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.Parameters.AddWithValue("@sifat_surat", sifat_surat); cmd.Parameters.AddWithValue("@id_jenis", getIdJenisSurat(jenis_surat)); cmd.Parameters.AddWithValue("@gambar_surat", gambar); cmd.Parameters.AddWithValue("@perihal_surat", perihal_surat); cmd.Parameters.AddWithValue("@tanggal_surat", tgl_surat); cmd.Parameters.AddWithValue("@tanggal_terima", tgl_terima); cmd.Parameters.AddWithValue("@pengirim", pengirim); cmd.Parameters.AddWithValue("@alamat_pengirim", alamat_pengirim); cmd.Parameters.AddWithValue("@penerima", penerima); //cmd.Parameters.AddWithValue("@jabatan_tertanda", jabatan_tertanda); //cmd.Parameters.AddWithValue("@tertanda", tertanda); cmd.Parameters.AddWithValue("@distribusi_tanggal", tanggal_distribusi); cmd.Parameters.AddWithValue("@isi_singkat", isi_surat); cmd.Parameters.AddWithValue("@keterangan", keterangan_surat); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil ditambah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { if (ex.Number == 1062) { MessageBox.Show("Nomor surat yang dimaksud telah ada dalam database. Silahkan ubah nomor surat yang ingin dimasukkan.", "Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show(ex.ToString()); } } conn.Close(); }
public void editSuratMasuk() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "UPDATE surat_masuk SET nomor_surat_masuk = @nomor_surat, perihal = @perihal_surat, " + "tanggal_surat = STR_TO_DATE(@tanggal_surat, '%d-%m-%Y'), " + "tanggal_terima = STR_TO_DATE(@tanggal_terima, '%d-%m-%Y'), " + "id_jenis = @id_jenis, " + "sifat_surat = @sifat_surat, pengirim = @pengirim, " + "alamat_pengirim = @alamat_pengirim, penerima = @penerima, " + "distribusi_tanggal = STR_TO_DATE(@distribusi_tanggal, '%d-%m-%Y'), " + "isi_singkat = @isi_singkat, keterangan = @keterangan, " + "gambar_surat = @gambar_surat, tanggal_update = NOW() " + "WHERE nomor_surat_masuk = @nomor_surat_sebelumnya"; // MessageBox.Show(nama_gambar); MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.Parameters.AddWithValue("@sifat_surat", sifat_surat); cmd.Parameters.AddWithValue("@id_jenis", getIdJenisSurat(jenis_surat)); cmd.Parameters.AddWithValue("@gambar_surat", gambar); cmd.Parameters.AddWithValue("@perihal_surat", perihal_surat); cmd.Parameters.AddWithValue("@tanggal_surat", tgl_surat); cmd.Parameters.AddWithValue("@tanggal_terima", tgl_terima); cmd.Parameters.AddWithValue("@pengirim", pengirim); cmd.Parameters.AddWithValue("@alamat_pengirim", alamat_pengirim); cmd.Parameters.AddWithValue("@penerima", penerima); //cmd.Parameters.AddWithValue("@jabatan_tertanda", jabatan_tertanda); //cmd.Parameters.AddWithValue("@tertanda", tertanda); cmd.Parameters.AddWithValue("@distribusi_tanggal", tanggal_distribusi); cmd.Parameters.AddWithValue("@isi_singkat", isi_surat); cmd.Parameters.AddWithValue("@keterangan", keterangan_surat); cmd.Parameters.AddWithValue("@nomor_surat_sebelumnya", FormSuratMasuk.nomor_surat); //cmd.Parameters.AddWithValue("@id_user", FormMain.id_user); cmd.ExecuteNonQuery(); MessageBox.Show("Edit data berhasil.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public MySqlDataReader cariuser(string cari) { user usernames = new user(); Database db = new Database(); MySqlDataReader reader = null; MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "SELECT id_user, username, nama, hak_akses FROM user WHERE username LIKE '%" + cari + "%'"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@cari", cari); reader = cmd.ExecuteReader(); return(reader); }
public bool cekLogin(string username, string password) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); bool benar = false; try { conn.Open(); string query = "SELECT * FROM user WHERE username = @username AND password = @password"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@username", username); cmd.Parameters.AddWithValue("@password", password); MySqlDataReader reader = cmd.ExecuteReader(); if (!reader.Read()) { MessageBox.Show("Username atau Password salah. Silahkan ulangi kembali.", "Kesalahan"); } else { benar = true; id_user = reader[0].ToString(); hak_akses = reader[4].ToString(); if (hak_akses == "Admin") { FormLogin form_login = new FormLogin(); FormMainAdmin main = new FormMainAdmin(); main.Show(); } else if (hak_akses == "User") { FormLogin form_login = new FormLogin(); FormMain main = new FormMain(); main.Show(); } } conn.Close(); } catch (MySqlException) { db.createDatabase(); this.cekLogin(username, password); } return(benar); }
public MySqlDataReader getAllBidang() { MySqlDataReader reader = null; Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "SELECT id_bagian_bidang, nama_bagian_bidang FROM bagian_bidang"; MySqlCommand cmd = new MySqlCommand(query, conn); reader = cmd.ExecuteReader(); } catch (MySqlException e) { MessageBox.Show(e.ToString()); } return(reader); }
public void deleteDistribusiSuratMasuk(string nomor_surat) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "DELETE FROM detail_bagian_bidang_surat_masuk WHERE nomor_surat_masuk = @nomor_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.ExecuteNonQuery(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
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); }
public void hapusDisposisiBidang(string nomor_surat) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "DELETE FROM disposisi_bagian WHERE nomor_surat = @nomor_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.ExecuteNonQuery(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public string getIdJenisSurat(string nama_jenis) { string id_jenis = ""; Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "SELECT id_jenis FROM jenis_surat WHERE nama_jenis = @nama_jenis"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nama_jenis", nama_jenis); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { id_jenis = reader[0].ToString(); } conn.Close(); return(id_jenis); }
public void deleteSuratMasuk(string nomor_surat) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "DELETE FROM surat_masuk WHERE nomor_surat_masuk = @nomor_surat"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil dihapus.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
//public void setBidang(string bidang) //{ // this.nama_bidang = bidang; //} //public string getBidang() //{ // return this.nama_bidang; //} public void tambahBidang(string nama_bidang) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "INSERT INTO bagian_bidang VALUES(NULL, @nama_bagian_bidang)"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nama_bagian_bidang", nama_bidang); cmd.ExecuteNonQuery(); MessageBox.Show("Bagian/Bidang berhasil ditambah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException e) { MessageBox.Show(e.ToString()); } conn.Close(); }
public MySqlDataReader getAllSuratDisposisi() { Database db = new Database(); MySqlDataReader reader = null; MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "SELECT @s:=@s+1 AS nomor, nomor_surat, nomor_agenda, DATE_FORMAT(tanggal_surat, '%d-%m-%Y'), DATE_FORMAT(tanggal_terima, '%d-%m-%Y'), " + "DATE_FORMAT(tanggal_diteruskan, '%d-%m-%Y'), asal, perihal, sifat " + "FROM surat_disposisi, (SELECT @s:=0) AS s ORDER BY nomor ASC"; MySqlCommand cmd = new MySqlCommand(query, conn); reader = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } return(reader); }
public MySqlDataReader cariSuratMasuk(string kriteria, string cari) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); MySqlDataReader reader = null; conn.Open(); try { string query = "SELECT @s:=@s+1 AS nomor, nomor_surat_masuk, DATE_FORMAT(tanggal_surat, '%d-%m-%Y'), DATE_FORMAT(tanggal_terima, '%d-%m-%Y'), perihal, pengirim, sifat_surat, j.nama_jenis AS jenis_surat " + "FROM surat_masuk JOIN jenis_surat AS j USING(id_jenis) , (SELECT @s:= 0) AS s " + "WHERE " + kriteria + " LIKE '%" + cari + "%' ORDER BY nomor ASC"; MySqlCommand cmd = new MySqlCommand(query, conn); reader = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } return(reader); }
public void tambahSuratKeluar() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "INSERT INTO surat_keluar(nomor_surat_keluar, perihal, tanggal_surat, id_jenis, sifat_surat, " + "penerima, " + "distribusi_tanggal, isi_singkat, keterangan, gambar_surat, tanggal_update) " + "VALUES(@nomor_surat, @perihal_surat, STR_TO_DATE(@tanggal_surat, '%d-%m-%Y'), " + "@id_jenis, @sifat_surat, " + "@penerima, " + "STR_TO_DATE(@distribusi_tanggal, '%d-%m-%Y'), @isi_singkat, @keterangan, @gambar_surat, NOW())"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.Parameters.AddWithValue("@id_jenis", getIdJenisSurat(jenis_surat)); cmd.Parameters.AddWithValue("@sifat_surat", sifat_surat); cmd.Parameters.AddWithValue("@perihal_surat", perihal_surat); cmd.Parameters.AddWithValue("@tanggal_surat", tgl_surat); cmd.Parameters.AddWithValue("@penerima", penerima); //cmd.Parameters.AddWithValue("@jabatan_tertanda", jabatan_tertanda); //cmd.Parameters.AddWithValue("@tertanda_pengirim", tertanda_pengirim); cmd.Parameters.AddWithValue("@distribusi_tanggal", distribusi_tanggal); cmd.Parameters.AddWithValue("@isi_singkat", isi_surat); cmd.Parameters.AddWithValue("@keterangan", keterangan_surat); cmd.Parameters.AddWithValue("@gambar_surat", gambar); //cmd.Parameters.AddWithValue("@id_user", FormMain.id_user); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil ditambah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public void tambahJenisSurat() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "INSERT INTO jenis_surat VALUES(NULL, @jenis)"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@jenis", nama_jenis); int hasil = cmd.ExecuteNonQuery(); if (hasil > 0) { MessageBox.Show("Data berhasil ditambah", "Sukses"); } else { MessageBox.Show("Data gagal ditambah", "Gagal"); } conn.Close(); }
public MySqlDataReader getAllSuratMasuk() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); MySqlDataReader reader = null; try { string query = "SELECT @s:=@s+1 AS nomor, nomor_surat_masuk, DATE_FORMAT(tanggal_surat, '%d-%m-%Y'), DATE_FORMAT(tanggal_terima, '%d-%m-%Y'), perihal, pengirim, sifat_surat, j.nama_jenis AS jenis_surat " + "FROM surat_masuk JOIN jenis_surat AS j USING(id_jenis), (SELECT @s:= 0) AS s ORDER BY nomor ASC"; MySqlCommand cmd = new MySqlCommand(query, conn); //cmd.Parameters.AddWithValue("@col", "2"); reader = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } return(reader); }
public void tambahLampiran() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { foreach (string lampiran in FormSuratKeluarLampiran.list_lampiran) { string query = "INSERT INTO lampiran_surat_keluar VALUES(NULL, @lampiran, @nomor_surat_keluar)"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@lampiran", lampiran); cmd.Parameters.AddWithValue("@nomor_surat_keluar", nomor_surat); cmd.ExecuteNonQuery(); } } catch (MySqlException ex) { MessageBox.Show(ex.ToString()); } conn.Close(); }
public void hapusUser(string id_user) { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "DELETE FROM user WHERE id_user = @id_user"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@id_user", id_user); int sukses = cmd.ExecuteNonQuery(); if (sukses > 0) { MessageBox.Show("Data berhasil dihapus.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Data gagal dihapus.", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Warning); } conn.Close(); }
public void editJenisSurat() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); string query = "UPDATE jenis_surat SET nama_jenis = @nama_jenis WHERE id_jenis = @id_jenis"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@id_jenis", id_jenis); cmd.Parameters.AddWithValue("@nama_jenis", nama_jenis); //MessageBox.Show(query); int sukses = cmd.ExecuteNonQuery(); if (sukses > 0) { MessageBox.Show("Data berhasil diubah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Data gagal diubah.", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Information); } conn.Close(); }
public void tambahSuratDisposisi() { Database db = new Database(); MySqlConnection conn = db.connect(db.getString()); conn.Open(); try { string query = "INSERT INTO surat_disposisi (nomor_surat, nomor_agenda, tanggal_surat, tanggal_terima, tanggal_diteruskan, " + "asal, sifat, perihal, perintah, disposisi_lain, diproses_diselesaikan, dilaksanakan, " + "ditanggapi, diperhatikan, dilaporkan, diketahui, diedarkan, diperbanyak_dicopy, " + "ditampung, dihadiri_diwakilkan, dikonsepkan_jawaban, dievaluasi_diteliti, saran_pendapat, " + "disimpan_file_arsip, gambar_surat, tanggal_update)" + "VALUES(@nomor_surat, @nomor_agenda, STR_TO_DATE(@tanggal_surat, '%d-%m-%Y'), " + "STR_TO_DATE(@tanggal_diterima, '%d-%m-%Y'), STR_TO_DATE(@tanggal_diteruskan, '%d-%m-%Y'), " + "@asal, @sifat, @perihal, @perintah, @lain, @diproses, @dilaksanakan, @ditanggapi, @diperhatikan, " + "@dilaporkan, @diketahui, @diedarkan, @diperbanyak, @ditampung, @dihadiri, @dikonsepkan, " + "@dievaluasi, @saran_pendapat, @disimpan, @gambar_surat, NOW())"; MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@nomor_surat", nomor_surat); cmd.Parameters.AddWithValue("@nomor_agenda", nomor_agenda); cmd.Parameters.AddWithValue("@tanggal_surat", tanggal_surat); cmd.Parameters.AddWithValue("@tanggal_diterima", tanggal_diterima); cmd.Parameters.AddWithValue("@tanggal_diteruskan", tanggal_diteruskan); cmd.Parameters.AddWithValue("@asal", asal_surat); cmd.Parameters.AddWithValue("@sifat", sifat_surat); cmd.Parameters.AddWithValue("@perihal", perihal); cmd.Parameters.AddWithValue("@perintah", isi_surat); cmd.Parameters.AddWithValue("@lain", lain); cmd.Parameters.AddWithValue("@diproses", diproses); cmd.Parameters.AddWithValue("@dilaksanakan", dilaksanakan); cmd.Parameters.AddWithValue("@ditanggapi", ditanggapi); cmd.Parameters.AddWithValue("@diperhatikan", diperhatikan); cmd.Parameters.AddWithValue("@dilaporkan", dilaporkan); cmd.Parameters.AddWithValue("@diketahui", diketahui); cmd.Parameters.AddWithValue("@diedarkan", diedarkan); cmd.Parameters.AddWithValue("@diperbanyak", diperbanyak); cmd.Parameters.AddWithValue("@ditampung", ditampung); cmd.Parameters.AddWithValue("@dihadiri", dihadiri); cmd.Parameters.AddWithValue("@dikonsepkan", dikonsepkan); cmd.Parameters.AddWithValue("@dievaluasi", dievaluasi); cmd.Parameters.AddWithValue("@saran_pendapat", saran); cmd.Parameters.AddWithValue("@disimpan", disimpan); cmd.Parameters.AddWithValue("@gambar_surat", gambar); //cmd.Parameters.AddWithValue("@id_user", FormMain.id_user); cmd.ExecuteNonQuery(); MessageBox.Show("Data berhasil ditambah.", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { if (ex.Number == 1062) { MessageBox.Show("Nomor surat/agenda yang diisi telah ada. Proses penyimpanan dibatalkan", "Duplicate Entry", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show(ex.ToString()); } } conn.Close(); }