BMS-HOSxP Community

HOSxP => Delphi / Pascal => ข้อความที่เริ่มโดย: doramon ที่ มกราคม 13, 2008, 17:09:31 PM

หัวข้อ: แนะนำตัวอย่าง การเขียน delphi ( pascal )
เริ่มหัวข้อโดย: doramon ที่ มกราคม 13, 2008, 17:09:31 PM
แนะนำตัวอย่าง การเขียน delphi ( pascal ) 

เจอที่ไหนที่สอนดี จะเอามาฝากครับ

โค๊ด: Delphi
  1.  
  2. ตัวอย่างคับ
  3.  
  4. ********************************************************************
  5.  
  6.  
  7. Program WisarutATM;
  8. Uses Wincrt;
  9. Var  pw,mycode,mycode2,mycredit,cusdrw:Integer;
  10.      myname:String;
  11. Const mypw=1234;
  12.  
  13.    Procedure  EnterPWD(var pw:integer);
  14.      begin
  15.         clrscr;
  16.         Write('Enter password : '); Readln(pw);
  17.         If pw=mypw Then
  18.            begin
  19.                clrscr;
  20.                writeln('**Correct password**':20);
  21.                write('Press Enter to continue...'); readln;
  22.            end
  23.            Else
  24.               begin
  25.                  clrscr;
  26.                  writeln('Incorrect password!');
  27.                  write('Try again[2] : '); readln(pw);
  28.                  if pw=mypw then
  29.                  begin
  30.                   clrscr;
  31.                   writeln('**Correct password**':20);
  32.                   write('Press Enter to continue...'); readln;
  33.                  end
  34.                  else
  35.                    begin
  36.                     clrscr;
  37.                     writeln('Incorrect password!');;
  38.                     write('Try again[3] : '); readln(pw);
  39.                     if pw=mypw then
  40.                     begin
  41.                       clrscr;
  42.                       writeln('**Correct password**':20);
  43.                       write('Press Enter to continue...'); readln;
  44.                     end
  45.                     else
  46.                       begin
  47.                         clrscr;
  48.                         writeln('Incorrect password!');
  49.                         writeln('Please contact the bank.');
  50.                       end;
  51.                    end;
  52.               end;
  53.         end;
  54.  
  55.    Procedure MenuChkCredit;
  56.       begin
  57.         clrscr;
  58.         write('Account Name : '); readln(myname);
  59.         write('Balance : '); readln(mycredit);
  60.       end;
  61.  
  62.    Procedure Mainmenu(var mychk:integer);
  63.       begin
  64.         clrscr;
  65.         writeln('**{[[[ MAINMENU ]]]}**':42);
  66.         gotoxy(3,3); write('[1] <<-Select 1 for Deposit');
  67.         gotoxy(38,3); write('Select 2 for Withdrawal ->> [2]');
  68.         gotoxy(3,5); write('[3] <<-Select 3 for Cancel');
  69.         gotoxy(32,7); write(']');
  70.         gotoxy(30,7); write('['); readln(mychk);
  71.       end;
  72.    Procedure Menu1;
  73.       var sal:integer;
  74.       begin
  75.          clrscr;
  76.          writeln('**{[[[ Deposit ]]]}**':20);
  77.          write('Insert Cash = '); readln(sal);
  78.          if sal < 0 then
  79.            begin
  80.            writeln('Cannot deposit (-)number!');
  81.            write('Press Enter to continue...');
  82.            readln;
  83.            end
  84.            else
  85.              begin
  86.                mycredit:=mycredit+sal;
  87.                writeln('Current balance = ',mycredit);
  88.                write('Press Enter to Mainmenu...'); readln;
  89.              end;
  90.       end;
  91.  
  92.     Procedure MenuWithdraw(var mychk2:integer);
  93.       begin
  94.         clrscr;
  95.         writeln('**{[[ Withdrawal ]]}**':42);
  96.         gotoxy(3,3); write('[1] <<- Withdraw 500 Baht');
  97.         gotoxy(35,3); write('[2] <<- Withdraw 1000 Baht');
  98.         gotoxy(3,5); write('[3] <<- Withdraw 5,000 Baht');
  99.         gotoxy(35,5); write('[4] <<- Withdraw 10,000 Baht');
  100.         gotoxy(3,7); write('[5] <<- Withdraw 20,000 Baht');
  101.         gotoxy(35,7); write('[6] <<- Customize Withdraw');
  102.         gotoxy(3,9); write('Select and Press Enter ->>');
  103.         gotoxy(37,9); write(']'); gotoxy(35,9); write('['); readln(mychk2);
  104.       end;
  105.  
  106.     Procedure ShowDraw(drw:integer);
  107.       begin
  108.         clrscr;
  109.         writeln('** Withdrawal Information **');
  110.         gotoxy(3,3); writeln('Withdraw = ',drw);
  111.         gotoxy(3,5); writeln('Curren Balance = ',mycredit);
  112.         gotoxy(1,7); write('Press enter to continue...');
  113.         readln;
  114.       end;
  115.  
  116.     Procedure OverCredit(ovr:integer);
  117.       begin
  118.        clrscr;
  119.        writeln('Cannot withdraw ',ovr);
  120.        writeln('Because Balance = ',mycredit);
  121.        write('Press Enter to Mainmenu...');
  122.        readln;
  123.       end;
  124.     Procedure CusDraw(var cusdrw:integer);
  125.       begin
  126.         clrscr;
  127.         writeln('** Customize Withdraw **');
  128.         gotoxy(3,3); write('Insert Cash = '); readln(cusdrw);
  129.       end;
  130.  
  131. Begin
  132.     EnterPWD(pw);
  133.     If pw<>mypw Then
  134.        readln
  135.     else
  136.     MenuChkCredit;
  137.     While pw=mypw do
  138.     begin
  139.     Mainmenu(mycode);
  140.     If mycode=1 Then
  141.        Menu1
  142.        Else If mycode=2 Then
  143.          begin
  144.            MenuWithdraw(mycode2);
  145.            If mycode2=1 Then
  146.               begin
  147.                 if 500 > mycredit then
  148.                  OverCredit(500)
  149.                 else
  150.                  begin
  151.                   mycredit:=mycredit-500;
  152.                   ShowDraw(500);
  153.                  end;
  154.                 end
  155.               else if mycode2=2 then
  156.                 begin
  157.                   if 1000 > mycredit then
  158.                    OverCredit(1000)
  159.                    else
  160.                      begin
  161.                       mycredit:=mycredit-1000;
  162.                       ShowDraw(1000);
  163.                      end;
  164.                 end
  165.                 else if mycode2=3 then
  166.                   begin
  167.                     if 5000 > mycredit then
  168.                       OverCredit(5000)
  169.                       else
  170.                         begin
  171.                           mycredit:=mycredit-5000;
  172.                           ShowDraw(5000);
  173.                         end;
  174.                     end
  175.                   else if mycode2=4 then
  176.                     begin
  177.                       if 10000 > mycredit then
  178.                         OverCredit(10000)
  179.                       else
  180.                         begin
  181.                           mycredit:=mycredit-10000;
  182.                           ShowDraw(10000);
  183.                         end;
  184.                     end
  185.                     else if mycode2=5 then
  186.                       begin
  187.                         if 20000 > mycredit then
  188.                           OverCredit(20000)
  189.                         else
  190.                           begin
  191.                             mycredit:=mycredit-20000;
  192.                             ShowDraw(20000);
  193.                           end;
  194.                        end
  195.                       else if mycode2=6 then
  196.                        begin
  197.                          CusDraw(cusdrw);
  198.                          if cusdrw <0 then
  199.                            begin
  200.                            writeln('Cannot withdraw (-)number');
  201.                            write('Press enter to continue...'); readln;
  202.                            end
  203.                            else
  204.                              begin
  205.                                if cusdrw > mycredit then
  206.                                OverCredit(cusdrw)
  207.                                else
  208.                                begin
  209.                                 mycredit:=mycredit-cusdrw;
  210.                                 ShowDraw(cusdrw);
  211.                                end;
  212.                              end;
  213.                        end
  214.                        else
  215.                          begin
  216.                            writeln('No selected menu!');
  217.                            write('Press enter to continue...'); readln;
  218.                          end;
  219.  
  220.          end
  221.          Else If mycode=3 Then
  222.             EnterPWD(pw)
  223.             Else
  224.              begin
  225.               Writeln('No selected menu!');
  226.               Write('Press Enter to Mainmenu...'); Readln;
  227.              end;
  228.        end;
  229.  
  230. End.
  231.  
  232.  
หัวข้อ: Re: แนะนำตัวอย่าง การเขียน delphi ( pascal )
เริ่มหัวข้อโดย: SrWooD ที่ มกราคม 14, 2008, 09:29:52 AM
ขอบคุณครับ

หามาเยอะๆ เลยครับ อ.อ๊อด
หัวข้อ: Re: แนะนำตัวอย่าง การเขียน delphi ( pascal )
เริ่มหัวข้อโดย: armds ที่ มกราคม 14, 2008, 10:55:16 AM
ขอบคุณท่าน อ.อ๊อด ที่แนะนำอะไรดีๆ ให้
ไม่ทราบว่า  มีคำสั่งของ delphi  เข้ารหัส  md5  ได้ไหมครับ  เข้ารหัสผ่านของ linux อะครับ เข้าไปใช้ในฐานะ root เลยอะครับ
หัวข้อ: Re: แนะนำตัวอย่าง การเขียน delphi ( pascal )
เริ่มหัวข้อโดย: doramon ที่ มกราคม 14, 2008, 12:20:20 PM
มีครับ

sha1md5

ผสม กันเข้ารหัสผ่าน สองชั้น   hack ยากกว่าเดิม

 ;D   
หัวข้อ: Re: แนะนำตัวอย่าง การเขียน delphi ( pascal )
เริ่มหัวข้อโดย: armds ที่ มกราคม 14, 2008, 12:33:27 PM
sha1md5      เป็น component  หรือ  เป็น  function  ที่มีอยู่แล้วหรือเปล่าครับ หรือต้องหาจากไหนครับ