Created
May 2, 2015 14:00
-
-
Save anonymous/1bc04234219363a1f84b to your computer and use it in GitHub Desktop.
Alquiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit UAlquiler; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, StdCtrls, Grids, DBGrids, Buttons, ComCtrls, ExtCtrls, DB, | |
IBCustomDataSet, DBCtrls, IBQuery, Mask; | |
type | |
TFalquiler = class(TForm) | |
Botonera1: TPanel; | |
PanelDatos: TPanel; | |
StatusBar1: TStatusBar; | |
SBSalir: TSpeedButton; | |
Panelunidad: TPanel; | |
Panelclientes: TPanel; | |
DBGrid1: TDBGrid; | |
Label1: TLabel; | |
Label2: TLabel; | |
PanelOculto: TPanel; | |
SBConfirmar: TSpeedButton; | |
SBCancelar: TSpeedButton; | |
SBNuevo: TSpeedButton; | |
SBEditar: TSpeedButton; | |
DsPrincipal: TDataSource; | |
Label3: TLabel; | |
DbeCodigocliente: TDBEdit; | |
Label4: TLabel; | |
DbeCodigoUnidad: TDBEdit; | |
Panel1: TPanel; | |
SBBAjar: TSpeedButton; | |
SBSubir: TSpeedButton; | |
Panel2: TPanel; | |
SBBuscarUnidad: TSpeedButton; | |
SBCerrar: TSpeedButton; | |
IBQClientes: TIBQuery; | |
IBQUnidad: TIBQuery; | |
IBQalquiler: TIBQuery; | |
IbqValor: TIBQuery; | |
DsIBQClientes: TDataSource; | |
DsIBQUnidad: TDataSource; | |
DataSource3: TDataSource; | |
DataSource4: TDataSource; | |
DBText1: TDBText; | |
Label5: TLabel; | |
Label6: TLabel; | |
DBText2: TDBText; | |
DBImage1: TDBImage; | |
DBText3: TDBText; | |
DBText4: TDBText; | |
DBText5: TDBText; | |
DBText6: TDBText; | |
DBText7: TDBText; | |
SbNota: TSpeedButton; | |
DBText8: TDBText; | |
DBText9: TDBText; | |
Label7: TLabel; | |
Label8: TLabel; | |
Label9: TLabel; | |
Label10: TLabel; | |
Label11: TLabel; | |
Label12: TLabel; | |
Label13: TLabel; | |
Label14: TLabel; | |
Label15: TLabel; | |
SpeedButton3: TSpeedButton; | |
Label16: TLabel; | |
Label17: TLabel; | |
Label18: TLabel; | |
Label19: TLabel; | |
Label20: TLabel; | |
Label22: TLabel; | |
Label23: TLabel; | |
DBText11: TDBText; | |
DBText12: TDBText; | |
DBText13: TDBText; | |
DBText14: TDBText; | |
DBText15: TDBText; | |
DBText16: TDBText; | |
DBImage2: TDBImage; | |
SpeedButton4: TSpeedButton; | |
Memo1: TMemo; | |
Label21: TLabel; | |
DBText10: TDBText; | |
SBNuevoalq: TSpeedButton; | |
DBText17: TDBText; | |
DBText18: TDBText; | |
DBNavigator1: TDBNavigator; | |
Panel3: TPanel; | |
Label24: TLabel; | |
DBEdit1: TDBEdit; | |
Panel4: TPanel; | |
SpeedButton1: TSpeedButton; | |
SpeedButton2: TSpeedButton; | |
Label25: TLabel; | |
DBEdit3: TDBEdit; | |
Label26: TLabel; | |
DBEdit4: TDBEdit; | |
Label27: TLabel; | |
DBEdit5: TDBEdit; | |
Label28: TLabel; | |
DBEdit6: TDBEdit; | |
Label29: TLabel; | |
DBEdit7: TDBEdit; | |
SBCancelarTodo: TSpeedButton; | |
IBQAlquilerNopagado: TIBQuery; | |
DsIBQAlquiler: TDataSource; | |
IBQ: TIBQuery; | |
procedure SBNuevoClick(Sender: TObject); | |
procedure SBEditarClick(Sender: TObject); | |
procedure SBSalirClick(Sender: TObject); | |
procedure SBCancelarClick(Sender: TObject); | |
procedure SbNotaClick(Sender: TObject); | |
procedure SpeedButton3Click(Sender: TObject); | |
procedure SBBuscarUnidadClick(Sender: TObject); | |
procedure SBNuevoalqClick(Sender: TObject); | |
procedure SBCerrarClick(Sender: TObject); | |
procedure SBConfirmarClick(Sender: TObject); | |
procedure SpeedButton4Click(Sender: TObject); | |
procedure FormKeyPress(Sender: TObject; var Key: Char); | |
procedure DbeCodigoclienteKeyDown(Sender: TObject; var Key: Word; | |
Shift: TShiftState); | |
procedure DbeCodigoUnidadKeyDown(Sender: TObject; var Key: Word; | |
Shift: TShiftState); | |
procedure DbeCodigoclienteClick(Sender: TObject); | |
procedure DbeCodigoUnidadClick(Sender: TObject); | |
procedure DbeCodigoclienteExit(Sender: TObject); | |
procedure DbeCodigoUnidadExit(Sender: TObject); | |
procedure DBText10Click(Sender: TObject); | |
procedure SBCancelarTodoClick(Sender: TObject); | |
procedure SBSubirClick(Sender: TObject); | |
procedure SBBAjarClick(Sender: TObject); | |
procedure SpeedButton2Click(Sender: TObject); | |
procedure SpeedButton1Click(Sender: TObject); | |
procedure FormActivate(Sender: TObject); | |
procedure carga; | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
Falquiler: TFalquiler; | |
VarBmodo:Boolean; //Para saber si buscamos por un código o por un código de barras | |
VarRPendientepago:Real; | |
implementation | |
{$R *.dfm} | |
uses UDM, Funciones, Uvernota, Ubuscarclientes, UBuscarUnidad, ubuscaralquiler, | |
UPAgosAlquiler; | |
procedure TFalquiler.carga; | |
begin | |
if Falquiler.Active then | |
begin | |
ActQuery(IBQalquiler,'Select * From ALQUILER WHERE ALQUILER.REGISTRO =' +QuotedStr(DsPrincipal.DataSet.FieldByName('REGISTRO').value)); | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoclienteClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************[ pulsar sobre dbedit ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
try | |
FBuscarCliente.ShowModal; | |
finally | |
if varSBusqueda<>'Cancelado' then | |
begin | |
ActQuery(IBQ,'SELECT * FROM CLIENTES WHERE CLIENTES.ID = '+QuotedStr(varSBusqueda)); | |
if not IBQ.IsEmpty then | |
begin | |
DbeCodigocliente.Field.value:=IBQ.FieldByName('CODIGO').Value; | |
end else | |
begin | |
ShowMessage('El cliente no se encuentra'); | |
DbeCodigoclienteClick(Sender); | |
end; | |
end; | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoclienteExit(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//********************************************[ Salir de dbecodigoCliente ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if (DbeCodigocliente.Text<>'') and (Falquiler.Active) then | |
begin | |
ActQuery(IBQClientes, 'Select * From CLIENTES WHERE CLIENTES.CODIGO='+QuotedStr(DbeCodigocliente.Text)); | |
if IBQClientes.IsEmpty then | |
begin | |
ShowMessage('El código del cliente no se encuentra, intentelo con otro código'); | |
DbeCodigocliente.SetFocus; | |
end; | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoclienteKeyDown(Sender: TObject; var Key: Word; | |
Shift: TShiftState); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ OnKeyDow dbedit ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if CombiKeyDown('b','ctrl',Key,Shift) then | |
begin | |
FBuscarCliente.ShowModal; | |
Key := 0; | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoUnidadClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************[ pulsar sobre dbedit ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
try | |
FBuscarUnidad.ShowModal; | |
finally | |
if varSBusqueda<>'Cancelado' then | |
begin | |
ActQuery(IBQ,'SELECT * FROM UNIDADES WHERE UNIDADES.ID = '+QuotedStr(varSBusqueda)); | |
if not IBQ.IsEmpty then | |
begin | |
if IBQ.FieldByName('DISPONIBLE').value='S' then | |
begin | |
if VarBmodo then DbeCodigoUnidad.Field.value:=IBQ.FieldByName('CODIGO').Value | |
else DbeCodigoUnidad.Field.value:=IBQ.FieldByName('CODIGO_BARRAS').Value | |
end else | |
begin | |
ShowMessage('La unidad no esta disponible'); | |
DbeCodigoUnidadClick(Sender); | |
end; | |
end; | |
end; | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoUnidadExit(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//********************************************[ Salir de dbecodigoUnidad ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if (DbeCodigoUnidad.Text<>'') and (Falquiler.Active) then | |
begin | |
if VarBmodo then | |
begin | |
ActQuery(IBQUnidad, 'Select * From UNIDADES WHERE UNIDADES.CODIGO='+QuotedStr(DbeCodigoUnidad.Text)); | |
if IBQUnidad.IsEmpty then | |
begin | |
ShowMessage('El código de la unidad no se encuentra, intentelo con otro código'); | |
DbeCodigoUnidad.SetFocus; | |
end; | |
end else | |
begin | |
ActQuery(IBQUnidad, 'Select * From UNIDADES WHERE UNIDADES.CODIGO_BARRAS='+QuotedStr(DbeCodigoUnidad.Text)); | |
if IBQUnidad.IsEmpty then | |
begin | |
ShowMessage('El código de barras de la unidad no se encuentra, intentelo con otro código'); | |
DbeCodigoUnidad.SetFocus; | |
end; | |
end; | |
end; | |
end; | |
procedure TFalquiler.DbeCodigoUnidadKeyDown(Sender: TObject; var Key: Word; | |
Shift: TShiftState); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ OnKeyDow dbedit ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if CombiKeyDown('B','CTRL',Key,Shift) then | |
begin | |
FBuscarUnidad.ShowModal; | |
Key := 0; | |
end; | |
case key of | |
vk_f2 :VarBmodo:=False; //Pasamos a buscar por un código de barras | |
end; | |
end; | |
procedure TFalquiler.DBText10Click(Sender: TObject); | |
begin | |
Fcobrosalquiler.ShowModal; | |
end; | |
procedure TFalquiler.FormActivate(Sender: TObject); | |
begin | |
VarBmodo:=True; | |
if not (DsPrincipal.DataSet.State in [dsEdit,dsInsert]) then DsPrincipal.DataSet.Last; | |
carga; | |
end; | |
procedure TFalquiler.FormKeyPress(Sender: TObject; var Key: Char); | |
//------------------------------------------------------------------------------ | |
//************************************************[ Al pulsar una tecla ]****** | |
// Al pulsar la tecla salta al foco del siguiente componente, si esta admitido | |
//------------------------------------------------------------------------------ | |
begin | |
if (Key = #13) then {Si se ha pulsado enter } | |
if (ActiveControl is TEdit) | |
or (ActiveControl is TDBEdit) | |
or (ActiveControl is TDBComboBox) then | |
begin | |
Key := #0; { anula la puulsación } | |
Perform(WM_NEXTDLGCTL, 0, 0); { mueve al próximo control } | |
end | |
end; | |
procedure TFalquiler.SBBAjarClick(Sender: TObject); | |
begin | |
DataSource3.DataSet.Next; | |
end; | |
procedure TFalquiler.SBBuscarUnidadClick(Sender: TObject); | |
begin | |
try | |
FBuscarUnidad.ShowModal; | |
finally //Cargamos el id de la unidad con un SQL | |
ActQuery(IBQUnidad, 'SELECT * FROM UNIDADES WHERE UNIDADES.ID='+QuotedStr(varSBusqueda)); | |
end; | |
end; | |
procedure TFalquiler.SBCancelarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*****************************************************[ Cancelar Proceso]****** | |
//------------------------------------------------------------------------------ | |
begin | |
if DsPrincipal.DataSet.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
SBConfirmar.Enabled:=False; | |
SBCancelar.Enabled:=False; | |
end; | |
procedure TFalquiler.SBCancelarTodoClick(Sender: TObject); | |
begin | |
if DsPrincipal.DataSet.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; | |
PanelDatos.Enabled:=False; | |
PanelOculto.Visible:=False; | |
Botonera1.Enabled:=True; | |
SBConfirmar.Enabled:=False; | |
SBCancelar.Enabled:=False; | |
end; | |
procedure TFalquiler.SBCerrarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************[ Grabar completamente ]***** | |
//------------------------------------------------------------------------------ | |
var VarRAlquilado, VarRTotal:Real; | |
VariVecesAlquilado:Integer; | |
VarBCobrar:Boolean; | |
begin | |
if not (DsPrincipal.DataSet.State in [dsEdit,dsInsert]) then | |
begin | |
try //Aseguramos el nuevo número de registro | |
if DM.IBDConfiguracionNUMERADOR_ALQUILER.Value<StrToInt(DsPrincipal.DataSet.FieldByName('REGISTRO').value) then | |
begin //Grabamos si el número de alquiler, es mayor que tenemos en la tabla confi en número de alquiler | |
DM.IBDConfiguracion.Edit; | |
DM.IBDConfiguracionNUMERADOR_ALQUILER.Value:=StrToInt(DsPrincipal.DataSet.FieldByName('REGISTRO').value); | |
DM.IBDConfiguracion.post; | |
end; | |
Dm.IBT.CommitRetaining; | |
except | |
on E: Exception do | |
begin | |
MessageBeep(1000); | |
ShowMessage('Se ha producido un error y el proceso no se ha podido terminar Unidad:[ UAlquiler ] Modulo:[ Grabar ]' + Chr(13) + Chr(13) | |
+ 'Clase de error: ' + E.ClassName + Chr(13) + Chr(13) | |
+ 'Mensaje del error:' + E.Message+Chr(13) + Chr(13) | |
+ ' '+Chr(13) + Chr(13) | |
+ 'El proceso ha quedado interrumpido'); | |
if DM.IBDClientes.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
//Búscamos todos los alquileres que tenga este registro | |
ActQuery(IBQalquiler,'Select * From ALQUILER WHERE (ALQUILER.REGISTRO =' +QuotedStr(DsPrincipal.DataSet.FieldByName('REGISTRO').value)+ | |
') AND (ALQUILER.DIA_DEVOLUCION IS NULL)'); | |
if not IBQalquiler.IsEmpty then | |
begin //Si hay datos, pasamos el valor al registro de la unidad ahora y no antes ya que estamos confirmando | |
VarRTotal:=0; //Para poner el total del alquiler | |
VarBCobrar:=False; | |
with IBQalquiler do | |
begin | |
First; | |
while not Eof do | |
begin //Búscamos el valor del alquiler | |
if DM.IBDUnidades.Locate('CODIGO',FieldByName('UNIDAD').Value,[loPartialKey,loCaseInsensitive]) then | |
begin | |
ActQuery(IbqValor,'SELECT * FROM VALOR_ALQUILER where VALOR_ALQUILER.CODIGO='+QuotedStr(IBQUnidad.FieldByName('VALOR_ALQUILER').value)); | |
if not IbqValor.IsEmpty then | |
begin | |
VarRAlquilado:=DM.IBDUnidadesRENDIMIENTO.Value; | |
VariVecesAlquilado:=DM.IBDUnidadesALQUILADA_VECES.Value; | |
//Cargamos el valor nuevo al rendimiento de la unidad teniendo en cuenta si es precio de oferta o precio normal, según el día | |
if xfsema(Now)=DM.IBDConfiguracionDIA_OFERTA.Value then | |
begin | |
if IBQalquiler.FieldByName('PAGADA').Value<>'S' then VarRTotal:=VarRTotal+IbqValor.FieldByName('PRECIO_OFERTA').Value; | |
end else | |
begin | |
if IBQalquiler.FieldByName('PAGADA').Value<>'S' then VarRTotal:=VarRTotal+IbqValor.FieldByName('PRECIO').Value; | |
end; | |
end; | |
VarRAlquilado:=0; | |
VariVecesAlquilado:=0; | |
if IBQalquiler.FieldByName('PAGADA').Value<>'S' then VarBCobrar:=True; //Si hay algo sin pagar lo marcamos | |
Next; | |
end; //Localizar código de la unidad | |
end; //Que no este eof | |
end; //with IBQalquiler do | |
end; // if not IBQalquiler.IsEmpty then | |
if VarBCobrar then | |
begin | |
Case Application.MessageBox(pchar( '¿Realizar el cobreo de este alquiler?'), pchar('Realizar cobro'), MB_YESNO+MB_ICONQUESTION) of | |
IDYES:begin //Si-llamamos al módulo de cobros | |
try | |
VarRPendientepago:=VarRTotal; | |
FCobrosAlquiler.ShowModal; | |
finally | |
try //GRabamos en el cliente | |
if VarRPendientepago>0 then | |
begin | |
if DM.IBDClientes.Locate('CODIGO',DsPrincipal.DataSet.FieldByName('CLIENTE').Value,[loPartialKey,loCaseInsensitive]) then | |
begin | |
DM.IBDClientes.Edit; | |
DM.IBDClientesPENDIENTE.Value:=DM.IBDClientesPENDIENTE.Value+VarRPendientepago; | |
DM.IBDClientes.Post; | |
DM.IBT.CommitRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
except | |
on E: Exception do | |
begin | |
MessageBeep(1000); | |
ShowMessage('Se ha producido un error y el proceso no se ha podido terminar Unidad:[ UAlquiler ] Modulo:[ Grabar ]' + Chr(13) + Chr(13) | |
+ 'Clase de error: ' + E.ClassName + Chr(13) + Chr(13) | |
+ 'Mensaje del error:' + E.Message+Chr(13) + Chr(13) | |
+ ' '+Chr(13) + Chr(13) | |
+ 'El proceso ha quedado interrumpido'); | |
if DM.IBDClientes.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
end; | |
end; | |
IDNO:begin //No, entonces MArcamos como pendientes | |
//GRabamos en el cliente | |
try | |
if VarRPendientepago>0 then | |
begin | |
if DM.IBDClientes.Locate('CODIGO',DsPrincipal.DataSet.FieldByName('CLIENTE').Value,[loPartialKey,loCaseInsensitive]) then | |
begin | |
DM.IBDClientes.Edit; | |
DM.IBDClientesPENDIENTE.Value:=DM.IBDClientesPENDIENTE.Value+VarRPendientepago; | |
DM.IBDClientes.Post; | |
DM.IBT.CommitRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
except | |
on E: Exception do | |
begin | |
MessageBeep(1000); | |
ShowMessage('Se ha producido un error y el proceso no se ha podido terminar Unidad:[ UAlquiler ] Modulo:[ Grabar ]' + Chr(13) + Chr(13) | |
+ 'Clase de error: ' + E.ClassName + Chr(13) + Chr(13) | |
+ 'Mensaje del error:' + E.Message+Chr(13) + Chr(13) | |
+ ' '+Chr(13) + Chr(13) | |
+ 'El proceso ha quedado interrumpido'); | |
if DM.IBDClientes.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
end; | |
end; | |
end; | |
end else ShowMessage('Tiene un dato sin grabar previamente, grabelo primero y luego intentelo de nuevo'); | |
end; | |
procedure TFalquiler.SBConfirmarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************[ Grabar temporalmente ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if DsPrincipal.DataSet.State in [dsInsert, dsEdit] then | |
begin | |
if (DbeCodigocliente.Text<>'') and (DbeCodigoUnidad.Text<>'') then | |
begin | |
try | |
if DsPrincipal.DataSet.State in [dsInsert, dsEdit] then | |
begin | |
DsPrincipal.DataSet.FieldByName('PAGADA').Value:='N'; | |
DsPrincipal.DataSet.FieldByName('RACARGO').Value:=0; | |
end; | |
ActQuery(IbqValor,'SELECT * FROM VALOR_ALQUILER where VALOR_ALQUILER.CODIGO='+QuotedStr(IBQUnidad.FieldByName('VALOR_ALQUILER').value)); | |
if not IbqValor.IsEmpty then | |
begin | |
if xfsema(Now)=DM.IBDConfiguracionDIA_OFERTA.Value then DsPrincipal.DataSet.FieldByName('LIBRE').Value:=FloatToStr(IbqValor.FieldByName('PRECIO_OFERTA').value) | |
else DsPrincipal.DataSet.FieldByName('LIBRE').Value:=FloatToStr(IbqValor.FieldByName('PRECIO').value); | |
DsPrincipal.DataSet.FieldByName('VALOR_RECARGO_DIA').Value:=IbqValor.FieldByName('PENALIZACION_DIA').value; | |
DsPrincipal.DataSet.FieldByName('DIA_DEVOLUCION_PREVISTO').Value:=now+IbqValor.FieldByName('DIAS').value; | |
DsPrincipal.DataSet.FieldByName('USUARIO').Value:=VarSUsuario; | |
end; | |
if DsPrincipal.DataSet.State in [dsInsert] then | |
begin //Grbamos la unidad el registro de veces alquilado | |
if DM.IBDUnidades.Locate('CODIGO',IBQUnidad.FieldByName('CODIGO').Value, [loPartialKey,loCaseInsensitive]) then | |
begin | |
DM.IBDUnidades.edit; | |
DM.IBDUnidadesALQUILADA_VECES.value:=DM.IBDUnidadesALQUILADA_VECES.value+1; | |
if xfsema(Now)=DM.IBDConfiguracionDIA_OFERTA.Value then DM.IBDUnidadesRENDIMIENTO.value:=DM.IBDUnidadesRENDIMIENTO.value+IbqValor.FieldByName('PRECIO_OFERTA').value | |
else DM.IBDUnidadesRENDIMIENTO.value:=DM.IBDUnidadesRENDIMIENTO.value+IbqValor.FieldByName('PRECIO').value; | |
DM.IBDUnidadesDISPONIBLE.Value:='N'; | |
DM.IBDUnidades.Post; | |
end; | |
end; | |
DsPrincipal.DataSet.Post; | |
carga; | |
SBConfirmar.Enabled:=False; | |
SBCancelar.Enabled:=False; | |
Case Application.MessageBox(pchar( '¿Desea añadir otra unidad al alquiler?'),pchar('introducir otra unidad'),MB_YESNO+MB_ICONQUESTION) of | |
IDYES:SBNuevoalqClick(Sender); //Si | |
end; | |
except | |
on E: Exception do | |
begin | |
MessageBeep(1000); | |
ShowMessage('Se ha producido un error y el proceso no se ha podido terminar Unidad:[ UAlquiler ] Modulo:[ Grabar ]' + Chr(13) + Chr(13) | |
+ 'Clase de error: ' + E.ClassName + Chr(13) + Chr(13) | |
+ 'Mensaje del error:' + E.Message+Chr(13) + Chr(13) | |
+ ' '+Chr(13) + Chr(13) | |
+ 'El proceso no se ha grabado, estando en edición aún'); | |
end; | |
end; | |
end else ShowMessage('Falta rellenar el código de cliente o el de la unidad'); | |
end else ShowMessage('No esta en modo edición'); | |
end; | |
procedure TFalquiler.SBEditarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*******************************************[ Editar el actual registro ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
if DsPrincipal.DataSet.IsEmpty<>true then | |
begin | |
DSPrincipal.DataSet.Edit; | |
PanelDatos.Enabled:=True; | |
PanelOculto.Visible:=True; | |
Botonera1.Enabled:=false; | |
SBConfirmar.Enabled:=True; | |
SBCancelar.Enabled:=True; | |
carga; | |
DbeCodigocliente.SetFocus; | |
end else ShowMessage('No hay tregistros disponibles para editar') | |
end; | |
procedure TFalquiler.SbNotaClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//************************************************************[ Ver notas ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Fvernota.Memo1.Lines.Text:=DsIBQClientes.DataSet.FieldByName('NOTAS').Value; | |
Fvernota.Show; | |
end; | |
procedure TFalquiler.SBNuevoClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBnuevo ]***** | |
//------------------------------------------------------------------------------ | |
var VarIRegistro:Integer; | |
begin | |
DsPrincipal.DataSet.Insert; | |
VarIRegistro:=DM.IBDConfiguracionNUMERADOR_ALQUILER.Value; | |
VarIRegistro:=VarIRegistro+1; | |
DsPrincipal.DataSet.FieldByName('REGISTRO').Value:=IntToStr(VarIRegistro); | |
DsPrincipal.DataSet.FieldByName('DIA_ALQUILER').Value:=Now; | |
PanelDatos.Enabled:=True; | |
PanelOculto.Visible:=True; | |
Botonera1.Enabled:=false; | |
VarIModoApertura:=0; | |
VarBmodo:=True; | |
carga; | |
SBConfirmar.Enabled:=True; | |
SBCancelar.Enabled:=True; | |
DbeCodigocliente.SetFocus; | |
end; | |
procedure TFalquiler.SBSalirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBSalir ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Close; | |
end; | |
procedure TFalquiler.SBSubirClick(Sender: TObject); | |
begin | |
DataSource3.DataSet.Prior; | |
end; | |
procedure TFalquiler.SpeedButton1Click(Sender: TObject); | |
begin | |
if not (DataSource3.DataSet.State in [dsEdit,dsInsert]) then | |
begin | |
if DsPrincipal.DataSet.Locate('ID',IBQalquiler.FieldByName('ID').Value,[loPartialKey,loCaseInsensitive]) then | |
begin | |
Case Application.MessageBox( pchar( '¿Esta seguro de eliminar el actual registro?'), pchar('Eliminar registro'), | |
MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2) of | |
IDYES:if not (DsPrincipal.DataSet.State in [dsEdit,dsInsert]) then DsPrincipal.DataSet.Delete; //Si | |
end; | |
end; | |
end; | |
end; | |
procedure TFalquiler.SpeedButton2Click(Sender: TObject); | |
begin | |
if not (DsPrincipal.DataSet.State in [dsEdit,dsInsert]) then | |
begin | |
if DsPrincipal.DataSet.Locate('ID',IBQalquiler.FieldByName('ID').Value,[loPartialKey,loCaseInsensitive]) then | |
begin | |
DsPrincipal.DataSet.Edit; | |
SBConfirmar.Enabled:=True; | |
SBCancelar.Enabled:=True; | |
end; | |
end; | |
end; | |
procedure TFalquiler.SpeedButton3Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Buscar alquiler ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
try | |
FBuscarAlquiler.ShowModal; | |
finally | |
//Cargamos el ide seleccionado con un locate | |
end; | |
end; | |
procedure TFalquiler.SpeedButton4Click(Sender: TObject); | |
begin | |
//Podemos cambiar el estado de unidad, bien este perdida o alquilada, registrando usario y sus datos | |
//Realmente este botón va en entradas y no en alquiler | |
end; | |
procedure TFalquiler.SBNuevoalqClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBnuevo ]***** | |
//------------------------------------------------------------------------------ | |
var VarIRegistro:Integer; | |
Varscodigocliente:string; | |
begin | |
VarIRegistro:=StrToInt(DBText10.Caption); | |
Varscodigocliente:=DsPrincipal.DataSet.FieldByName('CLIENTE').VALUE; | |
DsPrincipal.DataSet.Insert; | |
DsPrincipal.DataSet.FieldByName('REGISTRO').Value:=IntToStr(VarIRegistro); | |
DsPrincipal.DataSet.FieldByName('DIA_ALQUILER').Value:=Now; | |
DsPrincipal.DataSet.FieldByName('CLIENTE').VALUE:=Varscodigocliente; | |
PanelDatos.Enabled:=True; | |
PanelOculto.Visible:=True; | |
Botonera1.Enabled:=false; | |
VarIModoApertura:=0; | |
VarBmodo:=True; | |
SBConfirmar.Enabled:=True; | |
SBCancelar.Enabled:=True; | |
DbeCodigoUnidad.SetFocus; | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment