private void btnEdit_Click(object sender, EventArgs e)
 {
     if (dgvData.Rows.Count == 0)
     {
         MessageBox.Show("There are no rows to be selected ! Click the refresh button !", "Error", MessageBoxButtons.OK);
     }
     else
     {
         address = new AddressBookController();
         address.EditItem(selectedRowsAfterFilter, selectedRows, dgvData);
         FrmAddressBook_Load(null, null);
     }
 }
 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 FrmAddressBook_Load(object sender, EventArgs e)
 {
     selectedRowsAfterFilter = 0;
     selectedRows            = new int[25];
     try
     {
         address            = new AddressBookController();
         dgvData.DataSource = address.ListData;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     finally
     {
         lblBanyakRecordData.Text = $"{dgvData.Rows.Count.ToString("n0")} Record Data(s)";
     }
 }
Esempio n. 4
0
        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();
            }
        }
 private void btnFilter_Click(object sender, EventArgs e)
 {
     string [] data = { txtNama.Text, txtAlamat.Text, txtKota.Text, txtNoHp.Text, txtTglLahir.Text, txtEmail.Text };
     address = new AddressBookController();
     address.FilterItem(data, selectedRowsAfterFilter, selectedRows, dgvData);
 }