Esempio n. 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();
            }
        }
Esempio n. 2
0
        private void Admin_Load(object sender, EventArgs e)
        {
            cmbkja.SelectedIndex = 0;
            no_edit();
            hapus_admin();

            AutoGeneratedID autoid   = new AutoGeneratedID();
            string          id_admin = autoid.AutoIDAdmin();

            txtid.Text     = id_admin;
            txtid.ReadOnly = true;
            try
            {
                koneksi = conn.con();
                koneksi.Open();
                sql = "Select distinct id_admin, nama, jenis_kelamin, jenis_admin, telepon, status from tb_Admin order by id_admin desc";
                adapter.SelectCommand = new SqlCommand(sql, koneksi);
                adapter.Fill(ds, "Member");
                dv       = new DataView();
                dv.Table = ds.Tables[0];
                dataGridView1.DataSource = dv;
                dataGridView4.DataSource = dv;
                dataGridView6.DataSource = dv;
                koneksi.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                koneksi.Close();
            }
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            hapus_edit();
            hapus_member();

            cmbkjrsan.SelectedIndex = 0;

            AutoGeneratedID autoid    = new AutoGeneratedID();
            string          id_member = autoid.AutoIDMember();

            txtidmember.Text     = id_member;
            txtidmember.ReadOnly = true;
            try
            {
                koneksi = conn.con();
                koneksi.Open();
                sql = "Select * from tb_Member order by id_member desc";
                adapter.SelectCommand = new SqlCommand(sql, koneksi);
                adapter.Fill(ds, "Member");
                dv       = new DataView();
                dv.Table = ds.Tables[0];
                dataGridView1.DataSource = dv;
                dataGridView2.DataSource = dv;
                dataGridView3.DataSource = dv;
                dataGridView4.DataSource = dv;
                koneksi.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                koneksi.Close();
            }
        }
Esempio n. 5
0
 private void btnsimpan_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtnama.Text == "")
         {
             errorProvider1.Clear();
             errorProvider1.SetError(txtnama, "Nama Harus Diisi!");
             var warning = MessageBox.Show("Nama Harus Diisi!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (warning == DialogResult.Cancel)
             {
                 errorProvider1.Clear();
                 hapus();
             }
         }
         else if (txttelp.Text == "")
         {
             errorProvider1.Clear();
             errorProvider1.SetError(txttelp, "Telp Harus Diisi!");
             var warning = MessageBox.Show("Telp Harus Diisi!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (warning == DialogResult.Cancel)
             {
                 errorProvider1.Clear();
                 hapus();
             }
         }
         else if (txtpswd.Text == "")
         {
             errorProvider1.Clear();
             errorProvider1.SetError(txtpswd, "Password Harus Diisi!");
             var warning = MessageBox.Show("Password Harus Diisi!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (warning == DialogResult.Cancel)
             {
                 errorProvider1.Clear();
                 hapus();
             }
         }
         else if (cmbkja.SelectedIndex == 0)
         {
             errorProvider1.Clear();
             errorProvider1.SetError(cmbkja, "Jenis Admin Harus Dipilih!");
             var warning = MessageBox.Show("Jenis Admin Harus Dipilih!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (warning == DialogResult.Cancel)
             {
                 errorProvider1.Clear();
                 hapus();
             }
         }
         else if (txtpswd.Text != txtpswd1.Text)
         {
             errorProvider1.Clear();
             errorProvider1.SetError(txtpswd1, "Password Tidak Sama!");
             var warning = MessageBox.Show("Password Tidak Sama!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
             if (warning == DialogResult.Cancel)
             {
                 errorProvider1.Clear();
                 hapus();
             }
         }
         else
         {
             string status = "No";
             string jk     = "";
             if (rbt1.Checked || rbt2.Checked)
             {
                 if (rbt1.Checked)
                 {
                     jk = "Pria";
                 }
                 else
                 {
                     jk = "Wanita";
                 }
                 koneksi = conn.con();
                 koneksi.Open();
                 SqlCommand command = new SqlCommand("insert into tb_Admin (id_admin, nama, jenis_kelamin, jenis_admin, telepon, password, status) values ('" + txtid.Text + "','" + txtnama.Text + "','" + jk + "','" + cmbkja.SelectedItem + "','" + txttelp.Text + "','" + txtpswd.Text + "','" + status + "');", koneksi);
                 adapter = new SqlDataAdapter("select * from tb_Admin order by id_admin desc", koneksi);
                 DataTable dtMember = new DataTable();
                 command.ExecuteNonQuery();
                 dataGridView1.DataSource = dtMember;
                 dataGridView4.DataSource = dtMember;
                 dataGridView6.DataSource = dtMember;
                 adapter.SelectCommand.ExecuteNonQuery();
                 adapter.Fill(dtMember);
                 MessageBox.Show("Data Admin Berhasil Ditambah!");
                 AutoGeneratedID autoid   = new AutoGeneratedID();
                 string          id_admin = autoid.AutoIDAdmin();
                 txtid.Text     = id_admin;
                 txtid.ReadOnly = true;
                 hapus();
                 koneksi.Close();
                 errorProvider1.Clear();
             }
             else
             {
                 errorProvider1.Clear();
                 errorProvider1.SetError(rbt1, "Jenis Kelamin Harus Dipilih!");
                 var warning = MessageBox.Show("Jenis Kelamin Harus Dipilih!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                 if (warning == DialogResult.Cancel)
                 {
                     errorProvider1.Clear();
                     hapus();
                 }
             }
         }
     }
     catch (SqlException se)
     {
         MessageBox.Show(se.Message);
     }
 }
Esempio n. 6
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                String nama    = txtnama.Text;
                String nim     = txtnim.Text;
                String kelas   = txtkelas.Text;
                String alamat  = riscalmt.Text;
                String no_telp = txttlpn.Text;

                Regex reg          = new Regex(@"^[A-Z a-z]+$");
                Match match_huruf  = reg.Match(nama);
                Regex reg1         = new Regex(@"^[0-9]+$");
                Match match_angka  = reg1.Match(nim);
                Match match_angka1 = reg1.Match(no_telp);

                if (nim == "")
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnim, "Nim Tidak Boleh Kosong!");
                    var warning = MessageBox.Show("Nim Tidak Boleh Kosong!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (!match_angka.Success)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnim, "Nim Harus Berupa Angka!");
                    var warning = MessageBox.Show("Nim Harus Berupa Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (nim.Length < 9)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnim, "Nim Minimal Harus 9 Digit Angka!");
                    var warning = MessageBox.Show("Nim Minimal Harus 9 Digit Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (nim.Length > 11)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnim, "Nim Maksimal Harus 11 Digit Angka!");
                    var warning = MessageBox.Show("Nim Maksimal Harus 11 Digit Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (nama == "")
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnama, "Nama Tidak Boleh Kosong!");
                    var warning = MessageBox.Show("Nama Tidak Boleh Kosong!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (!match_huruf.Success)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnama, "Nama Harus Berupa Huruf!");
                    var warning = MessageBox.Show("Nama Harus Berupa Huruf!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (nama.Length < 3)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnama, "Nama Minimal 3 Huruf!");
                    var warning = MessageBox.Show("Nama Minimal 3 Huruf!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (nama.Length > 30)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtnama, "Nama Maksimal 30 Huruf!");
                    var warning = MessageBox.Show("Nama Maksimal 30 Huruf!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (kelas == "")
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtkelas, "Kelas Tidak Boleh Kosong!");
                    var warning = MessageBox.Show("Kelas Tidak Boleh Kosong!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (kelas.Length < 4)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtkelas, "Kelas Minimal 4 Character!");
                    var warning = MessageBox.Show("Kelas Minimal 4 Character!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (kelas.Length > 6)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtkelas, "Kelas Maksimal 5 Character!");
                    var warning = MessageBox.Show("Kelas Maksimal 5 Character!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (cmbkjrsan.SelectedIndex == 0)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(cmbkjrsan, "Jurusan Harus Dipilih!");
                    var warning = MessageBox.Show("Jurusan Harus Dipilih!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (alamat == "")
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(riscalmt, "Alamat Tidak Boleh Kosong!");
                    var warning = MessageBox.Show("Alamat Tidak Boleh Kosong!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (alamat.Length < 4)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(riscalmt, "Alamat Minimal 4 Huruf!");
                    var warning = MessageBox.Show("Alamat Minimal 4 Huruf!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (alamat.Length > 50)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(riscalmt, "Alamat Maksimal 50 Character!");
                    var warning = MessageBox.Show("Alamat Maksimal 50 Character!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (no_telp == "")
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txttlpn, "No Telp/Hp Tidak Boleh Kosong!");
                    var warning = MessageBox.Show("No Telp/Hp Tidak Boleh Kosong!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (!match_angka1.Success)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txttlpn, "No Telp/Hp Harus Berupa Angka!");
                    var warning = MessageBox.Show("No Telp/Hp Harus Berupa Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (no_telp.Length < 3)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txttlpn, "No Telp/Hp Minimal 3 Digit Angka!");
                    var warning = MessageBox.Show("No Telp/Hp Minimal 3 Digit Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else if (no_telp.Length > 13)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txttlpn, "No Telp/Hp Maksimal 13 Digit Angka!");
                    var warning = MessageBox.Show("No Telp/Hp Maksimal 13 Digit Angka!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                    if (warning == DialogResult.Cancel)
                    {
                        hapus();
                        errorProvider1.Clear();
                    }
                }
                else
                {
                    string jk = "";
                    if (radioButton1.Checked || radioButton2.Checked)
                    {
                        if (radioButton1.Checked)
                        {
                            jk = "Pria";
                        }
                        else
                        {
                            jk = "Wanita";
                        }
                        koneksi = conn.con();
                        SqlCommand command = new SqlCommand("insert into tb_Member (id_member, NIM, nama, kelas, jurusan, alamat, no_telp, jenis_kelamin) values ('" + txtidmember.Text + "','" + txtnim.Text + "','" + txtnama.Text + "','" + txtkelas.Text + "','" + cmbkjrsan.SelectedItem + "','" + riscalmt.Text + "','" + txttlpn.Text + "','" + jk + "');", koneksi);
                        adapter = new SqlDataAdapter("select * from tb_Member order by id_member desc", koneksi);
                        koneksi.Open();
                        DataTable dtMember = new DataTable();
                        command.ExecuteNonQuery();
                        dataGridView1.DataSource = dtMember;
                        dataGridView2.DataSource = dtMember;
                        dataGridView3.DataSource = dtMember;
                        adapter.SelectCommand.ExecuteNonQuery();
                        adapter.Fill(dtMember);
                        MessageBox.Show("Data success ditambah");

                        AutoGeneratedID autoid    = new AutoGeneratedID();
                        string          id_member = autoid.AutoIDMember();
                        txtidmember.Text     = id_member;
                        txtidmember.ReadOnly = true;
                        //dataGridView1.DataSource = dtMember;
                        errorProvider1.Clear();
                        hapus();
                        koneksi.Close();
                    }
                    else
                    {
                        errorProvider1.Clear();
                        errorProvider1.SetError(radioButton2, "Jenis Kelamin Harus Dipilih!");
                        var warning = MessageBox.Show("Jenis Kelamin Harus Dipilih!", "Perhatian", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                        if (warning == DialogResult.Cancel)
                        {
                            hapus();
                            errorProvider1.Clear();
                        }
                    }
                }
            }
            catch (SqlException se)
            {
                MessageBox.Show(se.Message);
            }
        }