private void btnCari_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } else { if (stat == "transaksi") { var ctrl = new TransaksiLayananControl(); if (ctrl.SearchTransaksiLayanan(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); txtCari.Text = string.Empty; throw null; } else { List <TransaksiLayanan> TransaksiLayananList = new List <TransaksiLayanan>(); TransaksiLayananList.Add(ctrl.SearchTransaksiLayanan(txtCari.Text)); dataGridViewTampil.DataSource = TransaksiLayananList; } } else if (stat == "detiltransaksi") { var ctrl = new DetilTransaksiLayananControl(); if (ctrl.SearchDetilTransaksiLayanan(txtCari.Text) == null) { MessageBox.Show("Pencarian Tidak Ditemukan"); txtCari.Text = string.Empty; throw null; } else { List <DetilTransaksiLayanan> DetilTransaksiLayananList = new List <DetilTransaksiLayanan>(); DetilTransaksiLayananList.Add(ctrl.SearchDetilTransaksiLayanan(txtCari.Text)); dataGridViewTampil.DataSource = DetilTransaksiLayananList; } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonTransaksi_Click(object sender, EventArgs e) { stat = "transaksi"; var ctrl = new TransaksiLayananControl(); dataGridViewTampil.DataSource = ctrl.ShowTransaksiLayanan(); for (int i = 0; i < dataGridViewTampil.Columns.Count; i++) { string str = dataGridViewTampil.Columns[i].HeaderText; if (str == "Nomor_Telpon" || str == "Jenis_Hewan") { dataGridViewTampil.Columns[i].Visible = false; } } txtCari.Text = string.Empty; txtCari.Enabled = true; btnCari.Enabled = true; }
private void btnHapusLayanan_Click(object sender, EventArgs e) { var ctrlDTL = new DetilTransaksiLayananControl(); var ctrlTL = new TransaksiLayananControl(); try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Kode Transaksi Kosong"); throw null; } if (string.IsNullOrEmpty(txtCariDetil.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } if (txtCariDetil.Text != null && ctrlDTL.SearchDetilTransaksiLayanan(txtCariDetil.Text) != null) { hargaSubtotal = 0; detilTransaksiLayanan = ctrlDTL.SearchDetilTransaksiLayanan(txtCariDetil.Text); hargaSubtotal = detilTransaksiLayanan.Sub_Total_Layanan; ctrlDTL.DeleteDetilTransaksiLayanan(txtCariDetil.Text, txtCari.Text); subtotalLayanan = subtotalLayanan - hargaSubtotal; totalHargaAkhir = subtotalLayanan - tempDiskon; ctrlTL.UpdateSubtotalLayanan(subtotalLayanan, txtCari.Text); ctrlTL.UpdateTotalHargaLayanan(totalHargaAkhir, txtCari.Text); MessageBox.Show("Layanan Berhasil Dihapus!"); } else { MessageBox.Show("Transaksi Layanan Tidak ditemukan!"); throw null; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonBatal_Click(object sender, EventArgs e) { SetTextBoxDisable(); buttonUbah.Enabled = false; buttonBatal.Enabled = false; try { var ctrlTL = new TransaksiLayananControl(); var ctrlDTL = new DetilTransaksiLayananControl(); if (statusTransaksi == 1) { MessageBox.Show("Transaksi Sudah Lunas! Transaksi tidak bisa dibatalkan!"); txtCari.Text = string.Empty; throw null; } if (progressLayanan == 1) { MessageBox.Show("Progress Sudah Selesai! Transaksi tidak bisa dibatalkan!"); txtCari.Text = string.Empty; throw null; } ctrlTL.DeleteTransaksiLayanan(txtCari.Text); ctrlDTL.DeleteDetilTransaksiLayananUsingIDTransaksi(txtCari.Text); MessageBox.Show("Transaksi Berhasil Dibatalkan"); txtCari.Text = string.Empty; txtDiskon.Text = string.Empty; comboBoxCS.Text = string.Empty; comboBoxHewan.Text = string.Empty; comboBoxKasir.Text = string.Empty; comboBoxStatus.Text = string.Empty; comboBoxProgress.Text = string.Empty; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonBayar_Click(object sender, EventArgs e) { int status; var ctrl = new TransaksiLayananControl(); try { if (string.IsNullOrEmpty(txtJumlahBayar.Text.Trim())) { MessageBox.Show("Diskon Tidak Boleh Kosong!"); throw null; } ValidateNumberOnly(txtJumlahBayar.Text); if (totalHarga > Int32.Parse(txtJumlahBayar.Text)) { MessageBox.Show("Uang untuk Pembayaran Kurang!"); txtJumlahBayar.Text = string.Empty; throw null; } status = 1; kembalian = Int32.Parse(txtJumlahBayar.Text) - totalHarga; txtKembalian.Text = Convert.ToString(kembalian); transaksiLayanan = new TransaksiLayanan(status, totalHarga, diskon, FormLogin.id_pegawai); ctrl.UpdatePembayaranLayanan(transaksiLayanan, txtCari.Text); MessageBox.Show("Pembayaran Berhasil!"); txtJumlahBayar.Enabled = false; buttonBayar.Enabled = false; buttonCetak.Enabled = true; } catch (NumberOnlyException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void btnUbahLayanan_Click(object sender, EventArgs e) { int SubtotalLayanan; try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Kode Transaksi Kosong"); throw null; } if (string.IsNullOrEmpty(txtCariDetil.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } if (string.IsNullOrEmpty(txtJumlah.Text.Trim())) { MessageBox.Show("Jumlah Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxLayanan.Text.Trim())) { MessageBox.Show("Nama Layanan Kosong"); throw null; } string connStr = "datasource=127.0.0.1;port=3306;username=root;password=;database=kouvee;Convert Zero Datetime=True;"; MySqlConnection conn = new MySqlConnection(connStr); string sqlLayanan = "SELECT * FROM layanan WHERE NAMA_LAYANAN = '" + comboBoxLayanan.Text + "';"; conn.Open(); try { MySqlCommand cmd1 = new MySqlCommand(sqlLayanan, conn); MySqlDataReader result1 = cmd1.ExecuteReader(); if (result1 != null) { while (result1.Read()) { hargaLayananInput = result1.GetInt32("HARGA_LAYANAN"); idLayanan = result1.GetInt32("ID_LAYANAN"); } } } catch (Exception ex) { Console.WriteLine("Failed to read..."); Console.WriteLine(ex.ToString()); } conn.Close(); var ctrl = new DetilTransaksiLayananControl(); var ctrlTP = new TransaksiLayananControl(); ValidateNumberOnly(txtJumlah.Text); SubtotalLayanan = (Convert.ToInt32(txtJumlah.Text) * hargaLayananInput); subtotalLayanan = tempSubtotalLayanan - oldSubtotal + SubtotalLayanan; totalHargaAkhir = subtotalLayanan - tempDiskon; detilTransaksiLayanan = new DetilTransaksiLayanan(comboBoxLayanan.Text, SubtotalLayanan, Convert.ToInt32(txtJumlah.Text)); transaksiLayanan = new TransaksiLayanan(subtotalLayanan); ctrl.UpdateDetilTransaksiLayanan(detilTransaksiLayanan, txtCariDetil.Text); ctrlTP.UpdateSubtotalLayanan(transaksiLayanan, txtCari.Text); ctrlTP.UpdateTotalHargaLayanan(totalHargaAkhir, txtCari.Text); MessageBox.Show("Transaksi Berhasil Diubah!"); } catch (NumberOnlyException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void buttonUbah_Click(object sender, EventArgs e) { SetTextBoxDisable(); buttonUbah.Enabled = false; buttonBatal.Enabled = false; int status; int progress; int totalHarga; try { if (string.IsNullOrEmpty(txtCari.Text.Trim())) { MessageBox.Show("Text Pencarian Kosong"); throw null; } if (string.IsNullOrEmpty(txtDiskon.Text.Trim())) { MessageBox.Show("Diskon Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxStatus.Text.Trim())) { MessageBox.Show("Status Pembayaran Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxProgress.Text.Trim())) { MessageBox.Show("Progress Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxCS.Text.Trim())) { MessageBox.Show("Nama CS Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxHewan.Text.Trim())) { MessageBox.Show("Nama Hewan Kosong"); throw null; } if (string.IsNullOrEmpty(comboBoxKasir.Text.Trim())) { MessageBox.Show("Nama Kasir Kosong"); throw null; } var ctrl = new TransaksiLayananControl(); ValidateNumberOnly(txtDiskon.Text); if (comboBoxStatus.Text == "Lunas") { status = 1; } else { status = 0; } if (comboBoxProgress.Text == "Selesai") { progress = 1; } else { progress = 0; } totalHarga = subtotal - Int32.Parse(txtDiskon.Text); transaksiLayanan = new TransaksiLayanan(comboBoxCS.Text, comboBoxKasir.Text, comboBoxHewan.Text, progress, status, totalHarga, Int32.Parse(txtDiskon.Text)); ctrl.UpdateTransaksiLayanan(transaksiLayanan, txtCari.Text); MessageBox.Show("Transaksi Berhasil Diubah"); txtCari.Text = string.Empty; txtDiskon.Text = string.Empty; comboBoxCS.Text = string.Empty; comboBoxHewan.Text = string.Empty; comboBoxKasir.Text = string.Empty; comboBoxStatus.Text = string.Empty; comboBoxProgress.Text = string.Empty; } catch (NumberOnlyException ex) { Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void btnCari_Click(object sender, EventArgs e) { var list = new TransaksiLayananControl(); var list2 = new DetilTransaksiLayananControl(); try { if (txtCari.Text != null && list.SearchTransaksiLayanan(txtCari.Text) != null) { SetTextBoxEnable(); buttonUbah.Enabled = true; buttonBatal.Enabled = true; btnTambahLayanan.Enabled = true; transaksiLayanan = list.SearchTransaksiLayanan(txtCari.Text); txtDiskon.Text = System.Convert.ToString(transaksiLayanan.Diskon_Layanan); subtotal = transaksiLayanan.Subtotal_Transaksi_Layanan; statusTransaksi = transaksiLayanan.Status_Layanan; progressLayanan = transaksiLayanan.Progres_Layanan; tempDiskon = transaksiLayanan.Diskon_Layanan; subtotalLayanan = transaksiLayanan.Subtotal_Transaksi_Layanan; tempSubtotalLayanan = subtotalLayanan; if (transaksiLayanan.Status_Layanan == 1) { comboBoxStatus.Text = "Lunas"; } else { comboBoxStatus.Text = "Belum Lunas"; } if (transaksiLayanan.Progres_Layanan == 1) { comboBoxProgress.Text = "Selesai"; } else { comboBoxProgress.Text = "Belum Selesai"; } string connStr = "datasource=127.0.0.1;port=3306;username=root;password=;database=kouvee;Convert Zero Datetime=True;"; MySqlConnection conn = new MySqlConnection(connStr); string sqlhewan = "SELECT * FROM hewan WHERE ID_HEWAN = '" + transaksiLayanan.ID_Hewan + "';"; string sqlCS = "SELECT * FROM pegawai WHERE ID_PEGAWAI = '" + transaksiLayanan.ID_Pegawai + "';"; string sqlKasir = "SELECT * FROM pegawai WHERE ID_PEGAWAI = '" + transaksiLayanan.Peg_ID_Pegawai + "';"; conn.Open(); try { MySqlCommand cmd1 = new MySqlCommand(sqlhewan, conn); MySqlDataReader result1 = cmd1.ExecuteReader(); if (result1 != null) { while (result1.Read()) { comboBoxHewan.Text = result1.GetString("Nama_Hewan"); } } } catch (Exception ex) { Console.WriteLine("Failed to read..."); Console.WriteLine(ex.ToString()); } conn.Close(); conn.Open(); try { MySqlCommand cmd2 = new MySqlCommand(sqlCS, conn); MySqlDataReader result2 = cmd2.ExecuteReader(); if (result2 != null) { while (result2.Read()) { comboBoxCS.Text = result2.GetString("Nama_Pegawai"); } } } catch (Exception ex) { Console.WriteLine("Failed to read..."); Console.WriteLine(ex.ToString()); } conn.Close(); conn.Open(); try { MySqlCommand cmd1 = new MySqlCommand(sqlKasir, conn); MySqlDataReader result1 = cmd1.ExecuteReader(); if (result1 != null) { while (result1.Read()) { comboBoxKasir.Text = result1.GetString("Nama_Pegawai"); } } } catch (Exception ex) { Console.WriteLine("Failed to read..."); Console.WriteLine(ex.ToString()); } conn.Close(); List <TransaksiLayanan> TransaksiLayananList = new List <TransaksiLayanan>(); TransaksiLayananList.Add(list.SearchTransaksiLayanan(txtCari.Text)); dataGridViewTransaksi.DataSource = TransaksiLayananList; dataGridViewDetiil.DataSource = list2.SearchDetilTransaksiLayananUsingIDLayanan(txtCari.Text); } else { MessageBox.Show("Pencarian Tidak Ditemukan"); txtCari.Text = string.Empty; txtCariDetil.Text = string.Empty; throw null; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void btnCari_Click(object sender, EventArgs e) { var list = new TransaksiLayananControl(); try { if (txtCari.Text != null && list.SearchTransaksiLayanan(txtCari.Text) != null) { transaksiLayanan = list.SearchTransaksiLayanan(txtCari.Text); notaLayanan = list.ShowNotaLayanan(txtCari.Text); NamaPelanggan = notaLayanan.Nama_Pelanggan; NamaHewan = notaLayanan.Nama_Hewan; NamaCS = notaLayanan.Nama_CS; NamaKasir = notaLayanan.Nama_Kasir; NoTelp = notaLayanan.Nomor_Telpon; Jenis_Hewan = notaLayanan.Jenis_Hewan; if (transaksiLayanan.Status_Layanan == 1) { txtNomorTransaksi.Text = transaksiLayanan.ID_Transaksi_Layanan; txtNamaHewan.Text = transaksiLayanan.Nama_Hewan; txtNamaPelanggan.Text = transaksiLayanan.Nama_Pelanggan; txtStatusBayar.Text = "Lunas"; txtSubtotal.Text = Convert.ToString(transaksiLayanan.Subtotal_Transaksi_Layanan); txtDiskon.Text = Convert.ToString(transaksiLayanan.Diskon_Layanan); txtTotalHarga.Text = Convert.ToString(transaksiLayanan.Total_Transaksi_Layanan); if (transaksiLayanan.Progres_Layanan == 1) { txtProgress.Text = "Selesai"; } else { txtProgress.Text = "Belum Selesai"; } buttonCetak.Enabled = true; MessageBox.Show("Transaksi Sudah Lunas!"); } else { buttonHitungTotal.Enabled = true; txtDiskon.Enabled = true; subtotal = transaksiLayanan.Subtotal_Transaksi_Layanan; txtNomorTransaksi.Text = transaksiLayanan.ID_Transaksi_Layanan; txtNamaHewan.Text = transaksiLayanan.Nama_Hewan; txtNamaPelanggan.Text = transaksiLayanan.Nama_Pelanggan; txtSubtotal.Text = Convert.ToString(transaksiLayanan.Subtotal_Transaksi_Layanan); if (transaksiLayanan.Progres_Layanan == 1) { txtProgress.Text = "Selesai"; } else { txtProgress.Text = "Belum Selesai"; } txtStatusBayar.Text = "Belum Lunas"; } } else { MessageBox.Show("Pencarian Tidak Ditemukan!"); txtCari.Text = string.Empty; throw null; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }