aqui hay una muestra pero esta muy enrredada lo que uqiero hacer es mas sensillo
Código Delphi
[-] begin
if(suiComboBox1.Text='') or (suiComboBox1.Text='Seleccione Número de Identificación')then
begin
showmessage('DEBE DIGITAR EL NUMERO DE IDENTIFICACION DEL USUARIO');
suiComboBox1.SetFocus;
end
else
begin
if(suiedit3.Text='')then
begin
showmessage('DEBE DIGITAR EL CODIGO DEL LIBRO');
suiedit5.SetFocus;
end
else
begin
consulta:=suiedit1.text;
table1.TableName:='prestamo';
table1.open;
if not table1.Locate('idprestamo',consulta, []) then
begin
table1.insert;
if(suiComboBox1.Text<>'')then
begin
table1.fieldbyname('cod_libro').Asstring:=(suiedit3.text);
table1.fieldbyname('documento_usuario').Asstring:=(suicombobox1.text);
table1.fieldbyname('idprestamo').Asstring:=(suiedit1.text);
table1.fieldbyname('fecha').AsDateTime:=(datetimepicker1.Date);
Table1.FieldByName('estado').AsString:=(ESTADO1.text);
table1.Post;
table1.Close;
table2.open;
table2.insert;
if (ESTADO1.Text='ABIERTO')then
begin
table2.fieldbyname('cod_libro').Asstring:=(suiedit3.text);
table2.fieldbyname('idprestamo').Asstring:=(suiedit1.text);
begin
consulta:='select prestamo.idprestamo, from prestamo where idprestamo >=4';
if (consulta>='4') then
begin
ShowMessage('No Puede Ingresar Mas Prestamos Para Este Usuario');
end
else
table2.Post;
table2.Close;
Application.MessageBox('TODOS LOS DATOS HAN SIDO ALMACENADOS SATISFACTORIAMENTE','SIBIBLIO',MB_OK);
suiedit1.Clear;
suiedit3.Clear;
suiComboBox1.Text:='Seleccione Número de Identificación';
suiedit5.Clear;
suiedit5.SetFocus;
end;
end;
end;
end;
end;
end;
end;
veo que mezclan 2 tablas etc... ((no es tarea, es solo que quiero aprender una forma diferente y mas sensilla)).
saludos