// CODING SIMPAN (letakkan di dalam tombol SIMPAN dgn cara klik 2x tombol SIMPAN)
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Append('insert into pelajar values('''+Edit1.Text+''','''+Edit2.Text+''','''+Edit3.Text+''','''+DateToStr(DateTimePicker1.Date)+''','''+ComboBox1.Text+''','''+Edit5.Text+''','''+ComboBox2.Text+''','''+Edit6.Text+''')');
ADOQuery1.ExecSQL;
//CODING REFRESH (letakkan di dalam tombol REFRESH dgn cara klik 2x tombol REFRESH)
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Append('SELECT * FROM pelajar order by ID_PELAJAR desc');
ADOQuery1.Open;
//CODING HAPUS (letakkan di dalam tombol HAPUS dgn cara klik 2x tombol HAPUS)
if (MessageDlg('Yakin Hapus Data Anda?',mtConfirmation,[mbYes,mbNo],0)=mrYes)then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Append('Delete From pelajar where ID_PELAJAR='''+Edit1.Text+'''');
ADOQuery1.ExecSQL;
MessageDlg('DATA ANDA SUDAH DIHAPUS',mtConfirmation,[mbOK],0);
Button3.Click; //Sesuaikan dengan tombol refresh
//Coding EXIT (letakkan di dalam tombol TUTUP dgn cara klik 2x tombol TUTUP)
Close;
DBGrid : klik DBGrid 1x - events - OnDBLClick - DBGrid1DBLClik - klik2x - masukkan coding
//coding DBGrid
Edit1.Text:=ADOQuery1.Fields[0].AsString;
Edit2.Text:=ADOQuery1.Fields[1].AsString;
Edit3.Text:=ADOQuery1.Fields[2].AsString;
DateTimePicker1.Date:=ADOQuery1.Fields[3].AsDateTime;
ComboBox1.Text:=ADOQuery1.Fields[4].AsString;
Edit5.Text:=ADOQuery1.Fields[5].AsString;
ComboBox2.Text:=ADOQuery1.Fields[6].AsString;
Edit6.Text:=ADOQuery1.Fields[7].AsString;
Source : http://frikamasivers.blogspot.com/2013/01/coding-simpan-refresh-hapus-exit-dbgrid.html
0 Response to "Coding SIMPAN , REFRESH , HAPUS , EXIT , DBGrid di Delphi 2010"
Post a Comment