Ejemplo n.º 1
0
        private void btnTambah_Click(object sender, EventArgs e)
        {
            try
            {
                String pesan = "";
                if (va.doValidation() == false)
                {
                    return;
                }
                tip = db.tbl_tipes.FirstOrDefault(x => x.id_tipe == tbIdjenis.Text);
                if (tip == null)
                {
                    aksi("insert");
                    pesan = "menambah";
                }

                else
                {
                    aksi("update");
                    pesan = "memperbaharui";
                }

                MessageBox.Show("Berhasil " + pesan + " data", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadGrid();
            }

            catch (Exception err)
            {
                MessageBox.Show("Terjadi Kesalahan" + err.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void aksi(String aksinya)
        {
            tip      = aksinya == "insert" ? new tbl_tipe() : db.tbl_tipes.FirstOrDefault(x => x.id_tipe == tbIdjenis.Text);
            tip.nama = tbNama.Text;
            if (aksinya == "insert")
            {
                tip.id_tipe = tbIdjenis.Text;
                db.tbl_tipes.InsertOnSubmit(tip);
            }

            db.SubmitChanges();
        }
Ejemplo n.º 3
0
        private void setTextbox()
        {
            if (!String.IsNullOrEmpty(tbIdjenis.Text))
            {
                tip = db.tbl_tipes.FirstOrDefault(x => x.id_tipe == tbIdjenis.Text);
                if (tip != null)
                {
                    tbIdjenis.Text = tip.id_tipe;
                    tbNama.Text    = tip.nama;
                    btnTambah.Text = "UBAH";
                }

                else
                {
                    va.clear("tbIdjenis");
                    btnTambah.Text = "TAMBAH";
                }
            }
        }
Ejemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (klik == 1)
            {
                foreach (DataGridViewRow rw in this.dgvJenis.SelectedRows)
                {
                    primary = rw.Cells[0].Value.ToString();
                }
                tip = db.tbl_tipes.Where(x => x.id_tipe == primary).Single();
                db.tbl_tipes.DeleteOnSubmit(tip);
                db.SubmitChanges();
                loadGrid();
            }

            else
            {
                MessageBox.Show("Silahkan pilih baris yang ingin dihapus", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }