Ver Mensaje Individual
  #12  
Antiguo 27-02-2018
Avatar de mRoman
mRoman mRoman is offline
Miembro
 
Registrado: nov 2003
Posts: 599
Reputación: 21
mRoman Va por buen camino
Otra forma

Hola buenas noches BlueSteel

Yo lo hago de esta forma (Lo q esta marcado con rojo, es lo q talvez necesites).

Código Delphi [-]
procedure TfrmProducto.btnGrabarClick(Sender: TObject);
var
   bmp:TBitmap; Stream:TStream;

begin
  inherited;
  try
        if chkBActivar.Checked then
            dsProducto.FieldByName('ACTIVAR_PRODUCTO').AsInteger:=1
        else
            dsProducto.FieldByName('ACTIVAR_PRODUCTO').AsInteger:=0;
        if chkKardex.Checked then
            dsProducto.FieldByName('CONTROL_KARDEX').AsString:='S'
        else
            dsProducto.FieldByName('CONTROL_KARDEX').AsString:='N';
        {Este clave servira para identificar si el producto es subsidiado o comercial,
        utilizando el numero 0 para los productos que son comerciales y el 1 para
        los productos subsidiados.}
        bmp:=TBitmap.Create;
        bmp.Assign(Image1.Picture.Graphic);
        dsProducto.FieldByName('TIPO_PRODUCTO').AsInteger:=cbxTipoProducto.ItemIndex;
        dsProducto.FieldByName('TIPO_LECHE').AsInteger:=cbxTipoLeche.ItemIndex;
        dsProducto.FieldByName('FOTO').Assign(bmp)  //Aqui le asigno la foto al campo de la tabla
        dsProducto.FieldByName('envase').AsString:=cbxEnvase.Text;
        dsProducto.FieldByName('embalaje').AsString:=cbxEmbalaje.Text;
        dsProducto.Post;
        dsProducto.ApplyUpdates;
        modDatos.trsFluida.Commit;
        btnGrabar.Enabled:=False;
        btnEliminar.Enabled:=False;
        btnCancelar.Enabled:=False;
        edClave.Text:='';
        edClave.SetFocus;
  except
        modDatos.trsFluida.Rollback;
        showmessage('Este registro no se puede Grabar');
  end;
end;

Y aqui...la leo de la tabla para q se muestre en un componente TImage
Código Delphi [-]
procedure TfrmProducto.pnlClavesExit(Sender: TObject);
var
i:integer;
begin
  inherited;
  dsProducto.Close;
  dsProducto.ParamByName('CVE_PROD').AsString:=edClave.Text;
  dsProducto.Open;
  if dsProducto.IsEmpty then
  begin
        btnGrabar.Enabled:=True;
        btnEliminar.Enabled:=False;
        btnCancelar.Enabled:=True;
        dsProducto.Append;
        dsProducto.FieldByName('CVE_PRODUCTO').AsString:=edClave.Text;
        GroupBox4.Enabled:=True;
  end Else Begin
        btnGrabar.Enabled:=True;
        btnEliminar.Enabled:=True;
        btnCancelar.Enabled:=True;
        dsProducto.Edit;
        if dsProducto.FieldByName('ACTIVAR_PRODUCTO').AsInteger=1 then
            chkBActivar.Checked:=True
        else
            chkBActivar.Checked:=False;
        if dsProducto.FieldByName('CONTROL_KARDEX').AsString='S' then
            chkKardex.Checked:=True
        else
            chkKardex.Checked:=False; 

        if dsProducto.FieldByName('tipo_producto').AsInteger=0 then
             Panel1.Visible:=True
        else
             Panel1.Visible:=False;

        for i:=0 to cbxEnvase.Items.Count -1 do
        begin
             if cbxEnvase.Items[i]=dsProducto.FieldByName('envase').AsString then
             begin
                  cbxEnvase.ItemIndex:=i;
             end;
        end;

        for i:=0 to cbxEmbalaje.Items.Count -1 do
        begin
             if cbxEmbalaje.Items[i]=dsProducto.FieldByName('embalaje').AsString then
             begin
                  cbxEmbalaje.ItemIndex:=i;
             end;
        end;
        if (dsProducto.FieldByName('stock_inicial').IsNull) or
           (dsProducto.FieldByName('stock_inicial').AsInteger=0) then
        begin
             GroupBox4.Enabled:=True;
        end;
        cbxTipoLeche.ItemIndex:=dsProducto.fieldByName('TIPO_LECHE').AsInteger;
        cbxTipoProducto.ItemIndex:=dsProducto.fieldByName('TIPO_PRODUCTO').AsInteger;
        Image1.Picture.Assign(dsProducto.fieldbyname('foto'));
  end;
end;

En la tabla declaras un campo tipo BLOB Binary....bueno eso en Firebird. Espero te sirva el ejemplo.

Saludos.
__________________
Miguel Román

Afectuoso saludo desde tierras mexicanas....un aguachile?, con unas "cetaseas" bien "muertas"?, VENTE PUES !!
Responder Con Cita