vladman
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору dfm Код: object Form10: TForm10 Left = 0 Top = 0 Caption = 'Form10' ClientHeight = 292 ClientWidth = 490 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object cxGrid1: TcxGrid Left = 32 Top = 16 Width = 393 Height = 225 TabOrder = 0 object cxGrid1DBTableView1: TcxGridDBTableView NavigatorButtons.ConfirmDelete = False OnInitEditValue = cxGrid1DBTableView1InitEditValue DataController.DataSource = DataSource1 DataController.Summary.DefaultGroupSummaryItems = <> DataController.Summary.FooterSummaryItems = <> DataController.Summary.SummaryGroups = <> object cxGrid1DBTableView1RecId: TcxGridDBColumn DataBinding.FieldName = 'RecId' Visible = False end object cxGrid1DBTableView1Filed1: TcxGridDBColumn DataBinding.FieldName = 'Filed1' OnGetDataText = cxGrid1DBTableView1Filed1GetDataText Width = 171 end object cxGrid1DBTableView1aaa: TcxGridDBColumn DataBinding.FieldName = 'aaa' end end object cxGrid1Level1: TcxGridLevel GridView = cxGrid1DBTableView1 end end object cxDBNavigator1: TcxDBNavigator Left = 200 Top = 247 Width = 225 Height = 25 DataSource = DataSource1 TabOrder = 1 end object cxButton1: TcxButton Left = 16 Top = 256 Width = 75 Height = 25 Caption = 'cxButton1' TabOrder = 2 OnClick = cxButton1Click end object dxMemData1: TdxMemData Active = True Indexes = <> Persistent.Data = { 5665728FC2F5285C8FFE3F020000001E0000000100070046696C656431002100 00000100040061616100} SortOptions = [] BeforePost = dxMemData1BeforePost Left = 440 Top = 24 object dxMemData1Filed1: TStringField DisplayWidth = 30 FieldName = 'Filed1' Size = 30 end object dxMemData1aaa: TStringField FieldName = 'aaa' Size = 33 end end object DataSource1: TDataSource DataSet = dxMemData1 Left = 440 Top = 56 end end | pas Код: unit Unit10; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters, cxStyles, dxSkinsCore, dxSkinMcSkin, dxSkinsDefaultPainters, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxGridCustomView, cxGrid, dxmdaset, cxNavigator, cxDBNavigator, Menus, StdCtrls, cxButtons, cxContainer, cxTextEdit; type TForm10 = class(TForm) dxMemData1: TdxMemData; dxMemData1Filed1: TStringField; DataSource1: TDataSource; cxGrid1DBTableView1: TcxGridDBTableView; cxGrid1Level1: TcxGridLevel; cxGrid1: TcxGrid; cxGrid1DBTableView1RecId: TcxGridDBColumn; cxGrid1DBTableView1Filed1: TcxGridDBColumn; cxDBNavigator1: TcxDBNavigator; cxButton1: TcxButton; dxMemData1aaa: TStringField; cxGrid1DBTableView1aaa: TcxGridDBColumn; procedure FormCreate(Sender: TObject); procedure cxButton1Click(Sender: TObject); procedure cxGrid1DBTableView1Filed1GetDataText(Sender: TcxCustomGridTableItem; ARecordIndex: Integer; var AText: string); procedure cxGrid1DBTableView1InitEditValue(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var AValue: Variant); procedure dxMemData1BeforePost(DataSet: TDataSet); private FInit: Boolean; { Private declarations } public { Public declarations } end; var Form10: TForm10; implementation {$R *.dfm} //**************************************************************************************** // Delphi 3000 . com // Here are the functions that demonstrate routines for encryption and decryption strings. const C1 = 52845; C2 = 22719; function Encrypt(const S: String; Key: Word): String; var I: byte; begin SetLength(Result, Length(S)); for I := 1 to Length(S) do begin Result[I] := char(byte(S[I]) xor (Key shr 8)); Key := (byte(Result[I]) + Key) * C1 + C2; end; end; function Decrypt(const S: String; Key: Word): String; var I: byte; begin SetLength(Result, Length(S)); for I := 1 to Length(S) do begin Result[I] := char(byte(S[I]) xor (Key shr 8)); Key := (byte(S[I]) + Key) * C1 + C2; end; end; // Delphi 3000 . com // Here are the functions that demonstrate routines for encryption and decryption strings. //**************************************************************************************** procedure TForm10.FormCreate(Sender: TObject); begin FInit := True; try dxMemData1.LoadFromTextFile('d:\1-Text.txt'); finally FInit := False; end; end; procedure TForm10.cxButton1Click(Sender: TObject); begin dxMemData1.SaveToTextFile('d:\1-Text.txt'); dxMemData1.SaveToBinaryFile('d:\1-Bunary.txt'); end; procedure TForm10.cxGrid1DBTableView1Filed1GetDataText(Sender: TcxCustomGridTableItem; ARecordIndex: Integer; var AText: string); begin if (cxGrid1DBTableView1.DataController.DataSource.DataSet.State in [dsInsert, dsEdit]) and (Sender.GridView.DataController.FocusedRecordIndex = ARecordIndex) then Exit; AText := Decrypt(AText, 123); end; procedure TForm10.cxGrid1DBTableView1InitEditValue(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit; var AValue: Variant); begin if AItem = cxGrid1DBTableView1Filed1 then AValue := Decrypt(VarToStr(AValue), 123); end; procedure TForm10.dxMemData1BeforePost(DataSet: TDataSet); begin if FInit then Exit; if DataSet.FieldByName('Filed1').OldValue <> DataSet['Filed1'] then DataSet['Filed1'] := Encrypt(DataSet['Filed1'], 123); end; end. | | Всего записей: 708 | Зарегистр. 13-11-2002 | Отправлено: 02:52 19-02-2010 | Исправлено: vladman, 03:31 19-02-2010 |
|