This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
LuisLeon_FactuGES/Modulos/Contactos/Views/uViewDireccionesEntrega.pas
2007-06-11 15:35:41 +00:00

127 lines
4.0 KiB
ObjectPascal
Raw Blame History

unit uViewDireccionesEntrega;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uViewBase, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxTextEdit, cxGridLevel,
cxGridCustomTableView, cxGridTableView, cxGridBandedTableView,
cxGridDBBandedTableView, cxClasses, cxControls, cxGridCustomView, cxGrid,
uDADataTable, Grids, DBGrids, ActnList, ImgList, PngImageList, ComCtrls,
ToolWin, cxGridDBTableView;
type
TfrViewDireccionesEntrega = class(TfrViewBase)
cxGrid: TcxGrid;
cxGridViewID: TcxGridDBColumn;
cxGridViewDIRECCION: TcxGridDBColumn;
cxGridViewPOBLACION: TcxGridDBColumn;
cxGridViewCP: TcxGridDBColumn;
cxGridViewPROVINCIA: TcxGridDBColumn;
cxGridViewPERSONA_CONTACTO: TcxGridDBColumn;
cxGridLevel: TcxGridLevel;
dsDirecciones: TDADataSource;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ContenidoImageList: TPngImageList;
ActionListContenido: TActionList;
actAnadir: TAction;
actEliminar: TAction;
cxGridView: TcxGridDBTableView;
procedure actAnadirExecute(Sender: TObject);
procedure actEliminarExecute(Sender: TObject);
procedure cxGridViewEditKeyDown(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
{$R *.dfm}
procedure TfrViewDireccionesEntrega.actAnadirExecute(Sender: TObject);
begin
cxGridView.BeginUpdate;
try
if cxGridView.Controller.EditingController.IsEditing then
cxGridView.Controller.EditingController.Edit.PostEditValue;
dsDirecciones.DataTable.Insert;
finally
cxGridView.EndUpdate;
end;
end;
procedure TfrViewDireccionesEntrega.actEliminarExecute(Sender: TObject);
var
AuxTop, AuxRow:Integer;
begin
cxGridView.BeginUpdate;
AuxTop := cxGridView.Controller.TopRowIndex;
AuxRow := cxGridView.DataController.FocusedRowIndex;
try
dsDirecciones.DataTable.Delete;
//Selecciona en el grid el registro siguiente
if (AuxRow < cxGridView.DataController.RowCount-1) then
Inc(AuxRow)
else
Dec(AuxRow);
if dsDirecciones.DataTable.RecordCount > 0 then
begin
cxGridView.DataController.SelectRows(AuxRow,AuxRow);
cxGridView.Controller.TopRowIndex := AuxTop;
end;
finally
cxGridView.EndUpdate;
end;
end;
procedure TfrViewDireccionesEntrega.cxGridViewEditKeyDown(
Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem;
AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState);
begin
inherited;
cxGridView.BeginUpdate;
try
Case Key of
VK_DOWN : begin
//En el caso de ser la <20>ltima fila hacemos un append nosotros no el grid
//ya que se saltaria la l<>gica del controllerDetallesBase
if cxGridView.Controller.IsFinish then
begin
Key := 0;
if Sender.Controller.EditingController.IsEditing then
Sender.Controller.EditingController.Edit.PostEditValue;
actAnadir.Execute;
end;
end;
VK_RETURN, VK_RIGHT
: begin
//En el caso de ser la <20>ltima fila hacemos un append nosotros no el grid
//ya que se saltaria la l<>gica del controllerDetallesBase
if cxGridView.Controller.IsFinish
and AItem.IsLast then
begin
Key := 0;
if Sender.Controller.EditingController.IsEditing then
Sender.Controller.EditingController.Edit.PostEditValue;
actAnadir.Execute;
end;
end;
end;
finally
cxGridView.EndUpdate;
end;
end;
end.