示例#1
0
        private void Peminjaman_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'cCIT_LibraryDataSet4.tb_Peminjaman' table. You can move, or remove it, as needed.
            this.tb_PeminjamanTableAdapter.Fill(this.cCIT_LibraryDataSet4.tb_Peminjaman);
            resetpengembalian();
            textBox2.Enabled       = false;
            btncari_tambah.Enabled = false;
            button2.Enabled        = false;
            reset();
            AutoGeneratedID auto = new AutoGeneratedID();
            string          id   = auto.AutoIDPeminjaman();

            textBox1.Text = id;
            try
            {
                koneksi = conn.con();
                koneksi.Open();
                sql = "Select p.id_peminjaman_detail, m.nama, p.status from tb_Peminjaman_Details p join tb_Member m on m.id_member = p.id_member where m.id_member = p.id_member order by id_peminjaman_detail desc";
                adapter.SelectCommand = new SqlCommand(sql, koneksi);
                adapter.Fill(ds, "Peminjaman Detail");
                dv       = new DataView();
                dv.Table = ds.Tables[0];
                dataGridView2.DataSource = dv;
                dataGridView3.DataSource = dv;
                koneksi.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                koneksi.Close();
            }
        }
示例#2
0
        public void simpandetails()
        {
            koneksi = conn.con();
            string     status    = "Belum Dikembalikan";
            SqlCommand sqlsimpan = new SqlCommand("insert into tb_Peminjaman_Details (id_peminjaman_detail, id_member, status) values ('" + textBox1.Text + "','" + textBox7.Text + "','" + status + "');", koneksi);

            koneksi.Open();
            sqlsimpan.ExecuteNonQuery();
            adapter = new SqlDataAdapter("select * from tb_Peminjaman_Details order by id_peminjaman_detail desc", koneksi);
            DataTable dtpeminjaman1 = new DataTable();

            dataGridView2.DataSource = dtpeminjaman1;
            adapter.SelectCommand.ExecuteNonQuery();
            adapter.Fill(dtpeminjaman1);
            MessageBox.Show("Data Peminjaman Berhasil Ditambah!");
            AutoGeneratedID autoid = new AutoGeneratedID();
            string          id_p   = autoid.AutoIDPeminjaman();

            textBox1.Text = id_p;
            koneksi.Close();
        }