git-svn-id: https://192.168.0.254/svn/Proyectos.EstudioCarnicero_ProGestion/trunk@5 1b8572a8-2d6b-b84e-8c90-20ed86fa4eca
216 lines
6.6 KiB
ObjectPascal
216 lines
6.6 KiB
ObjectPascal
unit uEditorFacturasCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uEditorGrid, Menus, DB, uDADataTable, JvAppStorage,
|
||
JvAppRegistryStorage, JvComponent, JvFormPlacement, ImgList,
|
||
PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems,
|
||
TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
||
JvNavigationPane, uViewGrid, pngimage, uBizFacturasCliente,
|
||
JvComponentBase, dxLayoutLookAndFeels, uCustomView, uViewBase,
|
||
uViewBarraSeleccion, StdCtrls;
|
||
|
||
type
|
||
IEditorFacturasCliente = interface(IEditorGrid)
|
||
['{597BF875-BD19-4B68-898F-B09982B3360A}']
|
||
function GetFacturasCliente: IBizFacturasCliente;
|
||
procedure SetFacturasCliente(const Value: IBizFacturasCliente);
|
||
property FacturasCliente: IBizFacturasCliente read GetFacturasCliente write SetFacturasCliente;
|
||
end;
|
||
|
||
TfEditorFacturasCliente = class(TfEditorGrid, IEditorFacturasCliente)
|
||
actAbonar: TAction;
|
||
TBXItem35: TTBXItem;
|
||
procedure actEliminarExecute(Sender: TObject);
|
||
procedure actModificarExecute(Sender: TObject);
|
||
procedure actNuevoExecute(Sender: TObject);
|
||
procedure actDuplicarExecute(Sender: TObject);
|
||
procedure actAbonarExecute(Sender: TObject);
|
||
procedure actAbonarUpdate(Sender: TObject);
|
||
private
|
||
FFacturasCliente: IBizFacturasCliente;
|
||
protected
|
||
function GetFacturasCliente: IBizFacturasCliente;
|
||
procedure SetFacturasCliente(const Value: IBizFacturasCliente);
|
||
procedure SetViewGrid(const Value: IViewGrid); override;
|
||
public
|
||
constructor Create(AOwner: TComponent); override;
|
||
destructor Destroy; override;
|
||
property FacturasCliente: IBizFacturasCliente read GetFacturasCliente
|
||
write SetFacturasCliente;
|
||
end;
|
||
|
||
var
|
||
fEditorFacturasCliente: TfEditorFacturasCliente;
|
||
|
||
implementation
|
||
|
||
uses
|
||
uDataModuleFacturasCliente, uViewFacturasCliente,
|
||
uEditorUtils;
|
||
|
||
{$R *.dfm}
|
||
|
||
function ShowEditorFacturasCliente (ABizObject : TDADataTableRules) : TModalResult;
|
||
var
|
||
AEditor: TfEditorFacturasCliente;
|
||
begin
|
||
AEditor := TfEditorFacturasCliente.Create(Application);
|
||
try
|
||
AEditor.FacturasCliente := (ABizObject as IBizFacturasCliente);
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
function ShowSelectEditorFacturasCliente (ABizObject : TDADataTableRules) : TModalResult;
|
||
var
|
||
AEditor: TfEditorFacturasCliente;
|
||
begin
|
||
AEditor := TfEditorFacturasCliente.Create(Application);
|
||
try
|
||
AEditor.FacturasCliente := (ABizObject as IBizFacturasCliente);
|
||
// AEditor.SelectionBarVisible := True;
|
||
Result := AEditor.ShowModal;
|
||
finally
|
||
AEditor.Release;
|
||
end;
|
||
end;
|
||
|
||
{
|
||
*************************** TfEditorFacturasCliente ***************************
|
||
}
|
||
constructor TfEditorFacturasCliente.Create(AOwner: TComponent);
|
||
begin
|
||
inherited;
|
||
ViewGrid := CreateView(TfrViewFacturasCliente) as IViewFacturasCliente;
|
||
end;
|
||
|
||
destructor TfEditorFacturasCliente.Destroy;
|
||
begin
|
||
FFacturasCliente := NIL;
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actEliminarExecute(Sender: TObject);
|
||
begin
|
||
if (Application.MessageBox('<27>Desea borrar esta factura de cliente?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
inherited;
|
||
ViewGrid.RefreshGrid;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actModificarExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FacturasCliente.Show;
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.SyncFocusedRecordsFromDataSet;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actNuevoExecute(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
FacturasCliente.Insert;
|
||
|
||
case ViewGrid.Grid.ActiveLevel.Index of
|
||
0: begin
|
||
FacturasCliente.CLASEFACTURA := CTE_NORMAL;
|
||
FacturasCliente.PAGADA := SITUACION_PENDIENTE;
|
||
FacturasCliente.setReferencia(CTE_NORMAL);
|
||
end;
|
||
1: begin
|
||
FacturasCliente.CLASEFACTURA := CTE_NORMAL;
|
||
FacturasCliente.PAGADA := SITUACION_PAGADO;
|
||
FacturasCliente.setReferencia(CTE_NORMAL);
|
||
end;
|
||
2: begin
|
||
FacturasCliente.CLASEFACTURA := CTE_PROFORMA;
|
||
FacturasCliente.setReferencia(CTE_PROFORMA);
|
||
end;
|
||
end;
|
||
|
||
FacturasCliente.Show;
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.SyncFocusedRecordsFromDataSet;
|
||
end;
|
||
|
||
function TfEditorFacturasCliente.GetFacturasCliente: IBizFacturasCliente;
|
||
begin
|
||
Result := FFacturasCliente;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.SetFacturasCliente(const Value: IBizFacturasCliente);
|
||
begin
|
||
FFacturasCliente := Value;
|
||
dsDataTable.DataTable := FFacturasCliente.DataTable;
|
||
if Assigned(ViewGrid) then
|
||
(ViewGrid as IViewFacturasCliente).FacturasCliente := FacturasCliente;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.SetViewGrid(const Value: IViewGrid);
|
||
begin
|
||
inherited;
|
||
if Assigned(ViewGrid) and Assigned(FacturasCliente) then
|
||
(ViewGrid as IViewFacturasCliente).FacturasCliente := FFacturasCliente;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actDuplicarExecute(Sender: TObject);
|
||
var
|
||
AFactura : IBizFacturasCliente;
|
||
begin
|
||
inherited;
|
||
AFactura := dmFacturasCliente.GetItem(FacturasCliente.CODIGO);
|
||
FacturasCliente.Insert;
|
||
FacturasCliente.CopyFrom(AFactura);
|
||
FacturasCliente.DataTable.ApplyUpdates;
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actAbonarExecute(Sender: TObject);
|
||
var
|
||
AFactura : IBizFacturasCliente;
|
||
begin
|
||
ViewGrid.SyncFocusedRecordsFromGrid; // Esto va ANTES. No cambiar.
|
||
if (FacturasCliente.CLASEFACTURA = CTE_NORMAL) then
|
||
begin
|
||
AFactura := dmFacturasCliente.GetItem(FacturasCliente.CODIGO);
|
||
FacturasCliente.Insert;
|
||
FacturasCliente.CopyFrom(AFactura, False);
|
||
FacturasCliente.Edit;
|
||
FacturasCliente.CLASEFACTURA := CTE_ABONO;
|
||
FacturasCliente.cambiarSigno;
|
||
FacturasCliente.Post;
|
||
FacturasCliente.DataTable.ApplyUpdates;
|
||
MessageBox(0, 'Se ha abonado correctamente la factura elegida.', 'Factura abonada', MB_ICONWARNING or MB_OK);
|
||
ViewGrid.RefreshGrid;
|
||
ViewGrid.GotoFirst;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorFacturasCliente.actAbonarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
if Assigned(dsDataTable.DataTable) then
|
||
(Sender as TAction).Enabled := (not dsDataTable.DataTable.IsEmpty)
|
||
and not (dsDataTable.DataTable.State = dsInsert)
|
||
else
|
||
(Sender as TAction).Enabled := False;
|
||
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := (Sender as TAction).Enabled and (ViewGrid.Grid.ActiveLevel.Index <> 2);
|
||
end;
|
||
|
||
initialization
|
||
RegisterEditor(IBizFacturasCliente, ShowEditorFacturasCliente, etItems);
|
||
RegisterEditor(IBizFacturasCliente, ShowSelectEditorFacturasCliente, etSelectItems);
|
||
|
||
finalization
|
||
|
||
end.
|