Skip to content

Instantly share code, notes, and snippets.

/T_V_CONFIGURACION
Created Feb 28, 2015

Embed
What would you like to do?
Modulo Configuración del Tutorial vídeo Club
unit UCONFIGURACION;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, DBCtrls, DB, Mask, ComCtrls, Buttons, ExtDlgs;
type
TFCONFIGURACION = class(TForm)
Botonera1: TPanel;
SBEditar: TSpeedButton;
SBSalir: TSpeedButton;
StatusBar1: TStatusBar;
PanelDatos: TPanel;
PanelOculto: TPanel;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
GroupBox1: TGroupBox;
Label1: TLabel;
DBEdit1: TDBEdit;
DsPrincipal: TDataSource;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
Label4: TLabel;
DBEdit4: TDBEdit;
Label5: TLabel;
DBEdit5: TDBEdit;
Label6: TLabel;
DBEdit6: TDBEdit;
Label7: TLabel;
DBEdit7: TDBEdit;
Label8: TLabel;
DBEdit8: TDBEdit;
Label9: TLabel;
DBEdit9: TDBEdit;
Label10: TLabel;
DBEdit10: TDBEdit;
Label11: TLabel;
DBEdit11: TDBEdit;
GroupBox2: TGroupBox;
Label12: TLabel;
DBENombre: TDBEdit;
Label13: TLabel;
DBEDireccion: TDBEdit;
Label14: TLabel;
DBEPoblacion: TDBEdit;
Label15: TLabel;
DBEProvincia: TDBEdit;
Label16: TLabel;
DBEDocumento: TDBEdit;
Label17: TLabel;
DBEEmail: TDBEdit;
Label18: TLabel;
DBETelefono: TDBEdit;
Label19: TLabel;
DBEMovil: TDBEdit;
Label20: TLabel;
DBEFax: TDBEdit;
Label21: TLabel;
DBEWeb: TDBEdit;
Label22: TLabel;
DBECodigoPostal: TDBEdit;
GroupBox3: TGroupBox;
Label23: TLabel;
Label24: TLabel;
Label25: TLabel;
Label26: TLabel;
DBENombreImpuesto: TDBEdit;
Label27: TLabel;
DBEPorcentajeImpuesto: TDBEdit;
Label28: TLabel;
DBEDia: TDBEdit;
Label29: TLabel;
DBESegundos: TDBEdit;
Label30: TLabel;
DBERegistros: TDBEdit;
ColorBox1: TColorBox;
ColorBox2: TColorBox;
ColorBox3: TColorBox;
Bevel1: TBevel;
Label31: TLabel;
Bevel2: TBevel;
Label32: TLabel;
Bevel3: TBevel;
Label33: TLabel;
SBMas: TSpeedButton;
SBMenos: TSpeedButton;
GroupBox4: TGroupBox;
Memo1: TMemo;
DBImage1: TDBImage;
SBCargar: TSpeedButton;
SBEditMemo: TSpeedButton;
StaticText1: TStaticText;
RadioGroup1: TRadioGroup;
OpenPictureDialog1: TOpenPictureDialog;
procedure SBEditarClick(Sender: TObject);
procedure SBMasClick(Sender: TObject);
procedure SBSalirClick(Sender: TObject);
procedure SBMenosClick(Sender: TObject);
procedure SBEditMemoClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SBCargarClick(Sender: TObject);
procedure SpeedButton9Click(Sender: TObject);
procedure SpeedButton8Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FCONFIGURACION: TFCONFIGURACION;
implementation
{$R *.dfm}
uses UDM,UEditor, Funciones;
procedure TFCONFIGURACION.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 TColorBox)
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 TFCONFIGURACION.FormShow(Sender: TObject);
//------------------------------------------------------------------------------
//***************************************************************[ OnShow ]*****
// Al mostrarse
//------------------------------------------------------------------------------
begin
if not (DsPrincipal.DataSet.State in [dsEdit]) then
begin
if DM.IBDConfiguracionCOLOR_DISPONIBLE.Value<>'' then ColorBox1.Selected:=StringToColor(DM.IBDConfiguracionCOLOR_DISPONIBLE.Value);
if DM.IBDConfiguracionCOLOR_NO_DISPONIBLE.Value<>'' then ColorBox2.Selected:=StringToColor(DM.IBDConfiguracionCOLOR_NO_DISPONIBLE.Value);
if DM.IBDConfiguracionCOLOR_BLOQUEADA.Value<>'' then ColorBox3.Selected:=StringToColor(DM.IBDConfiguracionCOLOR_BLOQUEADA.Value);
if DM.IBDConfiguracionLEY_PROTECCION_DATOS.Value<>'' then Memo1.Lines.Text:=DM.IBDConfiguracionLEY_PROTECCION_DATOS.Value;
end;
end;
procedure TFCONFIGURACION.SBCargarClick(Sender: TObject);
//------------------------------------------------------------------------------
//*********************************************************[ Cargar imagen ]****
//------------------------------------------------------------------------------
begin
CargaIimagenADBImagen(OpenPictureDialog1,DBImage1);
end;
procedure TFCONFIGURACION.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;
ColorBox1.SetFocus;
end else ShowMessage('No hay tregistros disponibles para editar')
end;
procedure TFCONFIGURACION.SBEditMemoClick(Sender: TObject);
//------------------------------------------------------------------------------
//******************************************************[ Editor del memo ]*****
//------------------------------------------------------------------------------
begin
VarSUnidad:='UCONFI';
VarSMEMO:=Memo1.Lines.Text;
Feditor.Memo1.Lines:=Memo1.Lines;
Feditor.Show;
end;
procedure TFCONFIGURACION.SBMasClick(Sender: TObject);
//------------------------------------------------------------------------------
//****************************************************************[ SBMas ]*****
// Aumenta en 1 el nivel del campo seleccionado entre Día, segundos y Registros
//------------------------------------------------------------------------------
begin
case RadioGroup1.ItemIndex of
0:begin
if DBEDia.Field.IsNull then DBEDia.field.Value:=1;
if DBEDia.Field.value<7 then DBEDia.field.Value:=DBEDia.field.Value+1;
end;
1:DBESegundos.field.Value:=DBESegundos.field.Value+1;
2:DBERegistros.field.Value:=DBERegistros.field.Value+1;
end;
end;
procedure TFCONFIGURACION.SBMenosClick(Sender: TObject);
//------------------------------------------------------------------------------
//**************************************************************[ SBMenos ]*****
// Disminuye 1 el nivel del campo seleccionado entre Día, segundos y Registros
//------------------------------------------------------------------------------
begin
case RadioGroup1.ItemIndex of
0:begin
if DBEDia.Field.IsNull then DBEDia.field.Value:=1;
if DBEDia.Field.value>1 then DBEDia.field.Value:=DBEDia.field.Value-1;
end;
1:if DBESegundos.Field.value>1 then DBESegundos.field.Value:=DBESegundos.field.Value-1;
2:if DBERegistros.Field.value>1 then DBERegistros.field.Value:=DBERegistros.field.Value-1;
end;
end;
procedure TFCONFIGURACION.SBSalirClick(Sender: TObject);
//------------------------------------------------------------------------------
//**************************************************************[ SBSalir ]*****
//------------------------------------------------------------------------------
begin
Close;
end;
procedure TFCONFIGURACION.SpeedButton8Click(Sender: TObject);
//------------------------------------------------------------------------------
//*****************************************************[ Cancelar Proceso]******
//------------------------------------------------------------------------------
begin
if DsPrincipal.DataSet.State in [dsEdit] then DSPrincipal.DataSet.Cancel;
DM.IBT.RollbackRetaining; //Donde IBT es el nombre de su Ibtrasaction, con ruta
PanelOculto.Visible:=False;
Botonera1.Enabled:=True;
PanelDatos.Enabled:=False;
end;
procedure TFCONFIGURACION.SpeedButton9Click(Sender: TObject);
//------------------------------------------------------------------------------
//********************************************************[ Grabar datos ]******
//------------------------------------------------------------------------------
begin
try
if DsPrincipal.DataSet.State in [dsEdit] then
begin
if ColorBox1.Selected<>StringToColor(DM.IBDConfiguracionCOLOR_DISPONIBLE.Value) then DM.IBDConfiguracionCOLOR_DISPONIBLE.Value:=ColorToString(ColorBox1.Selected);
if ColorBox2.Selected<>StringToColor(DM.IBDConfiguracionCOLOR_NO_DISPONIBLE.Value) then DM.IBDConfiguracionCOLOR_NO_DISPONIBLE.Value:=ColorToString(ColorBox2.Selected);
if ColorBox3.Selected<>StringToColor(DM.IBDConfiguracionCOLOR_BLOQUEADA.Value) then DM.IBDConfiguracionCOLOR_BLOQUEADA.Value:=ColorToString(ColorBox3.Selected);
if Memo1.Lines.Text<>DM.IBDConfiguracionLEY_PROTECCION_DATOS.Value then DM.IBDConfiguracionLEY_PROTECCION_DATOS.Value:=Memo1.Lines.Text;
DSPrincipal.DataSet.Post;
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:[ UConfiguración ] 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 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;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.