142 lines
4.9 KiB
ObjectPascal
142 lines
4.9 KiB
ObjectPascal
|
|
unit uEditorProveedor;
|
|||
|
|
|
|||
|
|
interface
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
|
uEditorContacto, uCustomView, uViewBase, uViewContacto,
|
|||
|
|
uViewProveedor, JvAppStorage, JvAppRegistryStorage, JvComponentBase,
|
|||
|
|
JvFormPlacement, DB, uDADataTable, ImgList, PngImageList, StdActns, ActnList,
|
|||
|
|
ComCtrls, TBX, TB2Item, TB2Dock, TB2Toolbar, ExtCtrls, JvExControls,
|
|||
|
|
JvComponent, JvNavigationPane,
|
|||
|
|
|
|||
|
|
uIEditorProveedor, cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit,
|
|||
|
|
cxSpinEdit, cxDBEdit, pngimage, TBXStatusBars, JvExComCtrls, JvStatusBar,
|
|||
|
|
dxLayoutLookAndFeels, uViewContactoDatosBancarios, uBizContactos,
|
|||
|
|
uViewProveedorDatosComerciales, uViewDetallesGenerico, uViewDireccionesEntrega,
|
|||
|
|
uDAInterfaces, uViewSubCuentaContacto, StdCtrls, DBCtrls,
|
|||
|
|
uViewPersonalContacto;
|
|||
|
|
|
|||
|
|
type
|
|||
|
|
TfEditorProveedor = class(TfEditorContacto, IEditorProveedor)
|
|||
|
|
frViewProveedor1: TfrViewProveedor;
|
|||
|
|
pagDatosComerciales: TTabSheet;
|
|||
|
|
frViewProveedorDatosComerciales1: TfrViewProveedorDatosComerciales;
|
|||
|
|
pagDirecciones: TTabSheet;
|
|||
|
|
frViewDireccionesEntrega1: TfrViewDireccionesEntrega;
|
|||
|
|
actGruposProveedor: TAction;
|
|||
|
|
PagContabilidad: TTabSheet;
|
|||
|
|
frViewSubCuentaContacto1: TfrViewSubCuentaContacto;
|
|||
|
|
procedure actGruposProveedorExecute(Sender: TObject);
|
|||
|
|
protected
|
|||
|
|
procedure GuardarInterno; override;
|
|||
|
|
procedure EliminarInterno; override;
|
|||
|
|
procedure SetContacto(const Value: IBizContacto); override;
|
|||
|
|
public
|
|||
|
|
constructor Create(AOwner: TComponent); override;
|
|||
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
implementation
|
|||
|
|
{$R *.dfm}
|
|||
|
|
{$INCLUDE ..\..\..\FactuGES.inc}
|
|||
|
|
|
|||
|
|
{ TfEditorProveedor }
|
|||
|
|
|
|||
|
|
uses
|
|||
|
|
uDialogUtils, uGruposProveedorController, uBizGruposProveedor, uProveedoresController;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedor.actGruposProveedorExecute(Sender: TObject);
|
|||
|
|
var
|
|||
|
|
AGruposController : IGruposProveedorController;
|
|||
|
|
AGrupos : IBizGrupoProveedor;
|
|||
|
|
begin
|
|||
|
|
AGruposController := TGruposProveedorController.Create;
|
|||
|
|
try
|
|||
|
|
AGrupos := (AGruposController.BuscarTodos as IBizGrupoProveedor);
|
|||
|
|
AGruposController.VerTodos(AGrupos);
|
|||
|
|
finally
|
|||
|
|
AGrupos := NIL;
|
|||
|
|
AGruposController := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
constructor TfEditorProveedor.Create(AOwner: TComponent);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
ViewContacto := frViewProveedor1;
|
|||
|
|
|
|||
|
|
{$IFDEF CONTABILIDAD}
|
|||
|
|
pagContabilidad.TabVisible := true;
|
|||
|
|
{$ELSE}
|
|||
|
|
pagContabilidad.TabVisible := false;
|
|||
|
|
{$ENDIF}
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedor.EliminarInterno;
|
|||
|
|
begin
|
|||
|
|
if (ShowConfirmMessage('<27>Desea borrar este proveedor?', '') = IDYES) then
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedor.GuardarInterno;
|
|||
|
|
begin
|
|||
|
|
//Si tiene al menos una subcuenta asociada se pone el flag el cliente a 1, asi podremos poner un icono en la lista de proveedores
|
|||
|
|
//que tengan subcuenta asociada, y comprobar si al modificar no tene ya seleccionada una subcuenta en tal caso la crearemos si el
|
|||
|
|
//usuario lo desea.
|
|||
|
|
if ((Contacto as IBizProveedor).SubCuentas.RecordCount <> 0) then
|
|||
|
|
(Controller as IProveedoresController).SetTieneSubCuenta(Contacto as IBizProveedor, True)
|
|||
|
|
else
|
|||
|
|
(Controller as IProveedoresController).SetTieneSubCuenta(Contacto as IBizProveedor, False);
|
|||
|
|
|
|||
|
|
(Contacto as IBizProveedor).Edit;
|
|||
|
|
(Contacto as IBizProveedor).ES_ACREEDOR := StrToInt(frViewSubCuentaContacto1.rdTipoSubcuenta.Value);
|
|||
|
|
|
|||
|
|
//Evitamos que cada vez que se a<>ada un proveedor te pregunta por defecto se crea y punto.
|
|||
|
|
//Otro caso es al modificar que si que hay que preguntar por si acaso desea asignar el manualmente una subcuenta existente
|
|||
|
|
if not Contacto.EsNuevo
|
|||
|
|
and (frViewSubCuentaContacto1.cbIgnorarContabilidad.EditValue = 0)
|
|||
|
|
and ((Contacto as IBizProveedor).TIENE_SUBCUENTA = 0) then
|
|||
|
|
if (ShowConfirmMessage('Confirmaci<63>n de subcuenta', 'El proveedor no tiene asignada ninguna subcuenta contable.' + #10#13 + '<27>Desea crear una nueva subcuenta para el proveedor?') = IDNO) then
|
|||
|
|
(Controller as IProveedoresController).SetIgnorarContabilidad(Contacto as IBizProveedor, True);
|
|||
|
|
|
|||
|
|
inherited;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedor.PonerTitulos(const ATitulo: string);
|
|||
|
|
var
|
|||
|
|
FTitulo : String;
|
|||
|
|
begin
|
|||
|
|
if Assigned(Contacto) then
|
|||
|
|
begin
|
|||
|
|
if Contacto.EsNuevo then
|
|||
|
|
FTitulo := 'Nuevo proveedor'
|
|||
|
|
else
|
|||
|
|
FTitulo := 'Proveedor';
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
inherited PonerTitulos(FTitulo);
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
procedure TfEditorProveedor.SetContacto(const Value: IBizContacto);
|
|||
|
|
begin
|
|||
|
|
inherited;
|
|||
|
|
if Assigned(Contacto) then
|
|||
|
|
begin
|
|||
|
|
frViewDireccionesEntrega1.dsDetalles.DataTable := Contacto.Direcciones.DataTable;
|
|||
|
|
frViewProveedorDatosComerciales1.Contacto := Contacto;
|
|||
|
|
frViewSubCuentaContacto1.Contacto := Contacto;
|
|||
|
|
|
|||
|
|
if Contacto.EsNuevo then
|
|||
|
|
frViewSubCuentaContacto1.rdTipoSubcuenta.ItemIndex := 0;
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
begin
|
|||
|
|
frViewProveedorDatosComerciales1.Contacto := NIL;
|
|||
|
|
frViewDireccionesEntrega1.dsDetalles.DataTable := NIL;
|
|||
|
|
frViewSubCuentaContacto1.Contacto := NIL;
|
|||
|
|
end;
|
|||
|
|
end;
|
|||
|
|
|
|||
|
|
end.
|