private void button_Simpan_Click(object sender, EventArgs e) { transaksiData = new Transaksi(label_IDNomor.Text, label_IDTrans.Text, label_IDMotor.Text, nama_TextBox.Text, nomorHp_TextBox.Text, alamat_TextBox.Text, tanggalJual_datePicker.Value.ToString("MM/dd/yyyy"), hargaJual_TextBox.Text.Replace(@".", "").Replace(@",", "")); if (nama_TextBox.Text.CompareTo("") == 0 || nomorHp_TextBox.Text.Trim().CompareTo("") == 0 || alamat_TextBox.Text.CompareTo("") == 0 || tanggalJual_datePicker.Text.Trim().CompareTo("") == 0 || hargaJual_TextBox.Text.CompareTo("") == 0) { MessageBox.Show("Input tidak boleh kosong !", "Peringatan", MessageBoxButtons.OK); } else { transaksiManager.addNewDataTransaksi(transaksiData); TransaksiUI transaksiUI = new TransaksiUI(); if (transaksiManager.successed() == true) { transaksiUI.refreshDataGrid(); nama_TextBox.Text = ""; nomorHp_TextBox.Text = ""; alamat_TextBox.Text = ""; tanggalJual_datePicker.Text = ""; hargaJual_TextBox.Text = ""; label_IDNomor.Text = "-"; label_IDTrans.Text = "-"; label_IDMotor.Text = "-"; MessageBox.Show("Data Pengguna berhasil disimpan !", "Informasi", MessageBoxButtons.OK); (this.Owner as Motorcycle).refreshDataGrid(); (this.Owner as Motorcycle).panelButton.Enabled = true; (this.Owner as Motorcycle).panelSide.Hide(); this.Close(); } else { MessageBox.Show("Data Pengguna gagal disimpan !", "Pesan Kesalahan", MessageBoxButtons.OK); } } }
private void button_Simpan_Click(object sender, EventArgs e) { if (pilih == 1) { transaksiData = new Transaksi("", label_IDTrans.Text, "", nama_TextBox.Text, nomorHP_TextBox.Text, alamat_TextBox.Text, tanggalJual_datePicker.Value.ToString("MM/dd/yyyy"), hargaJual_TextBox.Text.Replace(@".", "").Replace(@",", "")); if (nama_TextBox.Text.CompareTo("") == 0 || nomorHP_TextBox.Text.Trim().CompareTo("") == 0 || alamat_TextBox.Text.CompareTo("") == 0 || tanggalJual_datePicker.Text.Trim().CompareTo("") == 0 || hargaJual_TextBox.Text.CompareTo("") == 0) { MessageBox.Show("Input tidak boleh kosong !", "Peringatan", MessageBoxButtons.OK); } else { transaksiManager.editDataTransaksi(transaksiData); if (transaksiManager.successed() == true) { refreshDataGrid(); nama_TextBox.Text = ""; nomorHP_TextBox.Text = ""; alamat_TextBox.Text = ""; tanggalJual_datePicker.Text = ""; hargaJual_TextBox.Text = ""; label_IDTrans.Text = "-"; panelInput.Enabled = false; panelButton.Enabled = true; MessageBox.Show("Data Pengguna berhasil diubah!", "Informasi", MessageBoxButtons.OK); refreshDataGrid(); } else { MessageBox.Show("Data Pengguna gagal diubah!", "Pesan Kesalahan", MessageBoxButtons.OK); } } } else { if (pilih == 2) { transaksiData = new Transaksi("", label_IDTrans.Text, "", "", "", "", "", ""); transaksiManager.hapusDataTransaksi(transaksiData); if (transaksiManager.successed() == true) { refreshDataGrid(); nama_TextBox.Text = ""; nomorHP_TextBox.Text = ""; alamat_TextBox.Text = ""; tanggalJual_datePicker.Text = ""; hargaJual_TextBox.Text = ""; label_IDTrans.Text = "-"; panelInput.Enabled = false; panelButton.Enabled = true; MessageBox.Show("Data Pengguna berhasil dihapus!", "Informasi", MessageBoxButtons.OK); refreshDataGrid(); } else { MessageBox.Show("Data Pengguna gagal dihapus!", "Pesan Kesalahan", MessageBoxButtons.OK); } refreshDataGrid(); nama_TextBox.Enabled = true; nomorHP_TextBox.Enabled = true; alamat_TextBox.Enabled = true; tanggalJual_datePicker.Enabled = true; hargaJual_TextBox.Enabled = true; cari_TextBox.Enabled = true; } } }