RSS
email
0

View MySql


Views

VIEW is a virtual table, which acts like a table but actually it contains no data. That is based on the result set of a SELECT statement. A VIEW consists rows and columns from one or more than one tables. A VIEW is a query that’s stored as an object. A VIEW is nothing more than a way to select a subset of table’s columns.
When you defined a view then you can reference it like any other table in a database. A VIEW provides as a security mechanism also. VIEWS ensures that users are able to modify and retrieve only that data which seen by them. 

By using Views you can ensure about the security of data by restricting access to the following data:
  • Specific columns of the tables. 
    Specific rows of the tables. 
  • Specific rows and columns of the tables. 

  • Subsets of another view or a subset of views and tables
  • Rows fetched by using joins. 
  • Statistical summary of data in a given tables. 


CREATE VIEW Statement
     
CREATE VIEW Statement is used to create a new database view. The general syntax of CREATE VIEW Statement is:
        CREATE VIEW view_name [(column_list)] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION]
View_name specifies the name for the new view. column_list specifies the name of the columns to be used in view. column_list must have the same number of columns that specified in select_statement. If column_list option is not available then view is created with the same columns that specified in select_statement.
WITH ENCRYPTION option encrypts the text to the view in the syscomments table.
AS option specifies the action that is performed by the view. select_statement is used to specify the SELECT statement that defines a view. The optional WITH CHECK OPTION clause applies to the data modification statement like INSERT and UPDATE statements to fulfill the criteria given in the select_statement defining the view. This option also ensures that the data can visible after the modifications are made permanent.
Some restrictions imposed on views are given below :
  • A view can be created only in the current database. 
    The view name must follow the rules for identifiers and 

  • The view name must not be the same as that of the base table
  • A view can be created only that time if there is a SELECT permission on its base table. 
  • A SELECT INTO statement cannot be used in view declaration statement. 
  • A trigger or an index cannot be defined on a view. 
  • The CREATE VIEW statement cannot be combined with other SQL statements in a single batch. 

Example :
In the following example we have two table Client and Products. And if you want to see only those client records that are active in Products table also means right now they are supplying us the products. For this we are creating the view by the name of Supp_Client.

mysql> SELECT * FROM Client;
+------+---------------+----------+
| C_ID | Name | City |
+------+---------------+----------+
| 1 | A K Ltd | Delhi |
| 2 | V K Associate | Mumbai |
| 3 | R K India | Banglore |
| 4 | R S P Ltd | Kolkata |
| 5 | A T Ltd | Delhi |
| 6 | D T Info | Delhi |
+------+---------------+----------+
6 rows in set (0.00 sec)
mysql> SELECT * FROM Products;
+---------+-------------+------+
| Prod_ID | Prod_Detail | C_ID |
+---------+-------------+------+
| 111 | Monitor | 1 |
| 112 | Processor | 2 |
| 113 | Keyboard | 2 |
| 114 | Mouse | 3 |
| 115 | CPU | 5 |
+---------+-------------+------+
5 rows in set (0.00 sec)
       
Example : Create View Statement
         

mysql> CREATE VIEW Supp_Client AS
-> SELECT * FROM Client
-> WHERE C_ID IN (
-> SELECT C_ID FROM Products)
-> WITH CHECK OPTION;
Query OK, 0 rows affected (0.05 sec)
mysql> SELECT * FROM Supp_Client;
+------+---------------+----------+
| C_ID | Name | City |
+------+---------------+----------+
| 1 | A K Ltd | Delhi |
| 2 | V K Associate | Mumbai |
| 3 | R K India | Banglore |
| 5 | A T Ltd | Delhi |
+------+---------------+----------+
4 rows in set (0.03 sec)
In the following example we include the WHERE clause with the select statement of view. Then MySQL adds this condition to the VIEW definition when executing the statement for further restricting the result. Example :
mysql> SELECT * FROM Supp_Client WHERE City='Delhi';
+------+---------+-------+
| C_ID | Name | City |
+------+---------+-------+
| 1 | A K Ltd | Delhi |
| 5 | A T Ltd | Delhi |
+------+---------+-------+
2 rows in set (0.04 sec)
ALTER VIEW Statement
By the ALTER VIEW Statement we can change the definition of a view. This statement is useful to modify a view without dropping it. ALTER VIEW statement syntax is similar to CREATE VIEW Statement and effect is same as the CREATE OR REPLACE VIEW. The general syntax of ALTER VIEW Statement is :
        ALTER VIEW view_name [(column_list)] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION]
In the following example we are altering the view definition that we have created above. In this we add one more column by the name of Prod_Detail of Products table. Example of Altering the View Statement :
mysql> ALTER VIEW Supp_Client AS
-> SELECT Client.C_ID, Client.Name, Client.City,
-> Products.Prod_Detail from Client, Products
-> WHERE Client.C_ID=Products.C_ID;
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT * FROM Supp_Client;
+------+---------------+----------+-------------+
| C_ID | Name | City | Prod_Detail |
+------+---------------+----------+-------------+
| 1 | A K Ltd | Delhi | Monitor |
| 2 | V K Associate | Mumbai | Processor |
| 2 | V K Associate | Mumbai | Keyboard |
| 3 | R K India | Banglore | Mouse |
| 5 | A T Ltd | Delhi | CPU |
+------+---------------+----------+-------------+
5 rows in set (0.02 sec)
DROP VIEW Statement
For dropping a view you can use the DROP VIEW Statement. When view is dropped but it has no effect on the underlying tables. After dropping a view if you issue any query that reference a dropped view then you get an error message. But dropping a table that reference any view does not drop the view automatically you have to dropt the view explicitly. The general syntax of DROP VIEW Statement is :
       
DROP VIEW view_name;
In the following example we are dropping the view that we have created above. Example of Dropping the View Statement :
mysql> DROP VIEW Supp_Client;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM Supp_Client;
ERROR 1146 (42S02): Table 'employee.supp_client' doesn't exist


Contoh Implemetasi View:
1. Membuat Tabel barang:






mysql> create table barang
   -> (kode_barang char(3) not null primary key default'0',
   -> nama_barang char(30),
   -> harga_barang int);
Query OK, 0 rows affected (0.05 sec)


mysql> insert into barang
    -> value
    -> ('001', 'mobil',5000000);
Query OK, 1 row affected (0.01 sec)


2. Membuat Tabel Jual
mysql> create table jual
    -> (tgl date,
    -> kode char(3), jml_jual int);
Query OK, 0 rows affected (0.03 sec)


mysql> insert into jual
    -> value
    -> ('2007/01/01','001',3);
Query OK, 1 row affected (0.03 sec)


3. Membuat View
mysql> create view jualan_view as select date_format(b.tgl,'%d%M%Y')as tgl, b.ko
de, a.nama_barang, a.harga_barang, b.jml_jual,(a.harga_barang*b.jml_jual) as tot
al from jual b, barang a where b.kode=a.kode_barang;
Query OK, 0 rows affected (0.00 sec)


mysql> select* from jualan_view;
+---------------+------+-------------+--------------+----------+----------+
| tgl           | kode | nama_barang | harga_barang | jml_jual | total    |
+---------------+------+-------------+--------------+----------+----------+
| 01January2007 | 001  | mobil       |      5000000 |        3 | 15000000 |
+---------------+------+-------------+--------------+----------+----------+
1 row in set (0.00 sec)


mysql> select* from jual;
+------------+------+----------+
| tgl        | kode | jml_jual |
+------------+------+----------+
| 2007-01-01 | 001  |        3 |
+------------+------+----------+
1 row in set (0.00 sec)


mysql> select* from jualan_view;



Read more
0

BinaryTree (Pascal)


{Program Binary Tree dengan Pascal
tgl.1 Des 09
----------------------------------------------------------}
program binary_tree;


uses
   wincrt;


type
    PBinaryTree = ^Node;
    Node = record
         info : Integer;
         Left : PBinaryTree;
         Right: PBinaryTree;
    end;
var
   BinaryTree :PBinaryTree;
   Pil:char;


procedure Insert(var bt :PBinaryTree; info:Integer);
var
   x:PBinaryTree;
begin
     if (bt=nil) then
     begin
          new(x);
          x^.info:=info;
          x^.Left:=nil;
          x^.Right:=nil;
          bt :=x;
     end
     else
         if (info <=bt^.Info) then
            insert(bt^.left,info)
         else
             Insert(bt^.Right,info)
end;


function Find(bt:PBinaryTree; Search :Integer):Boolean;
begin
     if (bt=nil) then
        find:=Find(bt^.Left,Search)
     else
        if (Search>bt^.Info) then
           find:=Find(bt^.Right, Search)
        else
           if(search >bt^.info) then
              Find:=Find(bt^.Right, Search)
           else
               Find:=true;
end;




function Delete(var bt: PBinaryTree; Info: Integer):Boolean;
var
   x,y:PBinarytree;
begin
     if not (Find(bt,info)) then
        delete:=false
     else
         if(info
            delete:=delete(bt^.left, info)
         else
             if (info
             delete:=delete(bt^.left, info)
             else
                 if (info
                 delete:=delete(bt^.right, info)
                 else
                 begin
                      x:=bt;
                      if (x^.Right <> nil) then
                      begin
                           bt:=x^.Right;
                           y:=bt;
                           while (y^.Left <> nil) do
                                 y :=y^.Left;
                                 y^.left:=x^.Left;
                      end
                      else
                          bt:=x^.left;
                      delete:=true;
                 end;
end;


function NodeCount(bt:PbinaryTree):Integer;
begin
     if (bt=nil) then
        nodecount:=0
     else
         nodecount:=1+NodeCount(bt^.left)+NodeCount(bt^.right);
end;




procedure menu;
begin
     clrscr;
     writeln('Ordered Binary Tree');
     writeln('===================');
     writeln;
     writeln('1.Input data');
     writeln('2.Cari Data');
     writeln('3.Hapus Data');
     writeln('4.Jumlah Node');
     writeln('5.Tampilkan Data Secara in order');
     writeln('6.Tampilkan Data Secara pre order ');
     writeln('7.Tampilkan Data Secara Post Order');
     writeln;
     writeln('0.keluar');
     writeln;
     writeln('Silahkan Pilih (0-7)');
     writeln;
end;


procedure inputData(var bt:PBinaryTree);
var
   code,k,d:Integer;
   I:string;
begin
     clrscr;
     writeln('Input Data Binar Tree');
     writeln('=====================');
     writeln;
     writeln;
     K:=1;
     repeat
           write('masukkan data ke-',k,';');
           readln(i);
           if(i<>'') then
           begin
                val(i,d,code);
                if(code=0) then
                   insert(bt,d);
           end;
           inc(k)
     until(i='');
end;


procedure Caridata(bt:PBinaryTree);
var
   s:integer;
   ulangi:char;
begin
     clrscr;
     writeln('Mencari Data Binary Tree');
     writeln('========================');
     writeln;
     repeat
           write('Masukkan data yang akan dicari:');
           readln(s);
           if (Find(bt,s)) then
              writeln('Data Ditemukan')
           else
           writeln('Data Tidak Ada');
           writeln;
           write('Ulangi (Y/T)');
           ulangi := ReadKey;
           writeln;
     until (Upcase(Ulangi) ='T');
end;


procedure HapusData(var bt:PBinaryTree);
var
   s:Integer;
   Ulangi:Char;
begin
     clrscr;
     writeln('Menghapus Data Binay Tree');
     writeln('=========================');
     writeln;
     repeat
           writeln('masukan data yang akan dihapus:');
           readln(s);
           if (Delete(bt,s))then
              writeln('Data berhasil dihapus')
           else
              writeln('Data Tidak Ada');
           writeln;
           writeln;
           write('Ulangi (Y/T)');
           ulangi := ReadKey;
           writeln;
     until (Upcase(Ulangi) ='T');
end;


procedure jumlahNode(bt:PBinaryTree);
begin
     clrscr;
     writeln('Jumlah Node = ',NodeCount(bt));
     write('Tekan Sembarang Tombol...');
     ReadKey;
end;


procedure InOrder(bt:PBinaryTree);
begin
     if (bt <> nil) then
     begin
          InOrder(bt^.Left);
          write(bt^.Info:8);
          InOrder(bt^.Right);
     end;
end;


procedure PostOrder(bt:PBinaryTree);
begin
     if (bt <> nil) then
     begin
          PostOrder(bt^.Left);
          PostOrder(bt^.Right);
          write(bt^.Info:8);
     end;
end;


procedure PreOrder(bt:PBinaryTree);
begin
     if (bt <> nil) then
     begin
          write(bt^.Info:8);
          PreOrder(bt^.Left);
          PreOrder(bt^.Right);
     end;
end;




procedure cetakInOrder(bt:PBinaryTree);
begin
     clrscr;
     writeln('Inorder');
     InOrder(bt);
     writeln;
     write('Tekan Sembarang tombol...');
     ReadKey;
end;


procedure cetakPreOrder(bt:PBinaryTree);
begin
     clrscr;
     writeln('Pre Order');
     Preorder(bt);
     writeln;
     write('Tekan Sembarang tombol...');
     ReadKey;
end;


procedure cetakPostOrder(bt:PBinaryTree);
begin
     clrscr;
     writeln('Post Order');
     PostOrder(bt);
     writeln;
     write('Tekan Sembarang tombol...');
     ReadKey;
end;




begin
     BinaryTree :=Nil;
     repeat
           Menu;
           Pil := Readkey;
           case Pil of
                '1': InputData (BinaryTree);
                '2': CariData (BinaryTree);
                '3': HapusData (BinaryTree);
                '4': JumlahNode(BinaryTree);
                '5': CetakInOrder (BinaryTree);
                '6': CetakPreOrder (BinaryTree);
                '7': CetakPostOrder (BinaryTree);
           end;
     until pil='0';
end.

Read more
0

TRANSFER PRICING


DEFINISI TRANSFER PRICING
Transfer pricing adalah harga yang dibebankan satuan usaha individual dalam suatu perseroan multisatuan usaha atas transaksi di antara mereka sendiri. Konsep ini digunakan bila setiap satuan usaha dikelola sebagai suatu pusat laba, yang masing-masing bertanggung jawab atas laba dari modal yang diinvestasikan. Dengan praktek transfer pricing, perusahaan akan melaporkan rugi sehingga tidak perlu membayar pajak.
Bukan rahasia umum untuk meminimalisasi pajak, perusahaan sering melakukan transfer pricing guna memaksimalkan keuntungan. Bagi kalangan pebisnis, pajak tetap saja dipandang sebagai beban yang mengurangi kecil keuntungan. Atas dasar itu wajar jika mereka merekayasa suatu transaksi untuk meminimalisasi beban pajak dengan transfer pricing. Transfer pricing merupakan terminologi yang secara umum merujuk pada upaya rekayasa alokasi keuntungan antarbeberapa perusahaan dalam satu grup perusahaan multinasional. Secara keseluruhan yang terpenting dari akhir kegiatan adalah laba setelah pajak dari grup.
Transfer pricing menyebabkan ketidakadilan dalam perpajakan karena perbedaan struktur perusahaan. Perusahaan yang dipecah-pecah menjadi suatu grup dapat merekayasa laba sehingga meminimalkan pajak. Sementara itu, perusahaan tunggal harus membayar pajak seperti apa adanya. Untuk menegakkan keadilan perpajakan dimaksud, buku Tax Law Design and Drafting terbitan IMF 1996, merekomendasikan dua pendekatan. Pertama, dengan merumuskan dalam ketentuan domestik, suatu negara dapat mengambil laba global grup dan mengalokasikan sebagian laba tersebut berdasar formula tertentu kepada sumber yang berada di negaranya dan kemudian memajaki bagian laba dimaksud.
Kedua, suatu negara dapat menentukan laba dari cabang usaha (bentuk usaha tetap) atau anak perusahaan yang beroperasi di negaranya terpisah dari grup berdasar harga yang wajar yang seharusnya terjadi apabila transaksi dilakukan dengan pihak di luar grupnya (arm's length price).
Dari kedua pendekatan tersebut, UU Pajak Penghasilan (PPh) menyebut pendekatan kedua (pendekatan harga dan laba wajar- arm's length profits). Hal ini sejalan dengan praktik pemajakan internasional yang berterima umum dan dianjurkan untuk negara-negara anggota OECD.
Pasal 18 ayat (2) UU PPh menegaskan pemberlakuan arm's length price dan profit tersebut dengan memberikan kewenangan kepada Dirjen Pajak untuk menghitung kembali laba fiskal dan menentukan utang sebagai modal, apabila terdapat transaksi antara pihak yang terdapat hubungan istimewa. Untuk operasionalisasi Pasal 18 ayat (2) dimaksud. diterbitkan SE No.04/PJ.7/1993. Nampaknya Surat Edaran ini merujuk pada Pedoman Transfer Pricing OECD tahun 1979.
Subtansi dalam Surat Edaran tersebut lebih bersifat normatif, sehingga operasionalisasi dalam praktik mengalami kesulitan. Hal ini dapat dimaklumi karena kondisi dan istrumen pendukung upaya mengatasi transfer pricing di Indonesia masih langka. Data pembanding harga, biaya dan laba kotor dari dunia perdagangan, industri dan sektor lainya sulit didapatkan. Sehingga kebanyakan koreksi dari pemeriksaan atas transfer pricing dengan mudah dapat dipatahkan oleh wajib pajak di Pengadilan Pajak.





TUJUAN TRANSFER PRICING
Tujuan penerapan harga transfer adalah untuk mentransmisikan data keuangan di antara departemen-departemen atau divisi-divisi perusahaan pada waktu mereka salaing mengunakan barang dan jasa satu sama lain (Henry Simanora, 1999:273). Selain tujuan tersebut, transfer pricing terkadang digunakan untuk mengevaluasi kinerja divisi dan emotivasi manajer divisi penjual dan divisi pembelian menuju keputusan-keputusan yang serasi dengan tujuan perusahaan secara keseluruhan. A transfer pricing system should satisfy three objektives: acurate performance evaluation, goal congruance, and preservation of divisional autonomy (Joshua Ronen and George McKiney, 1970:100-101)
Sedangkan dalam lingkungan perusahaan multinasional, transfer pricing digunakan untuk meminimalkan pajak dan bea yang mereka keluarkan di seluruh dunia.
Trasfer pricing can effect overall corporate incame taxes, this is particulary true for multinational corporations (Hansen and Mowen, 1996:486)
METODE TRANSFER PRICING
Bebrapa metode transfer pricing yang sering digunakan oleh perusahaan-perusahaan konglomerasi dan divisionalisasi/departementasi yaitu:
1. Harga Transfer dasar Biaya (Cost – Based Transfer Pricing)
Perusahaan yang meggunakan metode transfer atas dasar biaya menetapkan harga trasfer atas biaya variabel dan tetap yang bisa dalam 3 pemilihan bentuk yaitu : biaya penuh (full cost), biaya penuh ditambahkan mark-up (full cost plus markup) dan gabungan antara biaya variabel dan tetap (variabel cost plus fixed fee).

2. Harga Transfer atas Dasar Harga Pasar (Market Basis Transfer Pricing)
Apabila ada suatu pasar yang sempurna, metode transfer pricing atas dasar pasar inilah merupakan ukuran yang paing memadai karena sifatnya yang independen. Namun keterbatasan informasi pasar yang terkadang menjadi kendala dalam mengunakan transfer pricing yang berdasarkan harga pasar.
3. Harga Transfer Negosiasi (Negotiated Transfer pricing)
Dalam ketiadaan harga, beberapa perusahaan memperkenalkan divisi-divisi dalam perusahaan yang berkepentingan dengan transfer pricing untuk menegosiasikan harga transfer pricing yang diinginkan. Harga trasfer mencerminkan prespektif kontrolabilitas yan inheren dalam pusat-pusat pertanggungjawaban karena setiap divisi yang berkepentingan tersebut pada akhirnya yang akan bertanggungjawab atas harga transfer yang dinegosiasikan.

Read more
0

Program Mesin ATM (Pascal)


program BANK_MADE_ATM;

{Program Mesin ATM
PRA S2 Ilkom UGM
Made Agung Raharja (mdagungraharja@gmail.com)
=========================================================================================}

uses wincrt;

Type
Customer = record
norek :LongInt;
realpin :LongInt;
Saldo :LongInt;
end;
var
FileCustomer : File of Customer;
RecordCustomer : Customer;
lagi,continue,subpil,lanjut :Char;
posisi : integer;
norektuju, salah,t,pilihan,pin,pinb,pinc,i, valtarik,PinA, norek1:longint;


{----------------- Procedure Exit -----------------------------------}
procedure exitt; {proedur untuk keluar program}
begin
clrscr;
writeln('Mau melakukan transaksi lainnya? (Y/N)');
readln(subpil);
if (subpil='n') or (subpil='N') then begin clrscr; writeln('Silakan ambil kartu anda. Terima kasih.');readln; end;
end;

{----------------------- Fungsi rekursif penyebutan bilangan------------------------ }
function Terbilang( x : longint):String;
function Bilang(x : longint):string;
begin
case x of
0: Bilang:='';
1: Bilang:='satu';
2: Bilang:='dua';
3: Bilang:='tiga';
4: Bilang:='empat';
5: Bilang:='lima';
6: Bilang:='enam';
7: Bilang:='tujuh';
8: Bilang:='delapan';
9: Bilang:='sembilan';
10: Bilang:='sepuluh';
11: Bilang:='sebelas';
end;{end case}
end;

begin
if x < 12 then Terbilang := ' ' + Bilang(x) else if x < 20 then terbilang := Terbilang(x-10) + 'belas' else if x < 100 then terbilang := Terbilang(x div 10) + 'puluh' + Terbilang(x mod 10) else if x < 200 then Terbilang := 'seratus' + Terbilang (x -100) else if x < 1000 then terbilang := Terbilang(x div 100) + 'ratus' + Terbilang(x mod 100) else if x < 2000 then Terbilang := 'seribu' + Terbilang (x -1000) else if x < 1000000 then terbilang := Terbilang(x div 1000) + 'ribu' + Terbilang(x mod 1000) else if x < 1000000000 then terbilang := Terbilang(x div 1000000) + 'juta' + Terbilang(x mod 1000000) else terbilang := Terbilang(x div 1000000000) + 'milyar' + Terbilang(x mod 1000000000); end; {------------ function cek ada No rekening --------------------------------------------} function AdaRek(rek:longint):boolean; var ada:boolean; begin ada:=false; reset(FileCustomer); while not eof(FileCustomer) do begin read(FileCustomer, RecordCustomer); if RecordCustomer.norek = rek then begin ada:=true; posisi:=filepos(FileCustomer); {letakkan pointer di eof biar keluar dari looping } seek(FileCustomer, filesize(FileCustomer)); end; end; adarek:=ada; end; {-----------------------------procedure buat acc baru--------------} procedure BuatAccBaru; begin {$I-} Assign(FileCustomer,'ATM.DAT'); rewrite(FileCustomer); {$I+} Lagi:='Y'; while Upcase(Lagi)='Y' do begin clrscr; writeln('..::: Membuat File Baru Data Account :::.. '); writeln('----------------------------------------------'); with RecordCustomer do Begin {proses input no account} write('No Account (9 digit) : '); Readln(norek1); while (norek1<10000000) or (norek1>999999999) do
begin
clrscr;
writeln('Salah');
Write('No account (Min & MAk 9 digit):');Readln(norek1);
end;
if AdaRek(norek1) then
begin
writeln('Data Sudah Ada...');
writeln('Press enter key to continue...');
readln;

end
else
begin
norek:=norek1;
write('PIN (Min & Mak 6 Digit) : ');
Readln(realpin);
{Proses input PIN}
while (realpin<100000) or (realpin>999999) do
begin
writeln('Salah');
Writeln('Masukkan PIN: (6 digit)');Readln(realpin);writeln;
end;

write('Masukkan Saldo Kelipatan 50000 : ');
Readln(saldo);
while (saldo mod 50000<>0) do
begin
Writeln('Masukkan Jumlah Saldo (Rp.) Kelipatan 50.000:');Readln(saldo);writeln;
end;
writeln('Terbilang : ', Terbilang(saldo),'rupiah');

end;
{----------------------rekam file----------------}
write(FileCustomer,RecordCustomer);


{----------------------tutup file----------------}
close(FileCustomer);
end;


GotoXY(5,8);write('Masukkan data lagi (Y/T)');Readln(Lagi);

end;

end;


{------------------------------------Procedure Menambah Data Acc-----------------}
procedure MenambahDataAcc;

begin

Assign(FileCustomer,'ATM.DAT'); {menghubungkan nama dari ekternal file ke dalam suatu file variabel}
{$I-}
Reset(FileCustomer); {Buka File}
{$I+}
if IOResult <> 0 Then Rewrite(FileCustomer);
{----------------------Arahkan petunjuk file ke akhir dari file}
seek(FileCustomer, FileSize(FileCustomer));

Lagi:='Y';
while Upcase(Lagi)='Y' do
begin
clrscr;
with RecordCustomer do
Begin
writeln(' ..::: Menambah Data Account :::.. ');
writeln('----------------------------------------------');
write('No Account (9 digit) : ');
Readln(norek1);
while (norek1<10000000) or (norek1>999999999) do
begin
clrscr;
writeln('Salah');
Write('No account (Min & MAk 9 digit):');Readln(norek1);
end;


if AdaRek(norek1) then
begin
writeln('Data Sudah Ada...');
writeln('Press enter key to continue...');
readln;

end
else
begin
norek:=norek1;
write('PIN (Min & Mak 6 Digit) : ');
Readln(realpin);
while (realpin<100000) or (realpin>999999) do
begin
writeln('Salah');
Writeln('Masukkan PIN: (6 digit)');Readln(realpin);writeln;
end;

write('Masukkan Saldo Kelipatan 50000 : ');
Readln(saldo);
while (saldo mod 50000<>0) do
begin
Writeln('Masukkan Jumlah Saldo (Rp.) Kelipatan 50.000:');Readln(saldo);writeln;

end;
writeln('Terbilang : ', Terbilang(saldo),'rupiah');
{----------------------rekam file----------------}
write(FileCustomer,RecordCustomer);
end;
end;
{----------------------tutup file----------------}
close(FileCustomer);

GotoXY(5,8);write('Masukkan data lagi (Y/T)');Readln(Lagi);
end;

end;

{---------------------- Procedure menghapus Data Account------------------}
Procedure HapusDataAcc;
Var FileTmp : File of Customer;
Lagi,Hapus, ulang: Char;
Ada : Boolean;
i : Integer;

Begin
Ulang:='Y';
Lagi :='Y';
Clrscr;
Repeat
Assign(FileCustomer,'ATM.DAT');
{$I-}
Reset(FileCustomer); {Buka File}
{$I+}

If IOResult<>0 Then
Write('Data Masih Kosong...!')
Else
Begin
Clrscr;
Assign(FileTmp,'atm.tmp');
Rewrite(FileTmp);
Ada:= False;
i:=0;
writeln(' ..::: Meghapus Data Account :::.. ');
writeln('----------------------------------------------');

Write('No Account (9 digit) : ');Readln(norek1);
While (Ada=False) And (i<>Filesize(FileCustomer)) Do
Begin
Seek(FileCustomer,i);
Read(FileCustomer,recordCustomer);
If RecordCustomer.norek=norek1 Then
Ada:=True
Else
Inc(i);
End;
If (Ada=True) Then
Begin
Writeln('PIN : ',RecordCustomer.realpin);
Writeln('Saldo : ',RecordCustomer.saldo:2);
writeln;
Writeln('Data Ini Di Hapus [Y/T]:');Readln(Hapus);
If Upcase(Hapus)='Y' Then
Begin
For i := 1 to Filesize(FileCustomer) Do
Begin
Seek(FileCustomer,i-1);
Read(FileCustomer,RecordCustomer);
If recordcustomer.norek<>norek1 Then
Write(FileTmp,recordcustomer);
End;
Close(FileCustomer);
Assign(FileCustomer,'ATM.Dat');
Erase(FileCustomer);
Assign(FileTmp,'atm.tmp');
Rename(FileTmp,'atm.Dat');
Writeln('Nomor Account "',norek1,'" Sudah Di Hapus!');
End;
End
Else
Begin
Writeln('Nomor Account "',norek1,'" Ini Tidak Ada!');
End;
Writeln('Hapus Data Lagi [Y/T]:');Lagi:=Upcase(Readkey);
End;
Until Lagi<>'Y';
End;


{-----------------------------procedure tampil acc --------------}
procedure TampilAcc;

begin
{$I-}
Assign(FileCustomer,'ATM.DAT');
reset(FileCustomer);
{$I+}

clrscr;
writeln('-------------------------------------');
writeln('No.Acc PIN saldo ');
writeln('--------------------------------------');

while not Eof(FileCustomer) Do
begin
read(FileCustomer, RecordCustomer);
with RecordCustomer do
writeln(norek:5,realpin:10,saldo:11);
end;
writeln('-----------------------------------------');

{----------------------tutup file----------------}
close(FileCustomer);
end;

{------------ function cek pin --------------------------------------------}
function AdaPin(cpin:longint):boolean;
var ada:boolean;
begin
ada:=false;
reset(FileCustomer);
while not eof(FileCustomer) do
begin
read(FileCustomer, RecordCustomer);
if RecordCustomer.realpin = cpin then
begin
ada:=true;
posisi:=filepos(FileCustomer);
{ letakkan pointer di eof biar keluar dari looping }
seek(FileCustomer, filesize(FileCustomer));
end;
end;
adaPin:=ada;

end;


{------------------------------Procedure input pin --------------}

procedure askpin;
begin

Write('Enter your PIN please: ');readln(pin);
end;


{-----------------------------------Procedure Tarik Tunai-------------------}
procedure tariktunai;

begin
Assign(FileCustomer,'ATM.DAT'); {menghubungkan nama dari ekternal file ke dalam suatu file variabel}
Reset(FileCustomer); {Buka File}
pin:=RecordCustomer.Realpin;
Read(FileCustomer, RecordCustomer);

if adapin(pin) then
begin

repeat
clrscr;
Writeln('AKEPI BANK ATM');
Writeln('TARIK TUNAI');
Writeln;
Writeln('1. 100.000 4. 1.500.000');
Writeln('2. 200.000 5. 2.500.000');
Writeln('3. 500.000 6. Other value');
Writeln;
Writeln('Enter your choice please: ');Readln(pilihan);
writeln('pin', RecordCustomer.Realpin);
Case pilihan of
1: valtarik:= 100000;
2: valtarik:= 200000;
3: valtarik:= 500000;
4: valtarik:= 1500000;
5: valtarik:= 2500000;
6: begin
clrscr;
writeln('Enter the value:');
Readln(valtarik);
while (valtarik mod 50000<>0) or (valtarik>5000000) do {penarikan mak 5juta}
begin
Writeln('Enter the value (Kelipatan Rp.50.000) :');Readln(valtarik);writeln;
end;
end;
else Writeln('Choice is not available!');
end;
until pilihan<7; while RecordCustomer.saldo-valtarik<=25000 do begin repeat clrscr; Writeln('AKEPI BANK ATM'); Writeln('TARIK TUNAI'); Writeln; Writeln('1. 100.000 4. 1.500.000'); Writeln('2. 200.000 5. 2.500.000'); Writeln('3. 500.000 6. Other value'); Writeln; Writeln('Saldo tidak mencukupi.'); Writeln('Enter your choice please: ');Readln(pilihan); Case pilihan of 1: valtarik:= 100000; 2: valtarik:= 200000; 3: valtarik:= 500000; 4: valtarik:= 1500000; 5: valtarik:= 2500000; 6: begin clrscr; writeln('Enter the value:'); Readln(valtarik); while (valtarik mod 50000<>0) or (valtarik>5000000) do {penarikan mak 5juta}
begin
Writeln('Enter the value (Kelipatan Rp.50.000) :');Readln(valtarik);writeln;
end;
end;
else Writeln('Choice is not available!');
end;
until pilihan<7; end; if RecordCustomer.saldo-valtarik>25000 then
RecordCustomer.saldo:=RecordCustomer.saldo-valtarik;
seek(FileCustomer,posisi-1);
Write(FileCustomer, RecordCustomer);
end;
clrscr;
Writeln('Silakan ambil uang anda.');
Writeln('Press enter key to continue...');
readln;
exitt;
{----------------------tutup file----------------}
close(FileCustomer);
end;

{--------------------- Ganti Pin -----------------------}
procedure gantipin;

begin
clrscr;
Assign(FileCustomer,'ATM.DAT');
Reset(FileCustomer);
Writeln('BANK MADE ATM');
Writeln('GANTI PIN');
Writeln;
Writeln;
Writeln('Masukkan PIN anda sekarang:');
Writeln;
Readln(pin);
Writeln;

Read(FileCustomer, RecordCustomer);

if adaPin(pin) then
begin
clrscr;
Writeln('BANK MADE ATM');
Writeln('GANTI PIN');
Writeln;
Writeln('Access Granted!');
Writeln('Masukkan PIN anda yang baru:');
Writeln;
Readln(pinb);
while (pinb<100000) or (pinb>999999) do
begin
writeln('Salah');
Writeln('Masukkan PIN: (6 digit)');Readln(pinb);writeln;
end;
clrscr;
Writeln('BANK MADE ATM');
Writeln('GANTI PIN');
Writeln;
Writeln;
Writeln('Masukkan PIN anda yang baru sekali lagi:');
Writeln;
Readln(pinc);

if (pinb=pinc) then
begin
RecordCustomer.realpin:=pinb;
{seek(FileCustomer, I-1);}
seek(FileCustomer,posisi-1);
Write(FileCustomer, RecordCustomer);

clrscr;
writeln('PIN sudah diubah.');
end
else
begin
clrscr;
writeln('PIN salah. PIN tidak diubah.');
end;
end
else
begin
clrscr;
writeln('PIN salah. PIN tidak diubah.');
end;

close(FileCustomer);
clrscr;
writeln;
Writeln('Press enter key to continue...');
readln;
exitt;


end;

{-------------------------- PROCEDURE TRANSFER ---------------------------------------}
procedure transfer;
begin
clrscr;
Assign(FileCustomer,'ATM.DAT');
Reset(FileCustomer);
pin:=RecordCustomer.Realpin;
Read(FileCustomer, RecordCustomer);

if adapin(pin) then
begin

Writeln('BANK MADE ATM');
Writeln('TRANSFER');
Writeln;
Writeln;
Writeln('Masukkan dana yang mau ditransfer:');
Writeln;
Readln(valtarik);
while (valtarik mod 50000<>0) or (valtarik>7000000) do {penarikan mak 5juta}
begin
Writeln('Enter the value (Kelipatan Rp.50.000) :');Readln(valtarik);writeln;
end;

while RecordCustomer.saldo-valtarik<=25000 do begin clrscr; Writeln('BANK MADE ATM'); Writeln('TRANSFER'); Writeln; Writeln('Saldo anda tidak mencukupi!'); Writeln('Masukkan dana yang mau ditransfer:'); Writeln; Readln(valtarik); while (valtarik mod 50000<>0) or (valtarik>7000000) do {penarikan mak 5juta}
begin
Writeln('Enter the value (Kelipatan Rp.50.000) :');Readln(valtarik);writeln;
end;
end;

clrscr;
Writeln('BANK MADE ATM');
Writeln('TRANSFER');
Writeln;
Writeln;
Writeln('Masukkan no rekening yang dituju: (9 digit)');
Writeln;
Readln(norektuju);

if (norektuju<999999999) or (norektuju>999999999) then
begin
clrscr;
Writeln('BANK MADE ATM');
Writeln('TRANSFER');
Writeln;
Writeln('No rekening yang dimasukkan salah!');
Writeln('Masukkan no rekening yang dituju: (9 digit)');
Writeln;
Readln(norektuju);
end;

if RecordCustomer.saldo-valtarik>25 then
RecordCustomer.saldo:=RecordCustomer.saldo-valtarik;
seek(FileCustomer,posisi-1);
write(FileCustomer, RecordCustomer);

end;

clrscr;
Writeln('Transfer selesai dilakukan.');
Writeln('Press enter key to continue...');
readln;
exitt;
{----------------------tutup file----------------}
close(FileCustomer);
end;

{-------------------------- procedure info saldo -------------------------}
procedure infosaldo;
begin
clrscr;
{$I-}
Assign(FileCustomer,'ATM.DAT');
reset(FileCustomer);
{$I+}
Writeln('BANK MADE ATM');
Writeln('INFORMASI SALDO');
Writeln;
Writeln;
Writeln('Saldo rekening anda sebesar:');
Writeln('');

pin:=RecordCustomer.Realpin;
Read(FileCustomer, RecordCustomer);
if adapin(pin) then
begin
Writeln('Rp. ',RecordCustomer.saldo);
writeln('Terbilang : ', Terbilang(RecordCustomer.saldo),' rupiah');
Writeln;
Writeln('Press enter key to continue...');
readln;

end;
{----------------------tutup file----------------}
close(FileCustomer);
exitt;
end;



{*********** progra utama***********************}
var
pilih :byte;
pinOke:boolean;


begin
while true do
begin
clrscr;
writeln('************************************');
Writeln('* BANK MADE *');
Writeln('* ADMINISTRATOR FORM *');
Writeln('************************************');
Writeln;

GotoXY(5,5);writeln('1.Buat File Account Baru');
GotoXY(5,6);writeln('2.Tambah Account Baru');
GotoXY(5,7);writeln('3.Menampilkan Data');
GotoXY(5,8);writeln('4.Menghapus Data');
GotoXY(5,9);writeln('5.Transaksi ATM');

pilih := 0;
while (Pilih<1) or (Pilih >5) do
begin
GotoXY(5,12);Write('Pilih Nomor(1-5)');Readln(Pilih);
if (Pilih <1) or (Pilih >5) then
write(^G);
end;

case Pilih of
1 : BuatAccBaru;
2 : MenambahDataAcc;
3 : Begin
TampilAcc;
writeln('Tekan enter untuk kembali ke menu');
readln;
end;
4 : hapusDataAcc;

5 :begin
clrscr;
writeln('..:: SELAMAT DATANG DI ATM BANK MADE ::..');
writeln('-----------------------------------------');

Assign(FileCustomer,'ATM.DAT');
{$I-} {pengecekan I/O disable}
Reset(FileCustomer);
{$I+}
pinOke:=false;
for i:=1 to 3 Do
begin

askPin;
if adaPin(pin) then
begin
pinOke:=true;
writeln('Access granted!');
salah:=0;writeln;
writeln('Press enter key to continue...');
Readln;
i:=3;
end
else
begin
inc(salah);
writeln('Wrong PIN!');
writeln;
if salah>=3 then
begin
writeln('Your card is blocked!');
exit;
end;
end;
end;

if not pinOke then exit;

{**************MENU AWAL***************}

Repeat
Repeat
clrscr;
writeln('**************************************');
Writeln('* BANK MADE ATM *');
Writeln('* MAIN MENU *');
writeln('**************************************');
Writeln;
Writeln('1. Tarik Tunai 3. Informasi Saldo');
Writeln('2. Transfer 4. Ganti PIN ');
Writeln('0. Batalkan transaksi');
Writeln;
Writeln('Enter your choice please: ');Readln(pilihan);

Case pilihan of
0: exitt;
1: tariktunai;
2: transfer;
3: infosaldo;
4: gantipin;
end;{end case}

until pilihan<4; until (subpil='n') or (subpil='N'); end; end; end; close(FileCustomer); {tutup file dan menuskannya ke penyuimpan sekunder} end.
Read more
 

Friends

ON-LINE