private void btnSimpan_Click(object sender, EventArgs e) { //validasi if (txtNama.Text.Trim() == "") { MessageBox.Show("Sorry, nama wajib isi."); txtNama.Focus(); } else if (txtAlamat.Text.Trim() == "") { MessageBox.Show("Sorry, alamat wajib isi."); txtAlamat.Focus(); } else if (txtKota.Text.Trim() == "") { MessageBox.Show("Sorry, kota wajib isi."); txtKota.Focus(); } else if (txtNoHp.Text.Trim() == "") { MessageBox.Show("Sorry, no.hp wajib isi."); txtNoHp.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("Sorry, email wajib isi."); txtEmail.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("Sorry, email tidak valid."); txtEmail.Focus(); } else { AddressBookController address = new AddressBookController(); if (!_addMode) { address.AddItem(_editData.Split(';'), _addMode, _row); } else { string[] addData = { txtNama.Text, txtAlamat.Text, txtKota.Text, txtNoHp.Text, dtpTglLahir.Value.ToShortDateString(), txtEmail.Text }; address.AddItem(addData, _addMode, _row); } this.Close(); } }
private void btnSimpan_Click(object sender, EventArgs e) { if (txtNama.Text.Trim() == "") { MessageBox.Show("Maaf, nama harus isi."); txtNama.Focus(); } else if (txtAlamat.Text.Trim() == "") { MessageBox.Show("alamat harus isi."); txtAlamat.Focus(); } else if (txtKota.Text.Trim() == "") { MessageBox.Show("kota harus isi."); txtKota.Focus(); } else if (txtNoHp.Text.Trim() == "") { MessageBox.Show("no.hp harus isi."); txtNoHp.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("email harus isi."); txtEmail.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("email anda tidak valid !"); txtEmail.Focus(); } else { AddressBookController address = new AddressBookController(); address.AddItem(_editData.Split(';'), _addMode, _row); this.Close(); } }
private void btnSimpan_Click(object sender, EventArgs e) { if (txtNama.Text.Trim() == "") { MessageBox.Show("Sorry, nama wajib di isi."); txtNama.Focus(); } else if (txtAlamat.Text.Trim() == "") { MessageBox.Show("Sorry, alamat wajib di isi."); txtAlamat.Focus(); } else if (txtKota.Text.Trim() == "") { MessageBox.Show("Sorry, kota wajib di isi."); txtKota.Focus(); } else if (txtNoHp.Text.Trim() == "") { MessageBox.Show("Sorry, no.hp wajib di isi."); txtNoHp.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("Sorry, email wajib di isi."); txtEmail.Focus(); } else if (txtEmail.Text.Trim() == "") { MessageBox.Show("Sorry, E-mail tidak valid."); txtEmail.Focus(); } else { AddressBookController address = new AddressBookController(); address.AddItem(_editData.Split(';'), _addMode, _row); this.Close(); } }