diff --git a/Source/Modulos/Pedidos a proveedor/Controller/uPedidosProveedorController.pas b/Source/Modulos/Pedidos a proveedor/Controller/uPedidosProveedorController.pas index 938bcf27..9cf68db5 100644 --- a/Source/Modulos/Pedidos a proveedor/Controller/uPedidosProveedorController.pas +++ b/Source/Modulos/Pedidos a proveedor/Controller/uPedidosProveedorController.pas @@ -53,6 +53,7 @@ type procedure EnviarPedidoPorEMail(APedido: IBizPedidoProveedor); Procedure AsignarIDObra(APedido: IBizPedidoProveedor; const IDObra: Variant); + Procedure AsignarIDAlmacen(APedido: IBizPedidoProveedor; const IDAlmacen: Variant); end; TPedidosProveedorController = class(TControllerBase, IPedidosProveedorController) @@ -119,7 +120,8 @@ type function ElegirPedidos(APedido: IBizPedidoProveedor; AMensaje: String; AMultiSelect: Boolean): IBizPedidoProveedor; procedure EnviarPedidoPorEMail(APedido: IBizPedidoProveedor); - Procedure AsignarIDObra(APedido: IBizPedidoProveedor; const IDObra: Variant); + Procedure AsignarIDObra(APedido: IBizPedidoProveedor; const IDObra: Variant); + Procedure AsignarIDAlmacen(APedido: IBizPedidoProveedor; const IDAlmacen: Variant); end; implementation @@ -131,7 +133,7 @@ uses schPedidosProveedorClient_Intf, uDAInterfaces, uPedidosProveedorReportController, uDateUtils, uIEditorPedidoProveedor, uIEditorElegirPedidosProveedor, Dialogs, uIEditorDireccionEntregaPedidoProveedor, Classes, uIEditorSituacionPedidoProveedor, - Variants, uSistemaFunc, uEMailUtils, uDialogElegirEMail, uIntegerListUtils; + Variants, uSistemaFunc, uEMailUtils, uDialogElegirEMail, uIntegerListUtils, uStringsUtils; { TPedidosProveedorController } @@ -145,6 +147,22 @@ begin FDataModule := TDataModulePedidosProveedor.Create(Nil); end; +procedure TPedidosProveedorController.AsignarIDAlmacen(APedido: IBizPedidoProveedor; const IDAlmacen: Variant); +begin + if Assigned(APedido) then + begin + if not APedido.DataTable.Editing then + APedido.DataTable.Edit; + + if EsCadenaVacia(IDAlmacen) then + APedido.ID_ALMACENIsNull := true + else + APedido.ID_ALMACEN := IDAlmacen; + + APedido.DataTable.Post; + end; +end; + procedure TPedidosProveedorController.AsignarIDObra(APedido: IBizPedidoProveedor; const IDObra: Variant); begin if Assigned(APedido) then @@ -152,7 +170,7 @@ begin if not APedido.DataTable.Editing then APedido.DataTable.Edit; - if VarIsNull(IDObra) then + if EsCadenaVacia(IDObra) then APedido.ID_OBRAIsNull := true else APedido.ID_OBRA := IDObra; diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.dfm b/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.dfm index b7b371cb..0a318033 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.dfm +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.dfm @@ -1,7 +1,6 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv Width = 484 Height = 240 - OnShow = CustomViewShow ExplicitWidth = 484 ExplicitHeight = 240 object dxLayoutControl1: TdxLayoutControl @@ -27,8 +26,10 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv object lblObra: TLabel Left = 247 Top = 37 - Width = 3 + Width = 15 Height = 13 + Align = alClient + Caption = ' ' end object rdxDestino1: TRadioButton Left = 10 @@ -41,11 +42,11 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv end object rdxDestino3: TRadioButton Left = 10 - Top = 67 + Top = 63 Width = 566 Height = 17 Action = actOtro - TabOrder = 4 + TabOrder = 3 end object cbListaAlmacenes: TcxDBLookupComboBox Left = 206 @@ -89,22 +90,22 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv Width = 128 Height = 25 Caption = 'Modificar la direcci'#243'n...' - TabOrder = 6 + TabOrder = 5 OnClick = bModificarClick end object txtDireccion: TStaticText Left = 25 - Top = 90 + Top = 86 Width = 882 Height = 47 AutoSize = False BevelKind = bkFlat - TabOrder = 5 + TabOrder = 4 OnDblClick = txtDireccionDblClick end object rdxDestino2: TRadioButton Left = 10 - Top = 39 + Top = 37 Width = 231 Height = 17 Action = actListaObras @@ -138,22 +139,9 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv StyleHot.LookAndFeel.Kind = lfStandard StyleHot.LookAndFeel.NativeStyle = True StyleHot.LookAndFeel.SkinName = '' - TabOrder = 7 + TabOrder = 6 Width = 334 end - object lblNombreObra: TcxDBLabel - Left = 256 - Top = 37 - DataBinding.DataField = 'NOMBRE_OBRA' - DataBinding.DataSource = dsPedido - Style.HotTrack = False - Style.LookAndFeel.SkinName = '' - StyleDisabled.LookAndFeel.SkinName = '' - StyleFocused.LookAndFeel.SkinName = '' - StyleHot.LookAndFeel.SkinName = '' - Height = 21 - Width = 121 - end object dxLayoutGroup1: TdxLayoutGroup ShowCaption = False Hidden = True @@ -206,14 +194,6 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv ControlOptions.AutoColor = True ControlOptions.ShowBorder = False end - object dxLayoutControl1Item9: TdxLayoutItem - AutoAligns = [] - AlignHorz = ahClient - AlignVert = avCenter - ShowCaption = False - Control = lblNombreObra - ControlOptions.ShowBorder = False - end end end object dxLayoutControl1Item2: TdxLayoutItem @@ -280,7 +260,6 @@ inherited frViewDireccionEntregaPedidoProv: TfrViewDireccionEntregaPedidoProv end end object dsPedido: TDADataSource - OnDataChange = dsPedidoDataChange Left = 352 Top = 8 end diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.pas b/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.pas index 1844635e..873f73e3 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.pas +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewDireccionEntregaPedidoProv.pas @@ -48,21 +48,17 @@ type dxLayoutControl1Group1: TdxLayoutGroup; dxLayoutControl1Group2: TdxLayoutGroup; dxLayoutControl1Group3: TdxLayoutGroup; - lblNombreObra: TcxDBLabel; - dxLayoutControl1Item9: TdxLayoutItem; lblObra: TLabel; dxLayoutControl1Item6: TdxLayoutItem; - procedure actListaAlmacenesExecute(Sender: TObject); - procedure actOtroExecute(Sender: TObject); + procedure cbListaAlmacenesPropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure bModificarClick(Sender: TObject); procedure txtDireccionDblClick(Sender: TObject); + + procedure edtEntregarAPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer); + procedure actListaAlmacenesExecute(Sender: TObject); + procedure actOtroExecute(Sender: TObject); procedure actListaObrasExecute(Sender: TObject); - procedure edtEntregarAPropertiesButtonClick(Sender: TObject; - AButtonIndex: Integer); - procedure dsPedidoDataChange(Sender: TObject; Field: TField); - procedure OnObraReservaEditValueChanged(Sender: TObject); - procedure CustomViewShow(Sender: TObject); protected FAlmacenesController : IAlmacenesController; @@ -81,7 +77,6 @@ type property PedidoProveedor: IBizPedidoProveedor read GetPedidoProveedor write SetPedidoProveedor; constructor Create(AOwner: TComponent); override; destructor Destroy; override; - procedure PrepararObra; procedure RecuperarObra; procedure CambioDireccionObra; end; @@ -93,18 +88,19 @@ implementation uses uEditorRegistryUtils, uCustomView, uEditorElegirPersonaContactoPedido, uBizInventario; -procedure TfrViewDireccionEntregaPedidoProv.actListaAlmacenesExecute(Sender: TObject); +procedure TfrViewDireccionEntregaPedidoProv.actListaAlmacenesExecute( + Sender: TObject); begin actListaAlmacenes.Checked := True; RefrescarControles; end; -procedure TfrViewDireccionEntregaPedidoProv.actListaObrasExecute( - Sender: TObject); +procedure TfrViewDireccionEntregaPedidoProv.actListaObrasExecute(Sender: TObject); begin actListaObras.Checked := True; - RefrescarControles; + RecuperarObra; CambioDireccionObra; + FController.AsignarIDAlmacen(FPedido, FPedido.ID_OBRA); end; procedure TfrViewDireccionEntregaPedidoProv.actOtroExecute(Sender: TObject); @@ -114,12 +110,7 @@ begin if Assigned(FPedido) then begin FController.VerDireccionEntrega(FPedido); - - if (FPedido.ID_ALMACEN > 0) then - begin - FPedido.Edit; - FPedido.ID_ALMACEN := 0; - end; + FController.AsignarIDAlmacen(FPedido, Null); end; RefrescarControles; end; @@ -163,7 +154,7 @@ procedure TfrViewDireccionEntregaPedidoProv.cbListaAlmacenesPropertiesValidate( var Error: Boolean); begin if Assigned(FPedido) and Assigned(FAlmacenes) and (FPedido.ID_ALMACEN <> FAlmacenes.ID) then - CambioDireccionAlmacen; + CambioDireccionAlmacen; end; constructor TfrViewDireccionEntregaPedidoProv.Create(AOwner: TComponent); @@ -179,17 +170,8 @@ begin FObra := NIL; end; -procedure TfrViewDireccionEntregaPedidoProv.CustomViewShow(Sender: TObject); -begin - inherited; -// lblNombreObra.Properties.OnEditValueChanged := OnObraReservaEditValueChanged; -end; - destructor TfrViewDireccionEntregaPedidoProv.Destroy; begin -// lblNombreObra.Properties.OnEditValueChanged := Nil; - - //cbListaObras.Properties.OnValidate := Nil; cbListaAlmacenes.Properties.OnValidate := Nil; FAlmacenesController := Nil; @@ -202,25 +184,6 @@ begin inherited; end; -procedure TfrViewDireccionEntregaPedidoProv.dsPedidoDataChange(Sender: TObject; - Field: TField); -begin - inherited; - - if Assigned(Field) and (Field.FieldName = 'ID_OBRA') then - begin - PrepararObra; - if actListaObras.Enabled then - begin - if not Assigned(FObra) then - RecuperarObra; - CambioDireccionObra - end - else - FObra := NIL; - end; -end; - procedure TfrViewDireccionEntregaPedidoProv.edtEntregarAPropertiesButtonClick( Sender: TObject; AButtonIndex: Integer); var @@ -254,12 +217,6 @@ begin Result := FPedido; end; -procedure TfrViewDireccionEntregaPedidoProv.OnObraReservaEditValueChanged( - Sender: TObject); -begin -// showmessage('hola'); -end; - procedure TfrViewDireccionEntregaPedidoProv.RecuperarObra; begin if Assigned(FObra) and (FObra.ID = FPedido.ID_OBRA) then @@ -278,7 +235,6 @@ begin begin cbListaAlmacenes.Enabled := False; cbListaAlmacenes.Text := ''; - txtDireccion.Enabled := True; txtDireccion.Caption := FPedido.CALLE; txtDireccion.Caption := txtDireccion.Caption + #13#10 + FPedido.CODIGO_POSTAL + ' ' + FPedido.POBLACION; @@ -287,36 +243,20 @@ begin end else if (actListaAlmacenes.Checked) then begin - txtDireccion.Enabled := False; - cbListaAlmacenes.Enabled := True; cbListaAlmacenes.DroppedDown := True; + txtDireccion.Enabled := False; bModificar.Enabled := False; end else begin - bModificar.Enabled := False; - - txtDireccion.Enabled := False; cbListaAlmacenes.Enabled := False; cbListaAlmacenes.Text := ''; + bModificar.Enabled := False; + txtDireccion.Enabled := False; end; end; end; -procedure TfrViewDireccionEntregaPedidoProv.PrepararObra; -begin - if Assigned(FPedido) and FPedido.Active then - if FPedido.ID_OBRAIsNull then - begin - actListaObras.Enabled := False; - - if actListaObras.Checked then - actListaAlmacenes.Execute; - end - else - actListaObras.Enabled := True; -end; - procedure TfrViewDireccionEntregaPedidoProv.SetPedidoProveedor( const Value: IBizPedidoProveedor); begin @@ -340,7 +280,6 @@ begin else actOtro.Checked := True; end; - PrepararObra; RefrescarControles; end; diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.dfm b/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.dfm index 23bcc4e0..099d5f72 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.dfm +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.dfm @@ -75,7 +75,6 @@ inherited frViewObraReserva: TfrViewObraReserva Properties.DropDownListStyle = lsEditFixedList Properties.DropDownRows = 25 Properties.ImmediatePost = True - Properties.OnEditValueChanged = cbObraReservaPropertiesEditValueChanged Style.BorderColor = clWindowFrame Style.BorderStyle = ebs3D Style.HotTrack = False diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.pas b/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.pas index e009b55e..635d8ec0 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.pas +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewObraReserva.pas @@ -3,7 +3,7 @@ unit uViewObraReserva; interface uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, uViewBase, uBizPedidosProveedor, cxGraphics, dxLayoutControl, cxMemo, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, StdCtrls, cxControls, DB, uDADataTable, @@ -32,7 +32,6 @@ type procedure actVerObraExecute(Sender: TObject); procedure actVerObraUpdate(Sender: TObject); procedure CustomViewShow(Sender: TObject); - procedure cbObraReservaPropertiesEditValueChanged(Sender: TObject); private FObras : TStringList; FObrasController: IObrasController; @@ -50,24 +49,24 @@ type property ObrasController: IObrasController read GetObrasController write SetObrasController; destructor Destroy; override; procedure ActivarObra(const IDObra:Integer); - function DarIDObraSeleccionada: Variant; + function DarIDObraSeleccionada: String; end; implementation - {$R *.dfm} uses - uEditorRegistryUtils, uCustomView, uEditorElegirPersonaContactoPedido, + Variants, uEditorRegistryUtils, uCustomView, uEditorElegirPersonaContactoPedido, uStringsUtils; procedure TfrViewObraReserva.actVerObraExecute(Sender: TObject); var AObra : IBizObra; - AID : Integer; + AID : Variant; begin inherited; - AObra := FObrasController.Buscar(DarIDObraSeleccionada); + AID := DarIDObraSeleccionada; + AObra := FObrasController.Buscar(AID); if Assigned(AObra) then try FObrasController.Ver(AObra); @@ -91,27 +90,19 @@ begin begin if IntToStr(IDObra) = FObras.Values[FObras.Names[i]] then begin - cbObraReserva.ItemIndex := i + 1; + cbObraReserva.ItemIndex := i; Exit; end; end; end; -procedure TfrViewObraReserva.cbObraReservaPropertiesEditValueChanged( - Sender: TObject); -begin - inherited; -showmessage('hola'); -// SalvarObra; -end; - procedure TfrViewObraReserva.CustomViewShow(Sender: TObject); begin inherited; cbObraReserva.Enabled := not Self.ReadOnly; end; -function TfrViewObraReserva.DarIDObraSeleccionada: Variant; +function TfrViewObraReserva.DarIDObraSeleccionada: String; begin if Assigned(FObras) then Result := FObras.Values[cbObraReserva.EditValue] diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.dfm b/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.dfm index 161bca80..9b09eec0 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.dfm +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.dfm @@ -202,14 +202,6 @@ inherited frViewPedidoProveedor: TfrViewPedidoProveedor StyleHot.LookAndFeel.SkinName = '' ExplicitTop = 231 end - inherited lblNombreObra: TcxDBLabel - Left = 248 - Style.LookAndFeel.SkinName = '' - StyleDisabled.LookAndFeel.SkinName = '' - StyleFocused.LookAndFeel.SkinName = '' - StyleHot.LookAndFeel.SkinName = '' - ExplicitLeft = 248 - end end inherited ActionList1: TActionList Left = 72 @@ -447,16 +439,21 @@ inherited frViewPedidoProveedor: TfrViewPedidoProveedor Height = 72 ExplicitWidth = 432 ExplicitHeight = 72 + inherited Label1: TLabel + Width = 202 + ExplicitWidth = 202 + end inherited Button3: TBitBtn Left = 278 ExplicitLeft = 278 end inherited cbObraReserva: TcxComboBox - Properties.OnEditValueChanged = nil Style.LookAndFeel.SkinName = '' StyleDisabled.LookAndFeel.SkinName = '' StyleFocused.LookAndFeel.SkinName = '' StyleHot.LookAndFeel.SkinName = '' + ExplicitWidth = 581 + Width = 581 end end inherited PngImageList: TPngImageList diff --git a/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.pas b/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.pas index f79acf0b..a85deb4c 100644 --- a/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.pas +++ b/Source/Modulos/Pedidos a proveedor/Views/uViewPedidoProveedor.pas @@ -101,7 +101,6 @@ type procedure SetPedido(const Value: IBizPedidoProveedor); virtual; function GetController : IPedidosProveedorController; procedure SetController (const Value : IPedidosProveedorController); - function GetViewProveedorPedido: TfrViewDatosYSeleccionProveedor; procedure SetViewProveedorPedido(const Value: TfrViewDatosYSeleccionProveedor); @@ -112,10 +111,11 @@ type end; implementation - - {$R *.dfm} +uses uStringsUtils; + + { TfrViewPedidoProveedor } procedure TfrViewPedidoProveedor.actVerPedidoCliExecute(Sender: TObject); @@ -167,41 +167,36 @@ procedure TfrViewPedidoProveedor.CustomViewShow(Sender: TObject); begin inherited; if not FPedido.ID_OBRAISNull then + begin frViewObraReserva1.ActivarObra(FPedido.ID_OBRA); + frViewDireccionEntregaPedidoProv1.lblObra.Caption := FPedido.NOMBRE_OBRA; + end; frViewObraReserva1.cbObraReserva.Properties.OnEditValueChanged := ObraReservaEditValueChanged; end; procedure TfrViewPedidoProveedor.ObraReservaEditValueChanged(Sender: TObject); var - IDObra: Variant; + IDObra: String; begin inherited; + IDObra := frViewObraReserva1.DarIDObraSeleccionada; Controller.AsignarIDObra(FPedido, IDObra); - if not VarIsNull(IDObra) then + if EsCadenaVacia(IDObra) then begin - frViewDireccionEntregaPedidoProv1.rdxDestino2.Checked := True; - frViewDireccionEntregaPedidoProv1.RecuperarObra; - frViewDireccionEntregaPedidoProv1.CambioDireccionObra; + frViewDireccionEntregaPedidoProv1.actListaObras.Enabled := False; + frViewDireccionEntregaPedidoProv1.lblObra.Caption := frViewObraReserva1.cbObraReserva.Text; + frViewDireccionEntregaPedidoProv1.actListaAlmacenes.Execute end else begin - + frViewDireccionEntregaPedidoProv1.actListaObras.Enabled := true; + frViewDireccionEntregaPedidoProv1.actListaObras.Execute; + frViewDireccionEntregaPedidoProv1.lblObra.Caption := frViewObraReserva1.cbObraReserva.Text; end; - - - showmessage('Cambio a radio buton de entraga de obra'); - showmessage('cargo direccion de la obnra'); - -{showmessage('hola2'); - frViewDireccionEntregaPedidoProv1.PrepararObra; - frViewDireccionEntregaPedidoProv1.RecuperarObra; - frViewDireccionEntregaPedidoProv1.CambioDireccionObra; - frViewDireccionEntregaPedidoProv1.rdxDestino2.Checked := true; -} end; procedure TfrViewPedidoProveedor.frViewProveedorPedidoButton1Click(Sender: TObject);