Created
August 8, 2013 18:10
-
-
Save anonymous/6187111 to your computer and use it in GitHub Desktop.
Agenda de contactos de programa de Gestión desde 0
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 Uagenda; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ExtCtrls, StdCtrls, Spin, Buttons, DB, Grids, DBGrids, ComCtrls, | |
IBCustomDataSet, IBQuery, DBCtrls, MyDbIbMemo, SPBBC; | |
type | |
TFagenda = class(TForm) | |
Panel1: TPanel; | |
TabControl1: TTabControl; | |
DBGrid1: TDBGrid; | |
DsPrincipal: TDataSource; | |
SBPrimero: TSpeedButton; | |
SBMenosx: TSpeedButton; | |
SBMenos1: TSpeedButton; | |
SBMas1: TSpeedButton; | |
SBMasX: TSpeedButton; | |
SBUltimo: TSpeedButton; | |
SEMobeByX: TSpinEdit; | |
Label1: TLabel; | |
SBBuscar: TSpeedButton; | |
SB_Salir: TSpeedButton; | |
RadioGroup1: TRadioGroup; | |
GBBuscar: TGroupBox; | |
Ebusqueda: TEdit; | |
BLimpiar: TButton; | |
BBuscar: TButton; | |
BCerrar: TButton; | |
SBImprimir: TSpeedButton; | |
CheckBox1: TCheckBox; | |
IBQContactos: TIBQuery; | |
DBIBMemo1: TDBIBMemo; | |
Panel2: TPanel; | |
DBText1: TDBText; | |
SpeedButtonBC1: TSpeedButtonBC; | |
IBQContactosID: TIntegerField; | |
IBQContactosMODULO: TIBStringField; | |
IBQContactosCODIGO: TIBStringField; | |
IBQContactosNOMBRE: TIBStringField; | |
IBQContactosTF: TIBStringField; | |
IBQContactosTF2: TIBStringField; | |
IBQContactosFAX: TIBStringField; | |
IBQContactosMAIL: TIBStringField; | |
IBQContactosMAIL2: TIBStringField; | |
IBQContactosWEB: TIBStringField; | |
IBQContactosCLAVEWEB: TIBStringField; | |
IBQContactosMOVIL: TIBStringField; | |
IBQContactosMOVIL2: TIBStringField; | |
IBQContactosNOTAS: TWideMemoField; | |
procedure SBImprimirClick(Sender: TObject); | |
procedure FormKeyPress(Sender: TObject; var Key: Char); | |
procedure FormActivate(Sender: TObject); | |
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; | |
DataCol: Integer; Column: TColumn; State: TGridDrawState); | |
procedure SBPrimeroClick(Sender: TObject); | |
procedure SBMenosxClick(Sender: TObject); | |
procedure SBMenos1Click(Sender: TObject); | |
procedure SBMas1Click(Sender: TObject); | |
procedure SBMasXClick(Sender: TObject); | |
procedure SBUltimoClick(Sender: TObject); | |
procedure SBBuscarClick(Sender: TObject); | |
procedure BLimpiarClick(Sender: TObject); | |
procedure BBuscarClick(Sender: TObject); | |
procedure BCerrarClick(Sender: TObject); | |
procedure SB_SalirClick(Sender: TObject); | |
procedure EbusquedaChange(Sender: TObject); | |
procedure SpeedButtonBC1Click(Sender: TObject); | |
procedure TabControl1Change(Sender: TObject); | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
Fagenda: TFagenda; | |
implementation | |
{$R *.dfm} | |
uses UDM, Fun, FUN_DBGRID, UMENU, Uvercontactos; | |
procedure TFagenda.BBuscarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ Buscar ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
if CheckBox1.Checked=false then | |
begin | |
case RadioGroup1.ItemIndex of | |
0:ActQuery(IBQContactos,'select * from CONTACTOS WHERE UPPER (NOMBRE) LIKE '+QuotedStr('%'+UpperCase(Ebusqueda.Text)+'%')); | |
1:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (UPPER (NOMBRE) LIKE '+QuotedStr('%'+UpperCase(Ebusqueda.Text)+'%')+') AND (MODULO ='+QuotedStr('PROVEEDORES')+')'); | |
2:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (UPPER (NOMBRE) LIKE '+QuotedStr('%'+UpperCase(Ebusqueda.Text)+'%')+') AND (MODULO ='+QuotedStr('CLIENTES')+')'); | |
3:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (UPPER (NOMBRE) LIKE '+QuotedStr('%'+UpperCase(Ebusqueda.Text)+'%')+') AND (MODULO ='+QuotedStr('EMPLEADOS')+')'); | |
end; | |
end else | |
begin | |
case RadioGroup1.ItemIndex of | |
0:ActQuery(IBQContactos,'select * from CONTACTOS'); | |
1:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (MODULO ='+QuotedStr('PROVEEDORES')+')'); | |
2:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (MODULO ='+QuotedStr('CLIENTES')+')'); | |
3:ActQuery(IBQContactos,'select * from CONTACTOS WHERE (MODULO ='+QuotedStr('EMPLEADOS')+')'); | |
end; | |
IBQContactos.Locate(RemoveAcentos(UpperCase('NOMBRE')),RemoveAcentos(UpperCase(Ebusqueda.Text)),[ loCaseInsensitive,loPartialKey]); | |
end; | |
end; | |
procedure TFagenda.BCerrarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*****************************************************[ Cerrar Busqueda ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
BLimpiarClick(Sender); | |
GBBuscar.Visible:=False; | |
end; | |
procedure TFagenda.BLimpiarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************[ Limpia la busqueda ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
Ebusqueda.Text:=''; | |
BBuscarClick(Sender); | |
Ebusqueda.SetFocus; | |
end; | |
procedure TFagenda.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; | |
DataCol: Integer; Column: TColumn; State: TGridDrawState); | |
//------------------------------------------------------------------------------ | |
//********************************************************[ Grid Agenda ]******* | |
// Dibujamos el zebrado | |
//------------------------------------------------------------------------------ | |
begin | |
Zebrado(DsPrincipal,DBGrid1,Rect, Column, State, COLOR1GRID,COLOR2GRID); | |
end; | |
procedure TFagenda.EbusquedaChange(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************[ Mientras se escribe en busqueda ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
BBuscarClick(sender); | |
end; | |
procedure TFagenda.FormActivate(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************[ Al activarse el Form ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
if Fagenda.Active then ActQuery(IBQContactos,'select * from CONTACTOS') | |
end; | |
procedure TFagenda.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 TFagenda.SBBuscarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Abrir Busqueda ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
GBBuscar.Visible:=True; | |
Ebusqueda.SetFocus; | |
end; | |
procedure TFagenda.SBImprimirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ Imprimir ]**** | |
//------------------------------------------------------------------------------ | |
begin | |
//Para la impresión | |
end; | |
procedure TFagenda.SBMas1Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************[ Avanzar un registro ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.Next; | |
end; | |
procedure TFagenda.SBMasXClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************[ Avanzar x Registros ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.MoveBy(SEMobeByX.Value); | |
end; | |
procedure TFagenda.SBMenos1Click(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************[ Retroceder 1 registro ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.Prior; | |
end; | |
procedure TFagenda.SBMenosxClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**********************************************[ Retroceder x Registros ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.MoveBy(-SEMobeByX.Value); | |
end; | |
procedure TFagenda.SBPrimeroClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************[ Ir al Primer Registro ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.First; | |
end; | |
procedure TFagenda.SBUltimoClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************[ Ir al último registro ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
DSPrincipal.DataSet.Last; | |
end; | |
procedure TFagenda.SB_SalirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Salir Del Form ]****** | |
//------------------------------------------------------------------------------ | |
begin | |
RadioGroup1.ItemIndex:=0; | |
Close; | |
end; | |
procedure TFagenda.SpeedButtonBC1Click(Sender: TObject); | |
begin | |
FverContactos.ShowModal; | |
end; | |
procedure TFagenda.TabControl1Change(Sender: TObject); | |
// ------------------------------------------------------------------------------- | |
// ******************************************[ ELEGIMOS UNA PESTAÑA EN AGENDA]**** | |
// ******************************************************************************* | |
// ------------------------------------------------------------------------------- | |
begin | |
ActQAgenda(IBQContactos,TabControl1,'NOMBRE','select * from CONTACTOS',False,False,False); | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment