private void btnSave_Click(object sender, EventArgs e) { ms.MsDate = dateTimePicker1.Value.ToString("yyyy-MM-dd"); ms.Save(); MySqlCommand command = new MySqlCommand(); DBProvider dbProvider = new DBProvider(); command.CommandText = "insert into customer_order(menu_schedule_id, com_order_date, com_selected, com_order_status, customer_id, id_input)"; command.CommandText += "select a.Menu_Schedule_Id, a.MS_DATE, a.MS_MENU_A, 'ACTIVE', b.Customer_ID, 0 from menu_schedule a join customer_profile b where a.menu_schedule_id not in (select c.menu_schedule_id from customer_order c)"; dbProvider.Exec(command); dbProvider.dbClose(); DialogResult = DialogResult.OK; }
public void deleteData(String regType, String regName) { DBProvider dbprovider = new DBProvider(); MySqlCommand command = new MySqlCommand(); String sqlCmd = "DELETE FROM `daftar_register` "; sqlCmd += "WHERE CONVERT(`daftar_register`.`reg_type` USING utf8) = ?reg_type AND "; sqlCmd += "CONVERT(`daftar_register`.`reg_name` USING utf8) = ?reg_name "; command.CommandText = sqlCmd; command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("reg_type", regType)); command.Parameters.Add(new MySqlParameter("reg_name", regName)); dbprovider.Exec(command); }
private void Btn_Save_Click(object sender, EventArgs e) { MySqlCommand command = new MySqlCommand(); DBProvider dbProvider = new DBProvider(); String sqlCmd = "select * from daftar_register where reg_type=?reg_type and reg_name=?reg_name"; command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("reg_type", Txt_CmdType.Text)); command.Parameters.Add(new MySqlParameter("reg_name", Txt_CmdName.Text)); command.Parameters.Add(new MySqlParameter("nama_class", Txt_ClassName.Text)); command.Parameters.Add(new MySqlParameter("nama_assembly", Txt_AssemblyName.Text)); command.CommandText = sqlCmd; DataTable dtCommand = dbProvider.getData(command); if (dtCommand.Rows.Count > 0) { command.CommandText = " update `daftar_register` set "; command.CommandText += " `reg_type`=?reg_type, "; command.CommandText += " `reg_name`=?reg_name , "; command.CommandText += " `nama_class`=?nama_class , "; command.CommandText += " `nama_assembly`=?nama_assembly "; command.CommandText += " where `reg_type`=?reg_type and `reg_name`=?reg_name"; } else { command.CommandText = "INSERT INTO `daftar_register` "; command.CommandText += "( `reg_type` , `reg_name` , `nama_class` , `nama_assembly` ) "; command.CommandText += "VALUES ( ?reg_type , ?reg_name , ?nama_class , ?nama_assembly )"; } if (dbProvider.Exec(command)) { MessageBox.Show("Data Saved", "Save"); } else { MessageBox.Show("Cannot Saving Data", "Save"); } dbProvider.dbClose(); }
public void deleteData(int jadwallID) { try { DBProvider dbprovider = new DBProvider(); MySqlCommand command = new MySqlCommand(); String sqlCmd = "DELETE FROM jadwal_broadcast "; sqlCmd += "WHERE id_jadwal= ?id_jadwal "; command.CommandText = sqlCmd; command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("id_jadwal", jadwallID)); dbprovider.Exec(command); } catch (Exception ex) { } }
private void btnSave_Click_1(object sender, EventArgs e) { MySqlCommand command = new MySqlCommand(); DBProvider dbProvider = new DBProvider(); String sqlCmd = "select * from `jadwal_broadcast` where id_jadwal=?id_jadwal"; command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("id_jadwal", brcdID)); command.CommandText = sqlCmd; DataTable dtCommand = dbProvider.getData(command); if (dtCommand.Rows.Count > 0) { command.CommandText = " update `jadwal_broadcast` set "; command.CommandText += " `id_jadwal`=?id_jadwal,"; command.CommandText += " `reg_type`=?reg_type,"; command.CommandText += " `reg_name`=?reg_name,"; command.CommandText += " `pengulangan_max`=?pengulangan_max,"; command.CommandText += " `pengulangan_hitung`=?pengulangan_hitung, "; command.CommandText += " `Pengulangan_Jeda_Hari`=?Pengulangan_Jeda_Hari, "; command.CommandText += " `Waktu_Eksekusi_Berikut`=?Waktu_Eksekusi_Berikut, "; command.CommandText += " `Waktu_Eksekusi_Terakhir`=?Waktu_Eksekusi_Terakhir,"; command.CommandText += " `status`=?status"; command.CommandText += " where `id_jadwal`=?id_jadwal"; command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("id_jadwal", brcdID)); } else { command.Parameters.Clear(); command.Parameters.Add(new MySqlParameter("id_jadwal", null)); command.CommandText = "INSERT INTO `jadwal_broadcast` "; command.CommandText += "( `id_jadwal` , `reg_type` , `reg_name` , `pengulangan_max` , `pengulangan_hitung` , `Pengulangan_Jeda_Hari` , `Waktu_Eksekusi_Berikut` , `Waktu_Eksekusi_Terakhir` , `status` ) "; command.CommandText += "VALUES ( ?id_jadwal,?reg_type , ?reg_name , ?pengulangan_max, ?pengulangan_hitung, ?Pengulangan_Jeda_Hari,?Waktu_Eksekusi_Berikut ,?Waktu_Eksekusi_Terakhir,?status )"; } String[] register = this.Cmb_Name.SelectedValue.ToString().Split('-'); command.Parameters.Add(new MySqlParameter("reg_type", register[0])); command.Parameters.Add(new MySqlParameter("reg_name", register[1])); command.Parameters.Add(new MySqlParameter("pengulangan_max", this.Txt_MaxLoop.Text)); command.Parameters.Add(new MySqlParameter("pengulangan_hitung", this.Txt_CurrLoop.Text)); command.Parameters.Add(new MySqlParameter("Pengulangan_Jeda_Hari", this.Txt_Interval.Text)); command.Parameters.Add(new MySqlParameter("Waktu_Eksekusi_Berikut", this.dtNextExecute.Value.ToString("yyyy-MM-dd HH:mm:ss"))); command.Parameters.Add(new MySqlParameter("Waktu_Eksekusi_Terakhir", this.dtLastExecute.Value.ToString("yyyy-MM-dd HH:mm:ss"))); command.Parameters.Add(new MySqlParameter("status", this.Cmb_Status.Text)); dbProvider.Exec(command); dbProvider.dbClose(); }