No se si alguien me querra ayudar, pero bueno, solucione el punto anterior, todo funcionaba bien pero ahora quieren que la factura sea auto incrementable, con esto en realidad no tenia problema, de echo era autoincrementable, pero el asunto que al no poder cargar un numero y la tabla detalle de factura no es autoincrementable, estoy tratando de que sea asi.
el punto creo que esta aca
Código Delphi
[-]procedure TForm14.DBGrid2DblClick(Sender: TObject);
begin
Table2.Filtered := False;
Table2.Close;
Table7.Close;
Table2.Open;
Table7.Open;
Table7.Last;
Table7.Edit;
if combobox1.Text = 'Productos' then
begin
datasource5.DataSet:= Table4; Table2.Insert; Table2Cod_prodser.Value:= Table4Cod_prod.Value; Table2Codigo.Value:= Table4Codigo.Value;
Table2Descripcion.Value:= Table4Descripcion.Value;
Table2Importunidad.Value:= Table4ImpVent.Value;
Table2Cantidad.Value:= StrToFloat(Edit1.Text); Table2TotalImp.Value:=Table2Cantidad.Value * Table2Importunidad.Value; Table2ID_Factura.Value:= StrToInt(Edit6.Text); //NO SE REALIZA MAS
Table2.Post; end;
if combobox1.Text = 'Servicios' then
begin
datasource9.DataSet:= Table8; Table2.Insert; Table2Cod_prodser.Value:= Table5Cod_servcio.Value; Table2Codigo.Value:= Table5Codigo.Value;
Table2Descripcion.Value:= Table5Servicio.Value;
Table2Cantidad.Value:= StrToFloat(Edit1.Text); Table2Importunidad.Value:= Table5ImpServ.Value;
Table2TotalImp.Value:=Table2Cantidad.Value * Table2Importunidad.Value;
Table2ID_Factura.Value:= StrToInt(Edit6.Text); //NO SE REALIZA MAS
Table2.Post; end;
calcula;
end;
EL BOTON DE NUEVA FACTURA
Código Delphi
[-]procedure TForm14.BitBtn1Click(Sender: TObject); begin
Table1.Open;
Table1.Last;
Table2.Open;
Table2.Last;
c:=Table1.FieldByName('Cod_factura').Asinteger;
c:=c+1;
Table1.insert;
Table1.Edit;
if Table2.IsEmpty then Application.MessageBox('Cargue los Items a Facturar'+ #13 +'Luego pulse Nueva Factura','¡ATENCION!',Mb_OK + Mb_IconWarning);
Table2.Last;
Table2.Refresh;
with Query1 do
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;
end;
y el boton guardar
Código Delphi
[-]procedure TForm14.SpeedButton4Click(Sender: TObject);
begin
Table7.Edit;
Table7.FieldByName('ID_factura').AsInteger:=k;
Table7.Post;
Table1.Edit;
Table1.FieldByName('Cod_factura').AsInteger:=Table7.FieldByName('ID_factura').AsInteger;
Table1Cod_productserv.Value:=Table2Cod_prodser.Value;
Table1Cod_detalleFactura.Value:=Table2ID_factura.Value;
Table1Cod_cliente.Value:=Table8Cod_prop.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;
end;
El asunto es como ponerle un numero a la tabla detallefactura si esta es temporal y con cada carga despues borro todo
y la tabla detallefacturafinal, creo que deberia pasar los datos entre detallefactura y detallefacturafinal y viceversa y sumarle 1, se entiende lo que digo.
digamos asi
Cargo detallefactura (tengo que ver de donde saco el numero)
Copio esta a detallefacturafinal
guardo luego borro detallefactura
cargo nueva detallefactura y el numero de la clave principal la tomo de detallefacturafinal +1
no se si la idea esta bien, pero todavia no lo supe implementar.
si alguien me tira una mano, caral¿?