LOGIN procedure TF_LOGIN.Button1Click(Sender: TObject); begin if (edit_user.Text <>'') and (edit_pass.Text <> '') and (combobox1.Text <>'') then begin if (edit_pass.Text = 'Admin') and (edit_user.Text = 'Admin') and (combobox1.Text ='Admin')then begin F_LOGIN.Close; end end else Showmessage('Tidak boleh kosong'); end; end. INSERT procedure TFormMhs.Button1Click(Sender: TObject); begin if (edit1.Text<>'') and (edit2.Text<>'') and (edit3.Text<>'') and (edit4.Text<>'') then begin Try dm.ADOConnection1.BeginTrans; with dm.qry_free do begin Close;
SQL.Clear; SQL.Add('insert into tb_mhs values('+QuotedStr(Edit1.Text)+',' +QuotedStr(Edit2.Text)+','+QuotedStr(Edit3.Text)+',' +QuotedStr(Edit4.Text)+')'); Edit1.Clear; Edit2.Text:=''; Edit3.Text:=''; Edit4.Text:=''; Edit1.SetFocus; ExecSQL; ShowMessage('sukses'); end; dm.ADOConnection1.CommitTrans; dm.qry_mhs.Requery(); Except dm.ADOConnection1.RollbackTrans; ShowMessage('data sudah ada'); end; end else ShowMessage('data jangan kosong'); end; UPDATE procedure TFormMhs.Button2Click(Sender: TObject); begin try dm.ADOConnection1.BeginTrans;
DELETE procedure TFormMhs.Button3Click(Sender: TObject); var x,y:string; begin y:='in'; x:=InputBox('Masukkan KODE BARANG','MONGGO',''); if x<>'' then begin Try dm.ADOConnection1.BeginTrans; with dm.qry_free do begin Close; SQL.Add('delete tb_mhs where nim='+quotedstr(x)); showmessage('hapus sukses'); edit1.Clear; Edit2.Text:=''; Edit3.Text:=''; Edit4.Text:=''; edit1.SetFocus; ExecSQL; end; DM.ADOConnection1.CommitTrans; DM.qry_mhs.Requery(); except DM.ADOConnection1.RollbackTrans; end; end; end; end.
CONNECT
begin if(Edit5.Text='')or(Edit6.Text='')then begin ShowMessage('isi nama database'); Edit5.SetFocus; end else begin try with DM.ADOConnection1 do begin LoginPrompt:=false; ConnectionString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=' +(Edit6.Text)+';data source='+(Edit5.Text); Connected:=True; end; ShowMessage('selamat bekerja'); DM.ADOQuery1.Connection:=DM.ADOConnection1; DM.ADOQuery2.Connection:=DM.ADOConnection1; DM.DataSource1.DataSet:=DM.qry_jual; DBGrid1.DataSource:=DM.DataSource1; FormShow(sender); Edit1.SetFocus; Except Application.MessageBox('koneksi gagal','peringatan',MB_OK+MB_ICONWARNING); Edit5.SetFocus; end; end; end;
SIMPAN
begin if(Edit1.Text='')or(Edit2.Text='')or(Edit3.Text='')or(Edit4.Text='')then begin ShowMessage('isikan semua data barang'); Edit1.SetFocus;
end else begin try DM.ADOConnection1.BeginTrans; with DM.qry_free do begin Active:=false; Close; SQL.Clear; SQL.Add('insert into toko values('+QuotedStr(Edit1.Text)+','+QuotedStr(Edit2.Text)+',' +','+QuotedStr(Edit3.Text)+','+QuotedStr(Edit4.Text)+')'); ExecSQL; end; DM.ADOConnection1.CommitTrans; ShowMessage('data telah tersimpan'); FormShow(sender); Edit1.SetFocus; except DM.ADOConnection1.RollbackTrans; Application.MessageBox('data tidak bisa di simpan','PERINGATAN !!',+MB_OK+MB_ICONWARNING); Edit1.SetFocus; end; end; end;
TAMPIL
begin with DM.qry_jual do Begin Active:=false; Close; SQL.Clear; SQL.Text:='select*from tb_toko'; Open; end; end;