diff --git a/Source/Base/Utiles/uDataTableUtils.pas b/Source/Base/Utiles/uDataTableUtils.pas index 294300e0..95a98dd3 100644 --- a/Source/Base/Utiles/uDataTableUtils.pas +++ b/Source/Base/Utiles/uDataTableUtils.pas @@ -347,7 +347,7 @@ begin end; -procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable; Const WithPKKey: Boolean = False; Const WithFKKey: Boolean = False); +procedure DuplicarRegistro(ASource : TDADataTable; ATarget : TDADataTable; const WithPKKey: Boolean = False; const WithFKKey: Boolean = False); var i, j: Integer; ATargetField: TDAField; diff --git a/Source/GUIBase/uViewDetallesBase.dfm b/Source/GUIBase/uViewDetallesBase.dfm index 5ae149af..9eee3243 100644 --- a/Source/GUIBase/uViewDetallesBase.dfm +++ b/Source/GUIBase/uViewDetallesBase.dfm @@ -10,7 +10,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase Left = 0 Top = 0 Width = 451 - Height = 68 + Height = 73 AutoSize = True ButtonWidth = 141 Caption = 'ToolBar1' @@ -42,24 +42,23 @@ inherited frViewDetallesBase: TfrViewDetallesBase Top = 0 Action = actSubir AutoSize = True - Wrap = True end object ToolButton4: TToolButton - Left = 0 - Top = 22 + Left = 184 + Top = 0 Action = actBajar AutoSize = True end object ToolButton14: TToolButton - Left = 56 - Top = 22 + Left = 240 + Top = 0 Action = FontEdit1 AutoSize = True Wrap = True end object FontName: TJvFontComboBox Left = 0 - Top = 44 + Top = 22 Width = 145 Height = 22 DroppedDownWidth = 145 @@ -75,7 +74,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase end object FontSize: TEdit Left = 145 - Top = 44 + Top = 22 Width = 26 Height = 22 Hint = 'Font Size|Select font size' @@ -86,7 +85,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase end object UpDown1: TUpDown Left = 171 - Top = 44 + Top = 22 Width = 16 Height = 22 Associate = FontSize @@ -95,7 +94,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase end object ToolButton13: TToolButton Left = 187 - Top = 44 + Top = 22 Width = 8 Caption = 'ToolButton13' ImageIndex = 10 @@ -103,54 +102,55 @@ inherited frViewDetallesBase: TfrViewDetallesBase end object ToolButton6: TToolButton Left = 195 - Top = 44 + Top = 22 Action = RichEditBold1 AutoSize = True end object ToolButton7: TToolButton Left = 261 - Top = 44 + Top = 22 Action = RichEditItalic1 AutoSize = True end object ToolButton8: TToolButton Left = 328 - Top = 44 + Top = 22 Action = RichEditUnderline1 AutoSize = True end object ToolButton12: TToolButton - Left = 411 - Top = 44 + Left = 0 + Top = 22 Width = 8 Caption = 'ToolButton12' ImageIndex = 10 + Wrap = True Style = tbsSeparator end object ToolButton9: TToolButton - Left = 419 - Top = 44 + Left = 0 + Top = 49 Action = RichEditAlignLeft1 AutoSize = True end object ToolButton10: TToolButton - Left = 564 - Top = 44 + Left = 145 + Top = 49 Action = RichEditAlignCenter1 AutoSize = True end object ToolButton11: TToolButton - Left = 689 - Top = 44 + Left = 270 + Top = 49 Action = RichEditAlignRight1 AutoSize = True end end object cxGrid: TcxGrid Left = 0 - Top = 94 + Top = 99 Width = 451 - Height = 210 + Height = 205 Align = alClient Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -161,14 +161,14 @@ inherited frViewDetallesBase: TfrViewDetallesBase TabOrder = 1 LookAndFeel.Kind = lfStandard LookAndFeel.NativeStyle = True - ExplicitTop = 99 - ExplicitHeight = 205 object cxGridView: TcxGridDBTableView NavigatorButtons.ConfirmDelete = False FilterBox.Visible = fvNever OnEditing = cxGridViewEditing OnEditKeyDown = cxGridViewEditKeyDown OnEditValueChanged = cxGridViewEditValueChanged + OnFocusedItemChanged = cxGridViewFocusedItemChanged + OnFocusedRecordChanged = cxGridViewFocusedRecordChanged OnInitEdit = cxGridViewInitEdit DataController.DataSource = DADataSource DataController.Filter.Options = [fcoCaseInsensitive] @@ -337,12 +337,11 @@ inherited frViewDetallesBase: TfrViewDetallesBase end object TBXDock1: TTBXDock Left = 0 - Top = 68 + Top = 73 Width = 451 Height = 26 BackgroundOnToolbars = False UseParentBackground = True - ExplicitTop = 73 object TBXToolbar1: TTBXToolbar Left = 0 Top = 0 diff --git a/Source/GUIBase/uViewDetallesBase.pas b/Source/GUIBase/uViewDetallesBase.pas index 924cd3ae..f6ae04f3 100644 --- a/Source/GUIBase/uViewDetallesBase.pas +++ b/Source/GUIBase/uViewDetallesBase.pas @@ -192,6 +192,11 @@ type procedure actDetallesPegarUpdate(Sender: TObject); procedure actDetallesCortarExecute(Sender: TObject); procedure actDetallesCortarUpdate(Sender: TObject); + procedure cxGridViewFocusedItemChanged(Sender: TcxCustomGridTableView; + APrevFocusedItem, AFocusedItem: TcxCustomGridTableItem); + procedure cxGridViewFocusedRecordChanged(Sender: TcxCustomGridTableView; + APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; + ANewItemRecordFocusingChanged: Boolean); private FController : IControllerDetallesBase; FDetalles: IDAStronglyTypedDataTable; @@ -242,6 +247,10 @@ implementation uses uDMBase, uCalculosUtils, dxOffice11, uSistemaFunc, uGridClipboardUtils; +var + _FRecalculando : Boolean; + _FRecalcular : Boolean; + function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric; FontType: Integer; Data: Pointer): Integer; stdcall; begin @@ -588,17 +597,46 @@ end; procedure TfrViewDetallesBase.cxGridViewEditValueChanged(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem); begin inherited; - cxGridView.BeginUpdate; - try - if HayQueRecalcular(AItem) then - begin - if Sender.Controller.EditingController.IsEditing then - Sender.Controller.EditingController.Edit.PostEditValue; + if not _FRecalcular and HayQueRecalcular(AItem) then + _FRecalcular := True; +end; - Controller.ActualizarTotales(Detalles); +procedure TfrViewDetallesBase.cxGridViewFocusedItemChanged( + Sender: TcxCustomGridTableView; APrevFocusedItem, + AFocusedItem: TcxCustomGridTableItem); +begin + inherited; + if _FRecalcular and not _FRecalculando then //and HayQueRecalcular(APrevFocusedItem) then + begin + _FRecalculando := True; + try + if Sender.Controller.EditingController.IsEditing then + Sender.Controller.EditingController.Edit.PostEditValue; + Controller.ActualizarTotales(Detalles); + _FRecalcular := False; + finally + _FRecalculando := False; + end; + end; +end; + +procedure TfrViewDetallesBase.cxGridViewFocusedRecordChanged( + Sender: TcxCustomGridTableView; APrevFocusedRecord, + AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean); +begin + inherited; + + if _FRecalcular and not _FRecalculando then //and HayQueRecalcular(cxGridView.Controller.FocusedItem) then + begin + _FRecalculando := True; + try + if Sender.Controller.EditingController.IsEditing then + Sender.Controller.EditingController.Edit.PostEditValue; + Controller.ActualizarTotales(Detalles); + _FRecalcular := False; + finally + _FRecalculando := False; end; - finally - cxGridView.EndUpdate; end; end; @@ -1079,4 +1117,8 @@ begin end; end; +initialization + _FRecalculando := False; + _FRecalcular := False; + end. diff --git a/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.dfm b/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.dfm index 893d0208..42f00698 100644 --- a/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.dfm +++ b/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.dfm @@ -1,80 +1,101 @@ inherited frViewDetallesArticulosParaVenta: TfrViewDetallesArticulosParaVenta inherited ToolBar1: TToolBar - Height = 73 - ExplicitHeight = 73 - inherited ToolButton3: TToolButton - Wrap = False - end - inherited ToolButton4: TToolButton - Left = 278 - Top = 0 - ExplicitLeft = 278 - ExplicitTop = 0 - end - inherited ToolButton14: TToolButton - Left = 334 - Top = 0 - ExplicitLeft = 334 - ExplicitTop = 0 - end - inherited FontName: TJvFontComboBox - Top = 22 - ExplicitTop = 22 - end - inherited FontSize: TEdit - Top = 22 - ExplicitTop = 22 - end - inherited UpDown1: TUpDown - Top = 22 - ExplicitTop = 22 - end - inherited ToolButton13: TToolButton - Top = 22 - ExplicitTop = 22 - end - inherited ToolButton6: TToolButton - Top = 22 - ExplicitTop = 22 - end - inherited ToolButton7: TToolButton - Top = 22 - ExplicitTop = 22 - end - inherited ToolButton8: TToolButton - Top = 22 - ExplicitTop = 22 - end - inherited ToolButton12: TToolButton + Height = 95 + ExplicitHeight = 95 + inherited ToolButton14: TToolButton [1] Left = 0 Top = 22 + Wrap = False + ExplicitLeft = 0 + ExplicitTop = 22 + end + inherited ToolButton12: TToolButton [2] + Left = 65 + Wrap = False + ExplicitLeft = 65 + ExplicitHeight = 22 + end + inherited ToolButton13: TToolButton [3] + Left = 0 Wrap = True ExplicitLeft = 0 - ExplicitTop = 22 ExplicitHeight = 27 end - inherited ToolButton9: TToolButton + inherited ToolButton2: TToolButton [4] Left = 0 Top = 49 ExplicitLeft = 0 ExplicitTop = 49 end - inherited ToolButton10: TToolButton - Left = 145 + inherited ToolButton3: TToolButton [5] + Left = 114 Top = 49 - ExplicitLeft = 145 + ExplicitLeft = 114 ExplicitTop = 49 end - inherited ToolButton11: TToolButton - Left = 270 + inherited ToolButton4: TToolButton [6] + Left = 169 Top = 49 - ExplicitLeft = 270 + ExplicitLeft = 169 ExplicitTop = 49 end + inherited ToolButton7: TToolButton [7] + Left = 225 + Top = 49 + ExplicitLeft = 225 + ExplicitTop = 49 + end + inherited FontName: TJvFontComboBox [8] + Left = 292 + Top = 49 + ExplicitLeft = 292 + ExplicitTop = 49 + end + inherited ToolButton9: TToolButton [9] + Left = 437 + ExplicitLeft = 437 + end + inherited ToolButton8: TToolButton [10] + Left = 582 + Top = 49 + Wrap = True + ExplicitLeft = 582 + ExplicitTop = 49 + end + inherited FontSize: TEdit [11] + Left = 0 + Top = 71 + ExplicitLeft = 0 + ExplicitTop = 71 + end + inherited UpDown1: TUpDown [12] + Left = 42 + Top = 71 + ExplicitLeft = 42 + ExplicitTop = 71 + end + inherited ToolButton6: TToolButton [13] + Left = 59 + Top = 71 + ExplicitLeft = 59 + ExplicitTop = 71 + end + inherited ToolButton10: TToolButton + Left = 125 + Top = 71 + ExplicitLeft = 125 + ExplicitTop = 71 + end + inherited ToolButton11: TToolButton + Left = 250 + Top = 71 + ExplicitLeft = 250 + ExplicitTop = 71 + end end inherited cxGrid: TcxGrid - Top = 99 - Height = 205 + Top = 121 + Height = 183 inherited cxGridView: TcxGridDBTableView inherited cxGridViewREFERENCIA_PROVEEDOR: TcxGridDBColumn Visible = False @@ -87,7 +108,6 @@ inherited frViewDetallesArticulosParaVenta: TfrViewDetallesArticulosParaVenta end end inherited TBXDock1: TTBXDock - Top = 73 - ExplicitTop = 73 + Top = 95 end end diff --git a/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.pas b/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.pas index 0faf4111..67329fc5 100644 --- a/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.pas +++ b/Source/Modulos/Articulos/Views/uViewDetallesArticulosParaVenta.pas @@ -20,7 +20,6 @@ type var AProperties: TcxCustomEditProperties); procedure CustomViewDestroy(Sender: TObject); procedure CustomViewShow(Sender: TObject); - procedure OnIMPORTEUNIDADPropertiesEditValueChanged(Sender: TObject); private { Private declarations } @@ -38,7 +37,6 @@ uses uControllerDetallesArticulos; procedure TfrViewDetallesArticulosParaVenta.CustomViewDestroy(Sender: TObject); begin inherited; - cxGridViewIMPORTEUNIDAD.Properties.OnEditValueChanged := Nil; cxGridViewIMPORTEUNIDAD.OnGetPropertiesForEdit := Nil; end; @@ -50,33 +48,13 @@ begin begin cxGridView.BeginUpdate; try - cxGridViewIMPORTEUNIDAD.OnGetPropertiesForEdit := OnIMPORTEUNIDADGetProperties; + cxGridViewIMPORTEUNIDAD.OnGetPropertiesForEdit := OnIMPORTEUNIDADGetProperties; finally cxGridView.EndUpdate; end; end; end; -procedure TfrViewDetallesArticulosParaVenta.OnIMPORTEUNIDADPropertiesEditValueChanged( - Sender: TObject); -begin - inherited; - cxGridView.BeginUpdate; - try -// if HayQueRecalcular(AItem) then -// begin - - if _FocusedView.Controller.EditingController.IsEditing then - _FocusedView.Controller.EditingController.Edit.PostEditValue; - - Controller.ActualizarTotales(Detalles); -// end; - finally - cxGridView.EndUpdate; - end; - -end; - procedure TfrViewDetallesArticulosParaVenta.OnIMPORTEUNIDADGetProperties( Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord; var AProperties: TcxCustomEditProperties); @@ -104,11 +82,10 @@ begin end; end; AProperties := cxEditRepositoryComboBox_IMPORTEUNIDAD.Properties; - AProperties.OnEditValueChanged := OnIMPORTEUNIDADPropertiesEditValueChanged; end else begin AProperties := cxEditRepositoryCurrencyItem_IMPORTEUNIDAD.Properties; - AProperties.OnEditValueChanged := OnIMPORTEUNIDADPropertiesEditValueChanged; + end; end; end;