public bool DeleteKurir(Kurir kurir) { bool result = false; query = "UPDATE kurir SET status_deleted = 1 WHERE id_kurir = '" + kurir.Id_kurir + "'"; try { connect.Open(); cmd = new MySqlCommand(query, connect); cmd.ExecuteNonQuery(); result = true; } catch (MySqlException ex) { MessageBox.Show(ex.Message.ToString()); result = false; } finally { connect.Close(); } return result; }
public bool AddKurir(Kurir kurir) { bool result = false; query = "INSERT INTO kurir VALUES('" + kurir.Id_kurir + "','" + kurir.Nama_kurir + "','" + kurir.Alamat_kurir + "','" + kurir.No_telp_kurir + "')"; try { connect.Open(); cmd = new MySqlCommand(query, connect); cmd.ExecuteNonQuery(); result = true; } catch (MySqlException ex) { MessageBox.Show(ex.Message.ToString()); result = false; } finally { connect.Close(); } return result; }
private void btn_DeleteKurir_Click(object sender, EventArgs e) { if (txt_NamaKurir.TextLength > 0 && txt_NoTelpKurir.TextLength > 0 && txt_AlamatKurir.TextLength > 0) { s_Kurir = new Kurir(Utils.ConcatMaxID(txt_IdKurir.Text.ToString(), txt_IdKurirNum.Text.ToString()), txt_NamaKurir.Text.ToString(), txt_NoTelpKurir.Text.ToString(), txt_AlamatKurir.Text.ToString()); if (s_KurirManager.DeleteKurir(s_Kurir)) { MessageBox.Show("Data berhasil dihapus"); txt_IdKurirNum.Text = Utils.DisplayMaxID(s_KurirManager.GetMaxIDKurir().Substring((s_KurirManager.GetMaxIDKurir().IndexOf("-")) + 1)); ClearField(); } else { MessageBox.Show("Data gagal dihapus"); } } else { MessageBox.Show("Mohon data-data dilengkapi"); } }
public bool UpdateKurir(Kurir kurir) { bool result = false; query = "UPDATE kurir SET nama_kurir = '" + kurir.Nama_kurir + "', alamat_kurir = '" + kurir.Alamat_kurir + "', no_telp_kurir = '" + kurir.No_telp_kurir + "' WHERE id_kurir = '" + kurir.Id_kurir + "'"; try { connect.Open(); cmd = new MySqlCommand(query, connect); cmd.ExecuteNonQuery(); result = true; } catch (MySqlException ex) { MessageBox.Show(ex.Message.ToString()); result = false; } finally { connect.Close(); } return result; }
private void btn_HapusPermanen_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Peringatan! Anda akan menghapus semua data secara permanen. Anda yakin?", "WARNING", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { s_Kurir = new Kurir(); s_Kurir.Id_kurir = Utils.ConcatMaxID(txt_IdKurir.Text.ToString(), txt_IdKurirNum.Text.ToString()); if (s_KurirManager.DeleteKurirPermanen(s_Kurir)) { MessageBox.Show("Data berhasil dihapus permanen"); txt_IdKurirNum.Text = Utils.DisplayMaxID(s_KurirManager.GetMaxIDKurir().Substring((s_KurirManager.GetMaxIDKurir().IndexOf("-")) + 1)); ClearField(); } else { MessageBox.Show("Data gagal dihapus permanen"); } } else { return; } }