Gracias amigo AzidRain por el tiempo que te tomas para ayudarme.
Con este codigo Llamo algunas funciones financieras que dan error en algunas maquinas. Se activa cuando rayamos un codigo de barras.
Código Delphi
[-]
procedure TFVenta.Edit1Exit(Sender: TObject);
begin
if Trim(Edit1.Text) <> '' then
begin
Actualiza;
SumaCantidad;
Impuesto;
SumarImp;
Subtotal;
end
else
end;
Las funciones son las siguientes:
Código Delphi
[-]
Procedure TFVenta.Actualiza;
begin
with DataModule1.IBQInventarios do begin
if active then Close; sql.Clear; SQL.Add('Select * From INVENTARIO');
SQL.Add('Where Codigo_Producto = '+QuotedStr(Edit1.Text));
Open;
if not IsEmpty then begin
StringGrid1.Row := StringGrid1.Rowcount - 1;
StringGrid1.Cells[0, StringGrid1.Row]:= fieldbyname('CODIGO_PRODUCTO').AsString;
StringGrid1.Cells[1, StringGrid1.Row]:= fieldbyname('NOMBRE_PRODUCTO').AsString;
StringGrid1.Cells[2, StringGrid1.Row]:= fieldbyname('REFERENCIA_PRODUCTO').AsString;
StringGrid1.Cells[3, StringGrid1.Row]:= fieldbyname('CATEGORIA').AsString;
StringGrid1.Cells[4, StringGrid1.Row]:= '1'; StringGrid1.Cells[5, StringGrid1.Row]:= fieldbyname('PRECIO').AsString;
Edit1.Clear;
Edit1.SetFocus;
StringGrid1.RowCount := StringGrid1.RowCount + 1;
Sumar;
Puntos;
end else begin
ShowMessage('PRODUCTO NO EXISTE EN INVENTARIO');
Edit1.Clear;
Edit1.SetFocus;
end;
end;
end;
Código Delphi
[-]
Procedure TFVenta.SumaCantidad;
var
k, Suma: integer;
a, c, d: Extended;
begin
d:= 0;
a := StrToInt(StringGrid1.Cells[5, StringGrid1.Row]); c := StrToInt(Edit8.Text); d:= (a*c);
StringGrid1.Cells[4, StringGrid1.Row]:= Edit8.Text; StringGrid1.Cells[6, StringGrid1.Row]:= FormatFloat('$ #0,.00',d);
StringGrid1.Cells[8, StringGrid1.Row]:= FloatToStr(d);
Suma := 0;
StringGrid1.Cells[7, StringGrid1.Row]:= StringGrid1.Cells[1, StringGrid1.Row];
for k := 0 to StringGrid1.RowCount - 1 do
if k <= StringGrid1.RowCount - 1 then
Suma := Suma + StrToIntdef(StringGrid1.Cells[8, k + 1], 0);
Edit7.Text:= FormatFloat('$ #0,.00', Suma);
Edit5.Text:= IntToStr(Suma);
end;
Código Delphi
[-]
Procedure TFVenta.Impuesto;
begin
DataModule1.IBQInvFact.Close;
DataModule1.IBQInvFact.ParamByName('Codigo').AsString := StringGrid1.Cells[0, StringGrid1.Row];
DataModule1.IBQInvFact.Open;
end;
Código Delphi
[-]
Procedure TFVenta.SumarImp;
var
a,b,c,d,e,f,z: Extended;
j, Suma: integer;
begin
z:= 0;
a:= StrToInt(DbEdit2.Text); b:= StrToInt(DbEdit3.Text); c:= 1+((a+b)/100); d:= StrToInt(StringGrid1.Cells[5, StringGrid1.Row])* StrToInt(StringGrid1.Cells[4, StringGrid1.Row]); f:= d/c;
z:= d-f;
if z > 0 then
StringGrid1.Cells[7, StringGrid1.Row]:= FormatFloat('#####', z)
else
StringGrid1.Cells[7, StringGrid1.Row]:= ('0');
Suma := 0;
StringGrid1.Cells[7, StringGrid1.Row];
for j := 0 to StringGrid1.RowCount - 1 do
if j <= StringGrid1.RowCount - 1 then
Suma := Suma + StrToIntdef(StringGrid1.Cells[7, j + 1], 0);
Edit2.Text:= FormatFloat('$ #0,.00', Suma);
Edit14.Text:= IntToStr(Suma);
end;
Código Delphi
[-]
Procedure TFVenta.Subtotal;
var
Precio, Impuesto, Resultado: Extended;
begin
Precio:= StrToInt(Edit5.Text);
Impuesto:= StrToInt(Edit14.Text);
Resultado:= ((Precio - Impuesto));
Edit4.text:= FormatFloat('$ #0,.00', Resultado);
Edit16.Text:= FloatToStr(Resultado);
end;
Lo de las variables me suena muy logico. solo quiero si no es molestia que revises los codigos para que me ratifiques o como tu mismo dices, no especular.
Gracias amigo y a todos los que tengan a bien opinar y aportar sobre el tema.