Advertisement
X-88

Old Project

Dec 15th, 2019
233
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unit U1;
  2.  
  3. interface
  4.  
  5. uses
  6.    SysUtils, Forms, Windows,
  7.    Dialogs, DB, ExtCtrls, DBCtrls, Grids, DBGrids, DBClient, DBTables,
  8.    StdCtrls, Buttons, Classes, Controls;
  9. //------------------------------------------------------------------------------>
  10. type
  11.   TFZS = class(TForm)
  12.     DBG1: TDBGrid;
  13.     DBN1: TDBNavigator;
  14.     DS: TDataSource;
  15.     T1: TTable;
  16.     LB1: TListBox;
  17.     B1: TButton;
  18. //------------------------------------------------------------------------------>
  19.     procedure FormCreate(Sender: TObject);
  20.     procedure DBG1CellClick(Column: TColumn);
  21.     procedure DBN1Click(Sender: TObject; Button: TNavigateBtn);
  22.     procedure B1Click(Sender: TObject);
  23.   private
  24.     { By : Zephio }
  25.     procedure CF(Sender: TObject);
  26.   public
  27.     { DB Desktop, 2007 - 2011}
  28.   end;
  29.  
  30. const
  31.   DN = 'Zephio - [Belajar DB Desktop]';
  32.  
  33. var
  34.   FZS: TFZS;
  35.  
  36. implementation
  37.  
  38. {$R *.dfm}
  39. //------------------------------------------------------------------------------>
  40. procedure TFZS.CF(Sender: TObject);
  41. var
  42.    I : Integer;
  43. begin
  44.    LB1.Clear;
  45. for I := 0 to DBG1.FieldCount - 1 do
  46.    LB1.AddItem(IntToHex(I + 1, 2) +' - '+DBG1.Columns.Items[I].FieldName +' : ' + DBG1.Columns.Grid.Fields[I].Text, Self);
  47.    LB1.AddItem('Total Fields : '+IntToStr(DBG1.FieldCount), Self);
  48.    LB1.AddItem('Total Records : '+IntToStr(DS.DataSet.RecordCount), Self);
  49. end;
  50. //------------------------------------------------------------------------------>
  51. procedure TFZS.FormCreate(Sender: TObject);
  52. var
  53.    P : String;
  54. begin
  55.    FZS.Caption := DN;
  56.    Application.Title := DN;
  57.    P := ExtractFilePath(Application.ExeName)+'data.db';
  58. if not FileExists(P) then
  59. begin
  60.    MessageBox(handle, 'Data.db tidak ditemukan!!!...'+#13#10+'Applikasi Akan Ditutup!!!...', 'Info', 0);
  61.    Application.Terminate;
  62. end
  63. else
  64. begin
  65.    T1.TableName := ExtractFilename(P);
  66.    T1.Active := true;
  67.    DS.DataSet := T1;
  68.    DBG1.DataSource := DS;
  69.    DBN1.DataSource := DS;
  70. end;
  71.    CF(Self);
  72.    LB1.ItemIndex := 0;
  73. end;
  74. //------------------------------------------------------------------------------>
  75. procedure TFZS.DBG1CellClick(Column: TColumn);
  76. begin
  77.    CF(Self);
  78.    LB1.ItemIndex := DBG1.SelectedIndex;
  79. end;
  80.  
  81. procedure TFZS.DBN1Click(Sender: TObject; Button: TNavigateBtn);
  82. begin
  83. if (DBG1.FieldCount < 1) or
  84.    (button <> NBInsert) then
  85. begin
  86.    exit;
  87. end
  88. else
  89. begin
  90.    T1.Insert;
  91.    DBG1.Columns.Grid.Fields[0].Text := '#0'+IntToStr(DS.DataSet.RecordCount + 1);
  92.    DBG1.Columns.Grid.Fields[3].Text := DateToStr(Now);
  93.    DBG1.Columns.Grid.Fields[6].Text := 'Zephio';
  94.    T1.Post;
  95. end;
  96.    CF(Self);
  97. end;
  98. //------------------------------------------------------------------------------>
  99. procedure TFZS.B1Click(Sender: TObject);
  100. var
  101.    Sum : Integer;
  102. begin
  103. if DBG1.FieldCount < 1 then
  104.    exit
  105. else
  106.    Sum := 0;
  107.    DS.DataSet.First;
  108. while not DS.DataSet.Eof do
  109. begin
  110.    Sum := Sum + DS.DataSet.Fields[5].AsInteger;
  111.    DS.DataSet.Next;
  112. end;
  113.    MessageBox(handle, pChar('Total : '+IntToStr(Sum)), 'Info', 0);
  114. end;
  115.  
  116. end.
Advertisement
RAW Paste Data Copied
Advertisement