git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@446 0c75b7a4-871f-7646-8a2f-f78d34cc349f
186 lines
5.7 KiB
ObjectPascal
186 lines
5.7 KiB
ObjectPascal
unit uEditorEmpleados;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
uEditorContactos, Menus, DB, uDADataTable, JvAppStorage,
|
|
JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList, PngImageList,
|
|
StdActns, ActnList, uCustomView, uViewBase, uViewBarraSeleccion, ComCtrls,
|
|
TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls,
|
|
JvExControls, JvComponent, JvNavigationPane, uViewGridBase, uViewGrid,
|
|
uViewContactos, uViewEmpleados, uIEditorEmpleados, pngimage, TBXStatusBars,
|
|
JvExComCtrls, JvStatusBar, JSDialog, uContactosController, uDAInterfaces;
|
|
|
|
type
|
|
TfEditorEmpleados = class(TfEditorContactos, IEditorEmpleados)
|
|
frViewEmpleados1: TfrViewEmpleados;
|
|
JsPrevisualizarDialog: TJSDialog;
|
|
JsImprimirDialog: TJSDialog;
|
|
JsListaContactosNoEliminados: TJSDialog;
|
|
|
|
protected
|
|
procedure EliminarInterno; override;
|
|
procedure ImprimirInterno; override;
|
|
procedure PrevisualizarInterno; override;
|
|
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
uGridStatusUtils, uEditorGridBase, uDataModuleUsuarios, uDialogUtils, uBizContactos,
|
|
uEmpleadosController, uDBSelectionListUtils, uFactuGES_App;
|
|
|
|
{$R *.dfm}
|
|
|
|
constructor TfEditorEmpleados.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
ViewGrid := frViewEmpleados1;
|
|
end;
|
|
|
|
procedure TfEditorEmpleados.EliminarInterno;
|
|
var
|
|
AContactos: IBizContacto;
|
|
AllItems: Boolean;
|
|
begin
|
|
AContactos := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
if AllItems then
|
|
begin
|
|
if (Application.MessageBox('¿Desea borrar los empleados seleccionados?', 'Atención', MB_YESNO) = IDYES) then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
|
|
AContactos := (Controller as IEmpleadosController).ExtraerSeleccionados(Contactos) as IBizContacto;
|
|
end
|
|
end
|
|
else begin
|
|
if (Application.MessageBox('¿Desea borrar el empleado seleccionado?', 'Atención', MB_YESNO) = IDYES) then
|
|
AContactos := Contactos;
|
|
end;
|
|
|
|
if Assigned(AContactos) then
|
|
begin
|
|
(FController as IEmpleadosController).Eliminar(AContactos, AllItems);
|
|
if AllItems then
|
|
begin
|
|
if (AContactos.DataTable.RecordCount > 0) then
|
|
begin
|
|
with AContactos.DataTable do
|
|
begin
|
|
First;
|
|
while not EOF do
|
|
begin
|
|
JsListaContactosNoEliminados.Content.Add('Empleado: ' + AContactos.NOMBRE);
|
|
Next;
|
|
end;
|
|
end;
|
|
JsListaContactosNoEliminados.Execute;
|
|
end;
|
|
actRefrescar.Execute;
|
|
end;
|
|
end;
|
|
|
|
ViewGrid.GotoFirst;
|
|
end;
|
|
|
|
procedure TfEditorEmpleados.ImprimirInterno;
|
|
var
|
|
Respuesta : Integer;
|
|
AFichas: IBizEmpleado;
|
|
AllItems: Boolean;
|
|
begin
|
|
AFichas := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
|
|
AFichas := (Controller as IEmpleadosController).ExtraerSeleccionados(Contactos) as IBizEmpleado;
|
|
end
|
|
else
|
|
AFichas := (Contactos as IBizEmpleado);
|
|
|
|
if Assigned(AFichas) then
|
|
(FController as IEmpleadosController).Print(AFichas, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfEditorEmpleados.PonerTitulos(const ATitulo: string);
|
|
var
|
|
FTitulo : String;
|
|
begin
|
|
FTitulo := 'Lista de empleados - ' + AppFactuGES.EmpresaActiva.NOMBRE;
|
|
inherited PonerTitulos(FTitulo);
|
|
end;
|
|
|
|
procedure TfEditorEmpleados.PrevisualizarInterno;
|
|
var
|
|
Respuesta : Integer;
|
|
AFichas: IBizEmpleado;
|
|
AllItems: Boolean;
|
|
begin
|
|
AFichas := Nil;
|
|
AllItems := False;
|
|
|
|
if MultiSelect and Assigned(ViewGrid) then
|
|
AllItems := (ViewGrid.NumSeleccionados > 1);
|
|
|
|
//Si esta agrupado solo podré imprimir la lista de elementos visibles
|
|
if not ViewGrid.esSeleccionCeldaDatos then
|
|
inherited
|
|
else
|
|
begin
|
|
Respuesta := JsPrevisualizarDialog.Execute;
|
|
if Respuesta <> IDCANCEL then
|
|
begin
|
|
case JsPrevisualizarDialog.CustomButtonResult of
|
|
200 : begin // Lista de elementos visibles
|
|
inherited;
|
|
end;
|
|
100 : begin // Elemento Seleccionado
|
|
if AllItems then
|
|
begin
|
|
SeleccionarFilasDesdeGrid(ViewGrid._FocusedView, (Contactos as ISeleccionable).SelectedRecords);
|
|
AFichas := (Controller as IEmpleadosController).ExtraerSeleccionados(Contactos) as IBizEmpleado;
|
|
end
|
|
else
|
|
AFichas := (Contactos as IBizEmpleado);
|
|
|
|
if Assigned(AFichas) then
|
|
(FController as IEmpleadosController).Preview(AFichas, AllItems);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|