bueno termine optando por usar un dbgrid, y he podido hacer lo que queria hacer, tengo:
1-DataSetProvider
1-ClientDataSet
2-ADOQuery1 y 2
1-Dataccess
1-Edit
1-DBGrid
hice la siguiente configuración:
->DataSetProvider->DataSet->ADOQuery
->ClientDataSet->ProviderName->DataSetProvider
->DataAccess->DataSet->ClientDataSet
supongo que esa configuración esta correcta, en el evento OnKeyDown del DBGrid puse este codigo:
Código Delphi
[-]procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_TAB then
begin
CLientDataset1.Append;
Edit1.Clear;
Edit1.SetFocus;
end;
end;
en el evento OnKeyPress del Edit puse este codigo:
Código Delphi
[-]procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then begin
with QArticulo do begin
if active then Close;
sql.Clear; SQL.Add(' SELECT ref, articulo, cantidad FROM articulos ');
SQL.Add('WHERE ref = '+QuotedStr(Edit1.Text) );
ClientDataSet1.Open;
ClientDataSet1.Edit;
Open;
if not IsEmpty then begin
DBGrid1.fields[0].Value:=QArticuloref.AsString;
DBGrid1.Fields[1].Value:=QArticuloarticulo.AsString;
DBGrid1.DataSource.DataSet.FieldByName('cantidad').FocusControl;
end else begin
ShowMessage('Articulo no existe');
end;
end;
end;
end;
hasta todo bien se agregan los datos al dbgrid mediante un edit, ahora tengo este problema y es cuando intento grabar los datos, puse un boton con este codigo:
Código Delphi
[-]procedure TForm1.BitBtn1Click(Sender: TObject);
begin
registrar.SQL.Clear;
registrar.SQL.Text:=' insert into entrada (articulo, cantidad, ref, suplidor, costo, itbis, monto, fecha, hora, usuario, fechauser)'+
' values ("'+DBGrid1.fields[1].Value+'", "'+DBGrid1.Fields[2].Value+'", "'+DBGrid1.Fields[0].Value+'", "", "+double(0.00)", "+double(0.00)", "+double(0.00)", "", "", "", "")';
ShowMessage(registrar.SQL.Text);
registrar.ExecSQL;
end;
y me tira este error:
Cita:
---------------------------
Debugger Exception Notification
---------------------------
Project inventario.exe raised exception class EVariantTypeCastError with message 'Could not convert variant of type (String) into type (Double)'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
|
he intentado de todo, use Quotedstr, FloatToInt, double, strToInt, etc. todo igual... cual sera la causa? estoy haciendo algo malo?
adjunto codigo:
Archivo Adjunto 955