private void btnTambah_Click(object sender, EventArgs e) { if (!txtNim.MaskFull) { MessageBox.Show("Nim Harus diisi", "Konfirmasi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!(txtName.Text.Length > 0)) { MessageBox.Show("Nama Harus diisi", "Konfirmasi", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (isNewData) { mhs = new Mahasiswa(); } mhs.Nim = txtNim.Text; mhs.Name = txtName.Text; mhs.Gender = rdoLakilaki.Checked ? "Laki-laki" : "Perempuan"; mhs.Alamat = txtAlamat.Text; mhs.Born = txtBorn.Text; mhs.Date = dtpDate.Value.ToString("dd/MM/yyyy"); if (isNewData) // data baru { Form1_OnSave(mhs); reset(); } else { Form1_OnUpdate(mhs);// panggil event OnUpdate reset(); isNewData = true; } }
private void btnTambah_Click(object sender, EventArgs e) { if (isNewData) { mhs = new Mahasiswa(); } mhs.Nim = txtNim.Text; mhs.Name = txtName.Text; mhs.Gender = rdoLakilaki.Checked ? "Laki-laki" : "Perempuan"; mhs.Alamat = txtAlamat.Text; mhs.Date = dtpDate.Value.ToString("dd/MM/yyyy"); if (isNewData) // data baru { Form1_OnSave(mhs); reset(); } else { Form1_OnUpdate(mhs);// panggil event OnUpdate reset(); isNewData = true; } }
private void Form1_OnUpdate(Mahasiswa obj) { listOfMahasiswa.Add(obj); FillToListView(false, obj); }
private void Form1_OnSave(Mahasiswa obj) { listOfMahasiswa.Add(obj); FillToListView(true, obj); }