Ver Mensaje Individual
  #71  
Antiguo 07-12-2014
DOS DOS is offline
Miembro
NULL
 
Registrado: jul 2011
Posts: 173
Reputación: 13
DOS Va por buen camino
Despues de mas de un año, sigo tan perdido como siempre, nunca termino de funcionar bien y ni iquiera se si vale la pena revivirlo, pero siempre me quede con las ganas de que funcione, creo que tiene un tonto error en alguna parte y yo no lo encuentro, asi que si alguien lo ve, me chifla por favor
al problema surge al apretar el boton guardar, aprarece el malefico, master record missing.

Código Delphi [-]
// Doble click para la carga de productos y servicios
procedure TForm14.DBGrid2DblClick(Sender: TObject);
begin
Table2.Filtered := False;
Table2.Close;
Table7.Close;
Table2.Open;
Table7.Open;
Table7.Last;
Table7.Edit;
              Table1.Open;
              Table1.Last;
              Table1.Edit;
              c:=Table1Cod_detalleFactura.Asinteger;
   c:=c+1;
if combobox1.Text = 'Productos' then
  begin
   datasource5.DataSet:= Table4;  // tabla de productos
   Table2.Insert; // inserta un campo
   Table2Cod_prodser.Value:= Table4Cod_prod.Value; // el campo cod_prod de la tabla nueva es igual al de la tabla5
   Table2Codigo.Value:= Table4Codigo.Value;
   Table2Descripcion.Value:= Table4Descripcion.Value;
   Table2Importunidad.Value:= Table4ImpVent.Value;
   Table2Cantidad.Value:= StrToFloat(Edit1.Text);  //cantidad cargada por el usuario
   Table2TotalImp.Value:=Table2Cantidad.Value * Table2Importunidad.Value;   // multiplica la cantidad por el valor unitario
   Table2ID_Factura.Value:=c; //incremento el numero del codigo
   Table2.Post; // guarda el dato en la tabla nueva.
   end;
  if combobox1.Text = 'Servicios' then
  begin
  datasource9.DataSet:= Table8;  // tabla servicios
   Table2.Insert; // inserta un campo
   Table2Cod_prodser.Value:= Table5Cod_servcio.Value; // el campo cod_servicio de la tabla nueva es igual al de la tabla3
   Table2Codigo.Value:= Table5Codigo.Value;
   Table2Descripcion.Value:= Table5Servicio.Value;
   Table2Cantidad.Value:= StrToFloat(Edit1.Text);  // cantidad cargada por el usuario
   Table2Importunidad.Value:= Table5ImpServ.Value;
   Table2TotalImp.Value:=Table2Cantidad.Value * Table2Importunidad.Value;
   Table2ID_Factura.Value:=c; // Nº de factura
   Table2.Post; // guarda el dato en la tabla nueva.
   end;
  calcula;
end;

Código Delphi [-]
// boton nueva factura,
procedure TForm14.BitBtn1Click(Sender: TObject);
begin
          k:=0;
          Table1.Open;     //factura
          Table1.Last;
          Table2.Open;  //det. factura
          Table2.Last;
          Table7.Open;    //det. factura final
          Table7.Last;
           //Table1.insert;
          Table1.Edit;
          Table2.Edit;
          k:=Table1.FieldByName('Cod_factura').AsInteger;
          k:=k+1;  // incrementa el numero del afactura
if Table2.IsEmpty then   //verifica la carga del nº de factura
Application.MessageBox('Seleccione el cliente'+ #13'Cargue los Items a Facturar'+ #13 +'Luego pulse Nueva Factura','¡ATENCION!',Mb_OK + Mb_IconWarning)
else
begin
Table2.Refresh;
with Form14.Query1 do  //pasa de la tabla temporal a la de detalle final
  begin
   Close;
   SQL.Clear;
   SQL.Add('INSERT INTO detfacturafinal');
   SQL.Add('SELECT * FROM detfactura');
   ExecSQL;
  end;
    BitBtn1.Enabled := false;
    SpeedButton4.Enabled:=true;
    PageControl1.ActivePage := TabSheet2;

             l:=Table7.FieldByName('Cod_prodser').AsInteger;
             l:=l+1;
end;

end;

Código Delphi [-]
//Guarda la tabla factura
procedure TForm14.SpeedButton4Click(Sender: TObject);
begin
Table7.Edit;
Table7.Post; //det. factura final
  Table1.Edit;
                   Table1.Insert;
  Table1.FieldByName('Cod_factura').AsInteger:=k;
  Table1Cod_productserv.Value:=l;
  Table1Cod_detalleFactura.Value:=c;
  Table1Cod_cliente.Value:=Table8Cod_propi.Value;
  Table1Fecha.Value:=Now();
  Table1Descuento.Value:=StrToFloat(Edit3.Text);
  Table1Incremento.Value:=StrToFloat(Edit4.Text);
  Table1Total.Value:=StrToFloat(Edit5.Text);
  Table1.Post;
BitBtn1.Enabled := true;
SpeedButton4.Enabled:=false;
Table7.Refresh;
Table1.Refresh;
PageControl1.ActivePage := TabSheet1;
end;

tabla detalle factura temporal IDEM detalle factura final
ID_factura
Cod_prodser
Codigo
Descripcion
Importunidad
Cantidad
TotalImp

Tabla Factura
Cod_factura
Cod_detalleFactura // ID_factura
Cod_productserv
Cod_cliente
Fecha
Descuento
Incremento
Total

si a alguien se le ocurre algo gracias
Responder Con Cita