git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_FactuGES/trunk@4 6cb6b671-b4a0-dd4c-8bdc-3006503d97e9
184 lines
5.8 KiB
ObjectPascal
184 lines
5.8 KiB
ObjectPascal
unit uEditorSituacionPresupuesto;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, StdCtrls, ExtCtrls,
|
||
uIEditorSituacionPresupuesto, uPresupuestosController, uBizPresupuestos,
|
||
JvExControls, JvComponent, JvgWizardHeader, cxControls, cxContainer, cxEdit,
|
||
cxTextEdit, cxMaskEdit, cxDropDownEdit, cxCalendar, cxDBEdit, ActnList;
|
||
|
||
type
|
||
TfEditorSituacionPresupuesto = class(TForm, IEditorSituacionPresupuesto)
|
||
pnlSeleccion: TPanel;
|
||
bAceptar: TButton;
|
||
bCancelar: TButton;
|
||
JvgWizardHeader1: TJvgWizardHeader;
|
||
rbPendiente: TRadioButton;
|
||
rbAceptado: TRadioButton;
|
||
rbRechazado: TRadioButton;
|
||
Label1: TLabel;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
edtFechaAceptado: TcxDateEdit;
|
||
edtFechaRechazado: TcxDateEdit;
|
||
ActionList1: TActionList;
|
||
actPendiente: TAction;
|
||
actAceptado: TAction;
|
||
actRechazado: TAction;
|
||
actAceptar: TAction;
|
||
Label4: TLabel;
|
||
edtFechaPresupuesto: TEdit;
|
||
procedure actPendienteExecute(Sender: TObject);
|
||
procedure actAceptadoExecute(Sender: TObject);
|
||
procedure actRechazadoExecute(Sender: TObject);
|
||
procedure actAceptarExecute(Sender: TObject);
|
||
private
|
||
FController: IPresupuestosController;
|
||
FPresupuesto: IBizPresupuesto;
|
||
function GetController : IPresupuestosController;
|
||
procedure SetController (const Value : IPresupuestosController);
|
||
|
||
function GetPresupuesto: IBizPresupuesto;
|
||
procedure SetPresupuesto(const Value: IBizPresupuesto);
|
||
procedure RefrescarEstado;
|
||
public
|
||
property Presupuesto: IBizPresupuesto read GetPresupuesto write SetPresupuesto;
|
||
property Controller : IPresupuestosController read GetController
|
||
write SetController;
|
||
end;
|
||
|
||
implementation
|
||
|
||
{$R *.dfm}
|
||
|
||
uses
|
||
uDateUtils, DateUtils, uMontajesDetallesController, uBizMontajesDetalles;
|
||
|
||
{ TfEditorSituacionPedido }
|
||
|
||
procedure TfEditorSituacionPresupuesto.actAceptadoExecute(Sender: TObject);
|
||
begin
|
||
RefrescarEstado;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.actAceptarExecute(Sender: TObject);
|
||
var
|
||
AControllerMontajes: IMontajesDetallesController;
|
||
AMontaje: IBizMontajeDetalles;
|
||
begin
|
||
if rbPendiente.Checked then
|
||
if (FPresupuesto.SITUACION <> SITUACION_PENDIENTE) then
|
||
FController.CambiarSituacion(FPresupuesto, SITUACION_PENDIENTE);
|
||
|
||
if rbAceptado.Checked then
|
||
begin
|
||
if (FPresupuesto.SITUACION <> SITUACION_ACEPTADO) then
|
||
begin
|
||
FController.CambiarSituacion(FPresupuesto, SITUACION_ACEPTADO,
|
||
edtFechaAceptado.Date, False);
|
||
|
||
//Para crear un montaje asociado al presupuesto
|
||
if (Application.MessageBox('<27>Desea crear un montaje para este presupuesto?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
||
begin
|
||
try
|
||
AControllerMontajes := TMontajesDetallesController.Create;
|
||
AMontaje := AControllerMontajes.Nuevo(FPresupuesto);
|
||
// AMontaje := (AControllerMontajes.Nuevo as IBizMontajeDetalles);
|
||
// AMontaje.REFERENCIA := FPresupuesto.REFERENCIA;
|
||
// AMontaje.ID_PRESUPUESTO := FPresupuesto.ID;
|
||
// AMontaje.Cliente := FPresupuesto.Cliente;
|
||
AControllerMontajes.Guardar(AMontaje);
|
||
AControllerMontajes := Nil;
|
||
AMontaje := Nil;
|
||
except
|
||
FController.DescartarCambios(FPresupuesto);
|
||
AControllerMontajes.DescartarCambios((AMontaje));
|
||
AControllerMontajes := Nil;
|
||
AMontaje := Nil;
|
||
raise Exception.Create('Error, Ya existe un montaje asociado a este presupuesto');
|
||
end;
|
||
end;
|
||
|
||
//Guardamos el cambio de situaci<63>n del presupuesto
|
||
FController.Guardar(FPresupuesto);
|
||
end;
|
||
end;
|
||
|
||
if rbRechazado.Checked then
|
||
if (FPresupuesto.SITUACION <> SITUACION_RECHAZADO) then
|
||
FController.CambiarSituacion(FPresupuesto, SITUACION_RECHAZADO, edtFechaRechazado.Date);
|
||
|
||
ModalResult := mrOk;
|
||
Close;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.actPendienteExecute(Sender: TObject);
|
||
begin
|
||
RefrescarEstado;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.actRechazadoExecute(Sender: TObject);
|
||
begin
|
||
RefrescarEstado;
|
||
end;
|
||
|
||
function TfEditorSituacionPresupuesto.GetController: IPresupuestosController;
|
||
begin
|
||
Result := FController;
|
||
end;
|
||
|
||
function TfEditorSituacionPresupuesto.GetPresupuesto: IBizPresupuesto;
|
||
begin
|
||
Result := FPresupuesto;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.SetController(
|
||
const Value: IPresupuestosController);
|
||
begin
|
||
FController := Value;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.SetPresupuesto(const Value: IBizPresupuesto);
|
||
begin
|
||
FPresupuesto := Value;
|
||
if not FPresupuesto.DataTable.Active then
|
||
FPresupuesto.DataTable.Open;
|
||
|
||
edtFechaPresupuesto.Text := DateToStr(FPresupuesto.FECHA_PRESUPUESTO);
|
||
|
||
rbPendiente.Checked := (FPresupuesto.Situacion = SITUACION_PENDIENTE);
|
||
rbRechazado.Checked := (FPresupuesto.Situacion = SITUACION_RECHAZADO);
|
||
rbAceptado.Checked := (FPresupuesto.Situacion = SITUACION_ACEPTADO);
|
||
|
||
if not EsFechaVacia(FPresupuesto.FECHA_DECISION) then
|
||
begin
|
||
edtFechaAceptado.Date := FPresupuesto.FECHA_DECISION;
|
||
edtFechaRechazado.Date := FPresupuesto.FECHA_DECISION;
|
||
end
|
||
else begin
|
||
edtFechaAceptado.Clear;
|
||
edtFechaRechazado.Clear;
|
||
end;
|
||
end;
|
||
|
||
procedure TfEditorSituacionPresupuesto.RefrescarEstado;
|
||
begin
|
||
edtFechaAceptado.Enabled := rbAceptado.Checked;
|
||
if (edtFechaAceptado.Enabled) then
|
||
begin
|
||
if (edtFechaAceptado.Date < FPresupuesto.FECHA_PRESUPUESTO) then
|
||
edtFechaAceptado.Date := DateOf(Now);
|
||
end;
|
||
|
||
edtFechaRechazado.Enabled := rbRechazado.Checked;
|
||
if (edtFechaRechazado.Enabled) then
|
||
begin
|
||
if (edtFechaRechazado.Date < FPresupuesto.FECHA_PRESUPUESTO) then
|
||
edtFechaRechazado.Date := DateOf(Now);
|
||
end;
|
||
end;
|
||
|
||
end.
|