unit uViewCliente; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewContacto, DB, uDADataTable, DBCtrls, StdCtrls, Mask, ExtCtrls, uCustomView, uViewBase, JvComponent, JvFormAutoSize, cxControls, uBizContactos, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutLookAndFeels, dxLayoutControl, cxMemo, cxHyperLinkEdit, ImgList, ActnList, Buttons, PngSpeedButton, PngImageList, cxGraphics, cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, uGruposClienteController, uProcedenciasClienteController, cxCheckBox, cxSpinEdit, Grids, DBGrids, uDAInterfaces, uViewTienda, uViewObservaciones; type IViewCliente = interface(IViewContacto) ['{C06F4653-1745-4B7E-A3DC-102B2F23238E}'] end; TfrViewCliente = class(TfrViewContacto, IViewCliente) dxLayoutControlContactoItem24: TdxLayoutItem; eNombreComercial: TcxDBTextEdit; dxLayoutControlContactoItem26: TdxLayoutItem; cbClienteBloqueado: TcxDBCheckBox; dxLayoutControlContactoGroup18: TdxLayoutGroup; dxLayoutControlContactoItem19: TdxLayoutItem; cbGrupoCliente: TcxDBComboBox; eBloqueo: TcxDBTextEdit; actBloqueoCliente: TAction; dxLayoutControlContactoItem22: TdxLayoutItem; eCodigoAsignado: TcxDBTextEdit; dxLayoutControlContactoItem23: TdxLayoutItem; cbProcedenciaCliente: TcxDBComboBox; dxLayoutControlContactoItem27: TdxLayoutItem; procedure cbGrupoClientePropertiesInitPopup(Sender: TObject); procedure cbGrupoClientePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure CustomViewCreate(Sender: TObject); procedure CustomViewDestroy(Sender: TObject); procedure actBloqueoClienteExecute(Sender: TObject); procedure cbProcedenciaClientePropertiesInitPopup(Sender: TObject); procedure cbProcedenciaClientePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure CustomViewShow(Sender: TObject); protected FGrupoController: IGruposClienteController; FProcedenciaController: IProcedenciasClienteController; procedure SetContacto(const Value: IBizContacto); override; end; implementation {$R *.dfm} uses uBizGruposCliente, uBizProcedenciasCliente, uFactuGES_App; { TfrViewCliente } procedure TfrViewCliente.actBloqueoClienteExecute(Sender: TObject); begin inherited; eBloqueo.Enabled := cbClienteBloqueado.Checked; end; procedure TfrViewCliente.cbGrupoClientePropertiesInitPopup(Sender: TObject); begin inherited; with cbGrupoCliente.Properties.Items do begin BeginUpdate; try Clear; AddStrings(FGrupoController.DarListaGruposCliente); finally EndUpdate; end; end; end; procedure TfrViewCliente.cbGrupoClientePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var AGrupo : IBizGrupoCliente; begin inherited; with (Sender as TcxDBComboBox) do begin if (Length(DisplayValue) > 0) and (DisplayValue <> (Contacto as IBizCliente).GRUPO_CLIENTE) then if Properties.LookupItems.IndexOf(DisplayValue) < 0 then begin Properties.LookupItems.BeginUpdate; AGrupo := FGrupoController.BuscarTodos; AGrupo.DataTable.Active := True; try FGrupoController.Anadir(AGrupo); AGrupo.DESCRIPCION := DisplayValue; FGrupoController.Guardar(AGrupo); Properties.LookupItems.Add(DisplayValue); finally Properties.LookupItems.EndUpdate; AGrupo := NIL; end; end; end; end; procedure TfrViewCliente.cbProcedenciaClientePropertiesInitPopup(Sender: TObject); begin inherited; with cbProcedenciaCliente.Properties.Items do begin BeginUpdate; try Clear; AddStrings(FProcedenciaController.DarListaProcedenciasCliente); finally EndUpdate; end; end; end; procedure TfrViewCliente.cbProcedenciaClientePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var AProcedencia : IBizProcedenciaCliente; begin inherited; with (Sender as TcxDBComboBox) do begin if (Length(DisplayValue) > 0) and (DisplayValue <> (Contacto as IBizCliente).PROCEDENCIA_CLIENTE) then if Properties.LookupItems.IndexOf(DisplayValue) < 0 then begin Properties.LookupItems.BeginUpdate; AProcedencia := FProcedenciaController.BuscarTodos; AProcedencia.DataTable.Active := True; try FProcedenciaController.Anadir(AProcedencia); AProcedencia.DESCRIPCION := DisplayValue; FProcedenciaController.Guardar(AProcedencia); Properties.LookupItems.Add(DisplayValue); finally Properties.LookupItems.EndUpdate; AProcedencia := NIL; end; end; end; end; procedure TfrViewCliente.CustomViewCreate(Sender: TObject); begin inherited; FGrupoController := TGruposClienteController.Create; FProcedenciaController := TProcedenciasClienteController.Create; end; procedure TfrViewCliente.CustomViewDestroy(Sender: TObject); begin FGrupoController := NIL; FProcedenciaController := NIL; inherited; end; procedure TfrViewCliente.CustomViewShow(Sender: TObject); begin inherited; //Solo se ve campo tienda en Graden if (AppFactuGES.EmpresaActiva.ID = 1) then begin dxLayoutControlContactoGroup100.Enabled := False; dxLayoutControlContactoGroup100.Visible := False; end else begin dxLayoutControlContactoGroup100.Enabled := True; dxLayoutControlContactoGroup100.Visible := True; end; end; procedure TfrViewCliente.SetContacto(const Value: IBizContacto); begin inherited; if Assigned(FContacto) then eBloqueo.Enabled := cbClienteBloqueado.Checked; end; end.