Created
March 7, 2015 12:45
-
-
Save anonymous/29671ebc05abf548bb61 to your computer and use it in GitHub Desktop.
Clientes del tutorial video club
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 UClientes; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ComCtrls, StdCtrls, DBCtrls, Grids, DBGrids, Mask, Buttons, ExtCtrls, | |
DB, ExtDlgs; | |
type | |
TFClientes = class(TForm) | |
Panelcontenedor: TPanel; | |
PanelDatos: TPanel; | |
PanelOculto: TPanel; | |
SpeedButton8: TSpeedButton; | |
SpeedButton9: TSpeedButton; | |
DBGrid1: TDBGrid; | |
Botonera1: TPanel; | |
SBNuevo: TSpeedButton; | |
SBEditar: TSpeedButton; | |
SBBorrar: TSpeedButton; | |
SBSalir: TSpeedButton; | |
SBBuscar: TSpeedButton; | |
DBNavigator1: TDBNavigator; | |
Botonera2: TPanel; | |
Label9: TLabel; | |
SpeedButton16: TSpeedButton; | |
SBBuscarnormal: TSpeedButton; | |
Edit1: TEdit; | |
StatusBar1: TStatusBar; | |
Label1: TLabel; | |
DbeCodigo: TDBEdit; | |
DsPrincipal: TDataSource; | |
Label2: TLabel; | |
DbeNombre: TDBEdit; | |
Label3: TLabel; | |
DbeDireccion: TDBEdit; | |
Label4: TLabel; | |
DbePoblacion: TDBEdit; | |
Label5: TLabel; | |
DbeProvincia: TDBEdit; | |
Label6: TLabel; | |
DbeDocumento: TDBEdit; | |
Label7: TLabel; | |
DbeTelefono: TDBEdit; | |
Label8: TLabel; | |
DbeMovil: TDBEdit; | |
Label10: TLabel; | |
DbeEmail: TDBEdit; | |
Label11: TLabel; | |
DbeCodigoPostal: TDBEdit; | |
Label12: TLabel; | |
DbeACuenta: TDBEdit; | |
Label13: TLabel; | |
DbePendiente: TDBEdit; | |
Label14: TLabel; | |
DBImage1: TDBImage; | |
Label15: TLabel; | |
Memo1: TMemo; | |
SBCargar: TSpeedButton; | |
SBWebCam: TSpeedButton; | |
SpeedButton12: TSpeedButton; | |
SBEditMemo: TSpeedButton; | |
SpeedButton10: TSpeedButton; | |
OpenPictureDialog1: TOpenPictureDialog; | |
RadioGroup1: TRadioGroup; | |
sbCarnet: TSpeedButton; | |
SBPagar: TSpeedButton; | |
SbACuenta: TSpeedButton; | |
procedure SBWebCamClick(Sender: TObject); | |
procedure SBCargarClick(Sender: TObject); | |
procedure SBEditMemoClick(Sender: TObject); | |
procedure SBSalirClick(Sender: TObject); | |
procedure SBNuevoClick(Sender: TObject); | |
procedure SBEditarClick(Sender: TObject); | |
procedure SBBorrarClick(Sender: TObject); | |
procedure SBBuscarClick(Sender: TObject); | |
procedure SpeedButton9Click(Sender: TObject); | |
procedure SpeedButton8Click(Sender: TObject); | |
procedure SBBuscarnormalClick(Sender: TObject); | |
procedure SpeedButton16Click(Sender: TObject); | |
procedure RadioGroup1Click(Sender: TObject); | |
procedure DsPrincipalDataChange(Sender: TObject; Field: TField); | |
procedure FormActivate(Sender: TObject); | |
procedure FormKeyPress(Sender: TObject; var Key: Char); | |
procedure comprobar; | |
procedure SbACuentaClick(Sender: TObject); | |
procedure SBPagarClick(Sender: TObject); | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
FClientes: TFClientes; | |
implementation | |
{$R *.dfm} | |
Uses UDM, Funciones, UCapturas, UEditor, UMoviemientos; | |
procedure TFClientes.comprobar; | |
//------------------------------------------------------------------------------ | |
//************************************************************[ comprobar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if FClientes.Active then | |
begin | |
if not (DsPrincipal.DataSet.State in [dsEdit,dsInsert]) then | |
begin | |
if not (DM.IBDClientes.IsEmpty) then | |
begin | |
if DsPrincipal.DataSet.FieldByName('NOTAS').Value<>'' then Memo1.Lines.Text:=DsPrincipal.DataSet.FieldByName('NOTAS').AsString | |
else Memo1.Lines.Clear; | |
end; | |
end; | |
end; | |
end; | |
procedure TFClientes.DsPrincipalDataChange(Sender: TObject; Field: TField); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Cambia de datos ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
comprobar; | |
end; | |
procedure TFClientes.FormActivate(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**********************************************************[ On Activate ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
comprobar; | |
end; | |
procedure TFClientes.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 TFClientes.RadioGroup1Click(Sender: TObject); | |
begin | |
case RadioGroup1.ItemIndex of | |
0:Label9.Caption:='Nombre'; | |
1:Label9.Caption:='Dirección'; | |
2:Label9.Caption:='Nº de documento'; | |
end; | |
end; | |
procedure TFClientes.SbACuentaClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************************[ A Cuenta ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
VarIModoApertura:=2; | |
FMovimientos.Show; | |
end; | |
procedure TFClientes.SBBorrarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*******************************************[ Borrar el Actual Registro ]****** | |
//------------------------------------------------------------------------------ | |
begin //Cambiar por el mensaje elegido | |
if (MessageBox(0, '¿Esta seguro de eliminar el registro actual?', | |
'Eliminar Registro', MB_ICONSTOP or MB_YESNO or MB_DEFBUTTON2) = ID_No) then abort | |
else begin | |
DSPrincipal.DataSet.Delete; | |
DM.IBT.CommitRetaining; | |
ShowMessage('El registro ha sido eliminado'); | |
end; | |
end; | |
procedure TFClientes.SBBuscarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Abrir Búsqueda ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
Botonera2.Visible:=True; | |
Edit1.SetFocus; | |
end; | |
procedure TFClientes.SBBuscarnormalClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************[ ejecutamos la búsqueda ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
case RadioGroup1.ItemIndex of | |
0:DSPrincipal.DataSet.Locate('NOMBRE',Edit1.Text,[loCaseInsensitive,loPartialKey]); | |
1:DSPrincipal.DataSet.Locate('DIRECCION',Edit1.Text,[loCaseInsensitive,loPartialKey]); | |
2:DSPrincipal.DataSet.Locate('DOCUMENTO',Edit1.Text,[loCaseInsensitive,loPartialKey]); | |
end; | |
end; | |
procedure TFClientes.SBCargarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*********************************************************[ Cargar imagen ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
CargaIimagenADBImagen(OpenPictureDialog1,DBImage1); | |
end; | |
procedure TFClientes.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; | |
DbeDocumento.SetFocus; | |
end else ShowMessage('No hay tregistros disponibles para editar') | |
end; | |
procedure TFClientes.SBEditMemoClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Editor del memo ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
VarSUnidad:='UCLIENTES'; | |
VarSMEMO:=Memo1.Lines.Text; | |
Feditor.Memo1.Lines:=Memo1.Lines; | |
Feditor.Show; | |
end; | |
procedure TFClientes.SBNuevoClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBnuevo ]***** | |
//------------------------------------------------------------------------------ | |
var VarIRegistro:Integer; | |
begin | |
DsPrincipal.DataSet.Insert; | |
VarIRegistro:=DM.IBDConfiguracionNUMERADOR_CLIENTE.Value; | |
VarIRegistro:=VarIRegistro+1; | |
DBECodigo.Field.Value:=IntToStr(VarIRegistro); | |
Memo1.Lines.Clear; | |
PanelDatos.Enabled:=True; | |
PanelOculto.Visible:=True; | |
Botonera1.Enabled:=false; | |
VarIModoApertura:=0; | |
DbeDocumento.SetFocus; | |
end; | |
procedure TFClientes.SBPagarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//****************************************************************[ Pagar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
VarIModoApertura:=3; | |
FMovimientos.Show; | |
end; | |
procedure TFClientes.SBSalirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBSalir ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Close; | |
end; | |
procedure TFClientes.SBWebCamClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***************************************************************[ Webcam ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
VarSUnidad:='UCLIENTES'; | |
FCapturas.show; | |
end; | |
procedure TFClientes.SpeedButton16Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//****************************************************[ Salir de búsqueda ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Edit1.Text:=''; | |
Botonera2.Visible:=False; | |
end; | |
procedure TFClientes.SpeedButton8Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*****************************************************[ Cancelar Proceso]****** | |
//------------------------------------------------------------------------------ | |
begin | |
if DsPrincipal.DataSet.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; | |
PanelOculto.Visible:=False; | |
Botonera1.Enabled:=True; | |
PanelDatos.Enabled:=False; | |
end; | |
procedure TFClientes.SpeedButton9Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//********************************************************[ Grabar datos ]****** | |
//------------------------------------------------------------------------------ | |
var VarIFase:Integer; | |
begin | |
try | |
VarIFase:=1; | |
if DsPrincipal.DataSet.State in [dsInsert] then VarBGrabarNumerador:=True else VarBGrabarNumerador:=False; | |
if DsPrincipal.DataSet.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Post; | |
if VarBGrabarNumerador=true then | |
begin | |
VarIFase:=2; | |
DM.IBDConfiguracion.Edit; | |
DM.IBDConfiguracionNUMERADOR_CLIENTE.Value:=StrToInt(DBECodigo.Field.Value); | |
DM.IBDConfiguracion.Post; | |
VarBGrabarNumerador:=False; | |
end; | |
DM.IBT.CommitRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
except | |
on E: Exception do | |
begin | |
MessageBeep(1000); | |
ShowMessage('Se ha producido un error y el proceso no se ha podido terminar Unidad:[ UUsuarios ] Modulo:[ Grabar ]' + Chr(13) + Chr(13) | |
+ 'Fase del error [ '+IntToStr(VarIFase)+' ]'+ 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 DsPrincipal.DataSet.State in [dsEdit,dsInsert] then DSPrincipal.DataSet.Cancel; | |
DM.IBT.RollbackRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta | |
end; | |
end; | |
PanelOculto.Visible:=False; | |
PanelDatos.Enabled:=False; | |
Botonera1.Enabled:=True; | |
end; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment