Selasa, 07 November 2017

Aplikasi Pemesanan Lapangan Futsal (Form Pemesanan)

Assalamualaikum wr. wb.

Pada kesempatan kali ini saya akan melanjutkan postingan kemarin yaitu penyewaan lapangan futsal. aplikasi yang saya buat kali ini yaitu membuat form pemesanan dari client. Pada postingan sebelum dari aplikasi yang buat hanya bisa sampai registrasi mendaftar sebagai member.
ok, langsung saja pada tahap-tahap pembuatan form pemesanan.
langkah yang pertama yang kita akan buat adalah login, seperti pada gambar di bawah ini:

dengan script seperti berikut :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widg37"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/coba"
xmlns:android="http://schemas.android.com/apk/res/android">

<TableLayout
    android:layout_marginTop="280dp"
android:id="@+id/widget37"
android:layout_width="250dp"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:orientation="vertical" >    
    
<EditText
    android:id="@+id/txtusername"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Username"
    android:textSize="18sp" />


<EditText
android:id="@+id/txtpassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:password="True"
android:textSize="18sp" />

 </TableLayout> 
 
<TableLayout
android:id="@+id/w7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>  
<TableRow
    android:layout_marginLeft="90dp"
android:id="@+id/widget65"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnlogin"
android:onClick="login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="L O G I N" />
<Button
android:id="@+id/btndaftar"
android:onClick="daftar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DAFTAR" />
</TableRow>
 </TableLayout> 
<TextView
android:id="@+id/txtstatus"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>


- setelah berhasil login akan masuk pada tampilan home disitu terdapat berbagai macam pengelolah futsal, seperti pada gambar dibawah ini:


dengan script seperti berikut:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bgc"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Home" >

    <ImageView
        android:id="@+id/lap1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="40dp"
        android:background="@drawable/a"/>
    <Button 
        android:id="@+id/btn1"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:text="Dunia Futsal"
        android:textStyle="bold"
        android:layout_below="@+id/lap1"
        android:layout_marginLeft="20dp"/>
     
     <ImageView
         android:id="@+id/lap2"
         android:layout_width="100dp"
         android:layout_height="100dp"
         android:layout_marginLeft="50dp"
         android:layout_marginTop="40dp"
         android:layout_toRightOf="@+id/lap1"
         android:background="@drawable/b" />
     <Button 
        android:id="@+id/btn2"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:text="MyFutsal"
        android:textStyle="bold"
        android:layout_marginLeft="45dp"
        android:layout_below="@+id/lap2"
        android:layout_toRightOf="@+id/lap1"/>
     
     <ImageView
        android:id="@+id/lap3"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="25dp"
        android:layout_marginTop="100dp"
        android:layout_below="@+id/lap1"
        android:background="@drawable/c"/>
     <Button 
        android:id="@+id/btn3"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:text="YouFutsal"
        android:textStyle="bold"
        android:layout_marginLeft="20dp"
        android:layout_below="@+id/lap3"/>
     
     <ImageView
        android:id="@+id/lap4"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_marginLeft="45dp"
        android:layout_marginTop="100dp"
        android:layout_below="@+id/lap2"
        android:layout_toRightOf="@+id/lap3"
        android:background="@drawable/d"/>
     <Button 
        android:id="@+id/btn4"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:text="Futsal"
        android:textStyle="bold" 
        android:layout_marginLeft="40dp"
        android:layout_below="@+id/lap4"
        android:layout_toRightOf="@+id/lap3"/>

</RelativeLayout>

- dari form home, setelah pilih tempat futsal yang kita pilih. kita lanjutkan dengan melakukan pemesanan pada lapangan futsal yang kita pilih. tampilan pilih lapangan seperti berikut:


dengan script seperti berikut :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/lap"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Lapangan1" >

     <ImageView
        android:id="@+id/lap1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginTop="100dp"
        android:background="@drawable/lap1"
        android:scaleType="fitXY" />

    <ScrollView
        android:id="@+id/scrol"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/lap1"
        android:layout_marginTop="20dp" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
            
<TextView
                android:id="@+id/view2"
                android:layout_gravity="center"
                android:textStyle="bold"
                android:textSize="15dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Lapangan Futsal"/>
<TextView
                android:id="@+id/view2"
                android:layout_marginTop="15dp"
                android:textSize="15dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Rp 70.000/Jam"/>
            
            
            <TextView
                android:id="@+id/view1"
                android:layout_marginTop="15dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Futsal adalah permainan bola yang dimainkan oleh dua tim, yang masing-masing beranggotakan lima orang. Tujuannya adalah memasukkan bola ke gawang lawan, dengan memanipulasi bola dengan kaki. Selain lima pemain utama, setiap regu juga diizinkan memiliki pemain cadangan. Tidak seperti permainan sepak bola dalam ruangan lainnya, lapangan futsal dibatasi garis, bukan net atau papan." />

            <TableLayout
                android:id="@+id/tab1"
                android:layout_marginTop="25dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <LinearLayout
                    android:id="@+id/l1"
                    android:layout_gravity="center"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <Button
                        android:id="@+id/btn2"
                        android:layout_width="97dp"
                        android:layout_height="45dp"
                        android:text="C H A T"
                        android:textStyle="bold" />

                    <Button
                        android:id="@+id/btn1"
                        android:layout_width="97dp"
                        android:layout_height="45dp"
                        android:textStyle="bold"
                        android:text="P E S A N" />

                    <Button
                        android:id="@+id/btn3"
                        android:layout_width="97dp"
                        android:layout_height="45dp"
                        android:textStyle="bold"
                        android:text="E X I T" />
                </LinearLayout>
            </TableLayout>
        </LinearLayout>
    </ScrollView>

</RelativeLayout>

- kemudian kita akan melakukan pemesanan pada lapangan yang kita inginkan, seperti pada gambar dibawah ini:


dengan script seperti berikut :


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widg37"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/tes"
xmlns:android="http://schemas.android.com/apk/res/android">

<TableLayout
    android:layout_marginTop="190dp"
android:id="@+id/widget37"
android:layout_width="250dp"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:orientation="vertical" >  
    <EditText
    android:id="@+id/txtlap"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="id_lapangan"
    android:textSize="18sp" />
    
<EditText
    android:id="@+id/txtjammulai"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Jam Mulai"
    android:textSize="18sp" />


<EditText
android:id="@+id/txtjamselesai"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Jam Selesai"
android:textSize="18sp" />
<TextView 
    android:layout_marginLeft="170dp"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="70.000/Jam"/>
<EditText
    android:id="@+id/txttothal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Total Harga"
    android:textSize="18sp" />

 </TableLayout> 
 
<TableLayout
android:id="@+id/w7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">  
<TableRow
android:id="@+id/widget65"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnlogin"
android:onClick="login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PESAN SEKARANG" />


</TableRow>
 </TableLayout> 
<TextView
android:id="@+id/txtstatus"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>


dengan begitu form pemesanan yang kita buat sudah selesai ....

Senin, 09 Oktober 2017

Aplikasi Pemesan Lapangan futsal

Assalamualaikum Wr. Wb.

Pada Pertemuan Kali Ini saya akan membuat aplikasi Client-Server Pemesanan Lapangan Futsal, Tapi pada blog kali ini saya hanya akan fokus pada Clientnya saja.
Ok, langsung saja ...
- langkah pertama yang harus kita lakukan adalah membuat project baru pada Aplikasi ADT atau sejenisnya .
dengan cara klik pada menu file -> new -> Android Application Project
kemudian kita beri nama disni nama project saya adalah "akta" dengan nama file xml "login".
dengan format project seperti pada gambar di bawah ini:

-login.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widg37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/bg"
xmlns:android="http://schemas.android.com/apk/res/android">

<TableLayout
    android:layout_marginTop="120dp"
android:id="@+id/widget37"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >    
    
    
<TableRow
    android:layout_marginLeft="15dp"
android:id="@+id/widget45"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget47"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="Username   :" />

<EditText
    android:id="@+id/txtusername"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:text=""
    android:textSize="18sp" />

</TableRow>
<TableRow
    android:layout_marginLeft="15dp"
android:id="@+id/widget46"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget55"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="Password   :" />
<EditText
android:id="@+id/txtpassword"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text=""
android:password="True"
android:textSize="18sp" />
</TableRow>
 </TableLayout> 

<TableLayout
android:id="@+id/w7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>  

<TableRow
    android:layout_marginLeft="90dp"
android:id="@+id/widget65"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnlogin"
android:onClick="login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="L O G I N" />
<Button
android:id="@+id/btndaftar"
android:onClick="daftar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DAFTAR" />
</TableRow>
 </TableLayout> 
<TextView
android:id="@+id/txtstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />

</LinearLayout>

- daftar_user.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/widget124"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg"
xmlns:android="http://schemas.android.com/apk/res/android">

<LinearLayout
    android:layout_marginTop="80dp"
android:id="@+id/widget124"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TableLayout
android:id="@+id/widget125"
android:layout_marginLeft="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TableRow
android:id="@+id/widget149"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget150"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Username" />
<EditText
android:id="@+id/txtusername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget152"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget153"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password" />
<EditText
android:id="@+id/txtpassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:password="True"
android:textSize="18sp" />
</TableRow>
<TableRow
android:id="@+id/widget129"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget130"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nama" />


<EditText
android:id="@+id/txtnama"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />

</TableRow>
<TableRow
android:id="@+id/widget135"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget136"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E-mail" />
<EditText
android:id="@+id/txtemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>

<TableRow
android:id="@+id/widget135"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget136"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No Telp" />
<EditText
android:id="@+id/txttelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>

<TableRow
android:id="@+id/widget143"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/widget144"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alamat" />
<EditText
android:id="@+id/txtalamat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="18sp" />
</TableRow>


</TableLayout>

<TableLayout
android:id="@+id/widget125"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
    android:layout_marginLeft="25dp"
android:id="@+id/widget155"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btnsimpan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SIMPAN" />
<Button
android:id="@+id/btnexit"
android:onClick="keluar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="E X I T" />
</TableRow>

</TableLayout>
<TextView
android:id="@+id/txtstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</LinearLayout>

</ScrollView>

- login.java
package com.wilis;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class login extends Activity {
    /** Called when the activity is first created. */
EditText username,password;
TextView status;
Button login,daftar;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        
        username=(EditText) findViewById(R.id.txtusername);
        password=(EditText) findViewById(R.id.txtpassword);
        status=(TextView) findViewById (R.id.txtstatus);
        
        login=(Button) findViewById (R.id.btnlogin);
        daftar=(Button) findViewById (R.id.btndaftar);
        
        login.setOnClickListener(new View.OnClickListener() {
            
            @Override
            
            public void onClick(View v) {
               
               // TODO Auto-generated method stub
               
               ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
               
               postParameters.add(new BasicNameValuePair("username", username
.getText().toString()));
postParameters.add(new BasicNameValuePair("password", password
.getText().toString()));
               
   /*            String valid = "1";*/      
               
               String response = null;
               
               try {
                  
                  response = CustomHttpClient.executeHttpPost("http://10.0.2.2/myfutsal/check.php", postParameters);
                  
                  String res = response.toString();
                  
                  res = res.trim();
                  
                  res = res.replaceAll("\\s+","");
                  
                  status.setText(res);
                  
                  if (res.equals("1")) 
                  {
                   status.setText("Anda Berhasil Login");
                   berhasil(v); 
                  
                  }
                  else { 
//                    status.setText(res.toString());
                    Toast toast = Toast.makeText(getApplicationContext(), "username or password wrong", Toast.LENGTH_LONG);
                    toast.show();
                    }
               }
               
               catch (Exception e) {
                  
                  status.setText(e.toString());
                  
               }
               
            }
            
            });
       
     // penutup buka dari public void onCreate
    }   
        

   
    
    public void daftar (View theButton)
    {
    Intent d = new Intent (this,daftar_user.class);
    startActivity(d);
    }
    

// apabila user berhasil login.
    
    public void berhasil (View theButton)
    {
    Intent s = new Intent (this, Home.class);
    startActivity(s);
    }
    
}


- daftar_user.java

package com.wilis;

import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class daftar_user extends Activity {
   
   EditText username,password,nama,email,no_telp,alamat;
   TextView status;
   Button simpan;
   
   
    /** Called when the activity is first created. */
   
   @Override
   
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.daftar_user);
       
        
        username=(EditText)findViewById(R.id.txtusername);
        password=(EditText)findViewById(R.id.txtpassword);
        nama=(EditText)findViewById(R.id.txtnama);
        email=(EditText)findViewById(R.id.txtemail);
        no_telp=(EditText)findViewById(R.id.txttelp);
        alamat=(EditText)findViewById(R.id.txtalamat);
           
        
        simpan=(Button)findViewById(R.id.btnsimpan);
       // keluar=(Button)findViewById(R.id.btnexit);
        status=(TextView)findViewById(R.id.txtstatus);
        
        simpan.setOnClickListener(new View.OnClickListener() {
         
         @Override
         
         public void onClick(View v) {
             
            // TODO Auto-generated method stub
         
        //atur variabel utk menampung pilihan jenis kelamin
        String type=null;
               
            
            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("username", username.getText().toString()));
            postParameters.add(new BasicNameValuePair("password", password.getText().toString()));
            postParameters.add(new BasicNameValuePair("nama_lengkap", nama.getText().toString()));
            postParameters.add(new BasicNameValuePair("email", email.getText().toString()));
            postParameters.add(new BasicNameValuePair("no_telp", no_telp.getText().toString()));
            postParameters.add(new BasicNameValuePair("alamat_lengkap", alamat.getText().toString()));
            
/*            String valid = "1";*/      
            
            String response = null;
            
            try {
               
               response = CustomHttpClient.executeHttpPost("http://10.0.2.2/myfutsal/aksi_daftar.php", postParameters);
               
               String res = response.toString();
               
               res = res.trim();
               
               res = res.replaceAll("\\s+","");
               
               status.setText(res);
               
               if (res.equals("1")) status.setText("Data tidak Tersimpan Ke server");
               
               else status.setText("Data berhasil disimpan ke server");
               
            }
            
            catch (Exception e) {
               
               username.setText(e.toString());
               
            }
               
         }
            
            
      });
    }
   
    public void keluar (View theButton)
    {
    Intent a = new Intent (this,login.class);
    startActivity(a);
    }
}

 hasil Running :