AbetoDesign_FactuGES2/Source/Modulos/Contactos/Views/uViewComercial.pas

103 lines
3.1 KiB
ObjectPascal

unit uViewComercial;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewContacto, dxLayoutLookAndFeels, DB, uDADataTable,
dxLayoutControl, cxMemo, cxDBEdit, cxContainer, cxEdit, cxTextEdit, cxControls,
cxMaskEdit, cxSpinEdit, ImgList, PngImageList, ActnList, cxHyperLinkEdit,
Buttons, PngSpeedButton, cxDropDownEdit, cxCalendar, cxGraphics,
uDAInterfaces, uCustomView, uViewBase, uViewTienda, uBizContactos,
uDelegacionesController,
uViewObservaciones, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox;
type
IViewComercial = interface(IViewContacto)
['{ABD730E4-9328-42C4-8567-F46CE93AE826}']
end;
TfrViewComercial = class(TfrViewContacto, IViewComercial)
cbDelegacionCliente: TcxDBComboBox;
dxLayoutControlContactoItem21: TdxLayoutItem;
dxLayoutControlContactoItem22: TdxLayoutItem;
edtComision: TcxDBSpinEdit;
dxLayoutControlContactoItem23: TdxLayoutItem;
eFechaBaja: TcxDBDateEdit;
dxLayoutControlContactoItem24: TdxLayoutItem;
eCausaBaja: TcxDBTextEdit;
procedure CustomViewCreate(Sender: TObject);
procedure CustomViewDestroy(Sender: TObject);
procedure cbDelegacionClientePropertiesInitPopup(Sender: TObject);
procedure cbDelegacionClientePropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
private
FDelegacionesController: IDelegacionesController;
end;
implementation
{$R *.dfm}
uses uFactuGES_App, uBizDelegaciones;
procedure TfrViewComercial.cbDelegacionClientePropertiesInitPopup(Sender: TObject);
begin
inherited;
with cbDelegacionCliente.Properties.Items do
begin
BeginUpdate;
try
Clear;
AddStrings(FDelegacionesController.DarListaDelegaciones);
finally
EndUpdate;
end;
end;
end;
procedure TfrViewComercial.cbDelegacionClientePropertiesValidate(
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
var Error: Boolean);
var
ADelegacion : IBizDelegacion;
begin
inherited;
with (Sender as TcxDBComboBox) do
begin
if (Length(DisplayValue) > 0) and (DisplayValue <> (Contacto as IBizComercial).DELEGACION) then
if Properties.LookupItems.IndexOf(DisplayValue) < 0 then
begin
Properties.LookupItems.BeginUpdate;
ADelegacion := FDelegacionesController.BuscarTodos;
ADelegacion.DataTable.Active := True;
try
FDelegacionesController.Anadir(ADelegacion);
ADelegacion.DESCRIPCION := DisplayValue;
FDelegacionesController.Guardar(ADelegacion);
Properties.LookupItems.Add(DisplayValue);
finally
Properties.LookupItems.EndUpdate;
ADelegacion := NIL;
end;
end;
end;
end;
procedure TfrViewComercial.CustomViewCreate(Sender: TObject);
begin
inherited;
FDelegacionesController := TDelegacionesController.Create;
end;
procedure TfrViewComercial.CustomViewDestroy(Sender: TObject);
begin
FDelegacionesController := NIL;
inherited;
end;
end.