示例#1
0
        private void BtnCari_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (txtCari.Text == null)
            {
                showData();
            }
            else
            {
                EntData   data = new EntData();
                ImpPenemu imp  = new ImpPenemu();
                data = imp.Search(txtCari.Text);

                //MessageBox.Show(data.dataBarang.Count.ToString());

                dgvPenemu.Rows.Clear();

                for (int i = 0; i < data.dataPenemu.Count; i++)
                {
                    dgvPenemu.Rows.Add();
                    dgvPenemu[0, count].Value = data.dataPenemu[i].id;
                    dgvPenemu[1, count].Value = data.dataBarang[i].id;
                    dgvPenemu[2, count].Value = data.dataPenemu[i].nama;
                    dgvPenemu[3, count].Value = data.dataBarang[i].jenis;
                    dgvPenemu[4, count].Value = data.dataBarang[i].nama;
                    dgvPenemu[5, count].Value = data.dataRuang[i].nama;
                    dgvPenemu[6, count].Value = data.dataPenemu[i].id_admin;
                    dgvPenemu[7, count].Value = data.dataPenemu[i].id_lokasi;
                    dgvPenemu[8, count].Value = data.dataBarang[i].status;
                    count++;
                }
            }
        }
示例#2
0
        private void btnHapus_Click(object sender, EventArgs e)
        {
            String id, id1;

            query = $"SELECT id_ruang FROM tb_barang WHERE id = '{dgvPenemu.SelectedRows[0].Cells[1].ToString()}';";

            koneksi.Open();
            command             = koneksi.CreateCommand();
            command.CommandText = query;
            reader = command.ExecuteReader();

            reader.Read();
            id = reader["id_ruang"].ToString();
            koneksi.Close();

            query = $"SELECT id_lokasi FROM tb_penemu WHERE id = '{dgvPenemu.SelectedRows[0].Cells[0].ToString()}';";

            koneksi.Open();
            command             = koneksi.CreateCommand();
            command.CommandText = query;
            reader = command.ExecuteReader();

            reader.Read();
            id1 = reader["id_lokasi"].ToString();
            koneksi.Close();

            String[] id_ = new String[4]
            {
                dgvPenemu.SelectedRows[0].Cells[0].ToString(),
                id1,
                dgvPenemu.SelectedRows[0].Cells[1].ToString(),
                id
            };

            ImpPenemu imp = new ImpPenemu();

            if (imp.DeleteData(id_))
            {
                MessageBox.Show("Hapus Berhasil");
            }

            if (this.dgvPenemu.SelectedRows.Count > 0)
            {
                dgvPenemu.Rows.RemoveAt(this.dgvPenemu.SelectedRows[0].Index);
            }
            ;
        }
示例#3
0
        private void BtnSimpan_Click(object sender, EventArgs e)
        {
            ImpPenemu imp    = new ImpPenemu();
            Boolean   status = imp.InsertData(penemu, getData(), getRuang(), barang);

            if (status)
            {
                MessageBox.Show("Input Berhasil");
            }
            else
            {
                MessageBox.Show("Input Gagal");
            }

            this.Hide();
            frmPelapor frm = new frmPelapor();

            frm.ShowDialog();
            this.Dispose();
        }
示例#4
0
        public void getEntity(EntPenemu p, EntBarang b)
        {
            query = "SELECT id_admin FROM tb_admin WHERE status_admin = 1;";

            koneksi.Open();
            command             = koneksi.CreateCommand();
            command.CommandText = query;
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                id = reader["id_admin"].ToString();
            }

            e             = new EntPelapor();
            e.id          = kodeBaru("pelapor");
            e.otherId     = p.id_lokasi;
            e.nama        = txtNamaPelapor.Text;
            e.jenis       = cmbJenisBarang.Text;
            e.nama_barang = txtNamaBarang.Text;
            e.no_telp     = txtNoTelp.Text;
            e.id_admin    = id;

            koneksi.Close();

            penemu = new EntPenemu();
            barang = new EntBarang();

            penemu = p;
            barang = b;

            txtIdBarang.Text    = b.id;
            txtIdPelapor.Text   = kodeBaru("pelapor");
            txtNamaBarang.Text  = b.nama;
            cmbJenisBarang.Text = b.jenis;

            ImpPenemu imp = new ImpPenemu();

            imp.UpdateData(barang, penemu, e);
        }