This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
FactuGES/Agenda/EditorCitas.pas
2007-06-26 08:08:27 +00:00

197 lines
5.1 KiB
ObjectPascal
Raw Permalink Blame History

unit EditorCitas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxSchedulerEventEditor, cxLookAndFeelPainters, cxMemo,
cxDropDownEdit, cxCheckBox, cxSpinEdit, cxTimeEdit, cxCalendar, ExtCtrls,
cxMaskEdit, cxImageComboBox, cxControls, cxContainer, cxEdit, cxTextEdit,
StdCtrls, cxButtons, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox,
TablaObras, cxRadioGroup;
type
TfEditorCitas = class(TcxSchedulerEventEditor)
Panel1: TPanel;
Bevel6: TBevel;
cbObra: TcxComboBox;
teCodigoContrato: TEdit;
cbTipos: TcxComboBox;
Tipo: TLabel;
cxRadioButton1: TcxRadioButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure cbObraPropertiesEditValueChanged(Sender: TObject);
procedure cbTiposPropertiesEditValueChanged(Sender: TObject);
private
FListaObras : TListaObras;
procedure CargarObras;
procedure CargarTipos;
protected
procedure ApplyChanges; override;
function GetFormColor: TColor; override;
procedure InitializeControls; override;
procedure LoadEventValuesIntoControls; override;
function IsValid: Boolean; override;
procedure SetCaptions; override;
procedure SetReadOnly(AValue: Boolean); override;
procedure UpdateEventValuesFromControls; override;
public
//
end;
var
fEditorCitas: TfEditorCitas;
implementation
uses
cxSchedulerDialogs, Configuracion, StrFunc,
cxSchedulerUtils;
{$R *.dfm}
{ TfEditorCitas }
procedure TfEditorCitas.ApplyChanges;
begin
inherited;
end;
procedure TfEditorCitas.CargarObras;
var
I, J, AResourceIndex: Integer;
begin
I := 0;
try
with cbObra.Properties.Items do
begin
BeginUpdate;
Clear;
for I := 0 to FListaObras.Count - 1 do
begin
J := Add(FListaObras.Obras[I].CodigoContrato + ' ' + FListaObras.Obras[I].Nombre);
if VarToStr(Event.GetCustomFieldValueByName('CODIGOCONTRATO')) = FListaObras.Obras[I].CodigoContrato then
AResourceIndex := I;
end;
cbObra.ItemIndex := AResourceIndex;
end;
finally
cbObra.Properties.Items.EndUpdate;
end;
end;
function TfEditorCitas.GetFormColor: TColor;
begin
Result := $00F9FEFF;
end;
procedure TfEditorCitas.InitializeControls;
begin
inherited InitializeControls;
CargarObras;
CargarTipos;
end;
function TfEditorCitas.IsValid: Boolean;
begin
Result := inherited IsValid;
end;
procedure TfEditorCitas.LoadEventValuesIntoControls;
var
i : integer;
begin
inherited LoadEventValuesIntoControls;
if not EsCadenaVacia(Event.GetCustomFieldValueByName('TIPOTAREA')) then
cbTipos.EditValue := Event.GetCustomFieldValueByName('TIPOTAREA');
if not EsCadenaVacia(Event.GetCustomFieldValueByName('CODIGOCONTRATO')) then
teCodigoContrato.Text := Event.GetCustomFieldValueByName('CODIGOCONTRATO');
end;
procedure TfEditorCitas.SetCaptions;
begin
inherited SetCaptions;
lbResource.Caption := 'Instalador:';
lbSubject.Caption := 'Asunto:';
lbStartTime.Caption := 'Comienzo:';
lbEndTime.Caption := 'Final:';
cbAllDayEvent.Caption := 'Todo el d<>a';
end;
procedure TfEditorCitas.SetReadOnly(AValue: Boolean);
begin
inherited;
end;
procedure TfEditorCitas.UpdateEventValuesFromControls;
begin
inherited UpdateEventValuesFromControls;
//$F4A6C4, $C4CEA4, $74E6FC
try
//Event.LabelColor := EventLabelColors[cbTipos.ItemIndex];
// post the data from the custom editing controls
if not VarIsNull(teCodigoContrato.Text) then
Event.SetCustomFieldValueByName('CODIGOCONTRATO', teCodigoContrato.Text);
if not VarIsNull(cbTipos.EditValue) then
Event.SetCustomFieldValueByName('TIPOTAREA', cbTipos.EditValue);
except
on E: Exception do
ShowMessage('Can''t post data' + #13#10 + E.Message);
end;
end;
procedure TfEditorCitas.FormCreate(Sender: TObject);
begin
inherited;
FListaObras := TListaObras.Create(tsoAbiertas);
end;
procedure TfEditorCitas.FormDestroy(Sender: TObject);
begin
inherited;
FreeAndNil(FListaObras);
end;
procedure TfEditorCitas.cbObraPropertiesEditValueChanged(Sender: TObject);
begin
inherited;
if not EsCadenaVacia(cbObra.EditValue) then
begin
teCodigoContrato.Text := Copy(cbObra.EditValue, 0, Pos(' ', cbObra.EditValue)-1);
teSubject.EditValue := Copy(cbObra.EditValue, Pos(' ', cbObra.EditValue), MaxInt);
teSubject.EditModified := True;
end;
end;
procedure TfEditorCitas.CargarTipos;
begin
with cbTipos.Properties do
begin
BeginUpdate;
Items.Clear;
Items.Add('Montaje');
Items.Add('Remate');
Items.Add('Entrega de material');
EndUpdate;
end;
cbTipos.ItemIndex := 0;
end;
procedure TfEditorCitas.cbTiposPropertiesEditValueChanged(Sender: TObject);
begin
inherited;
icbLabel.ItemIndex := cbTipos.ItemIndex + 1;
icbLabel.EditModified := True;
end;
initialization
cxEventEditorClass := TfEditorCitas; // indicate that the new Event modal dialog will be invoked at runtime
end.