Commit 5b4c0cf0 authored by Bhavesh Yadav's avatar Bhavesh Yadav

Added checkout receipt

parent 9d7a6b2a
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>
\ No newline at end of file
...@@ -71,6 +71,10 @@ public class checkout extends Activity { ...@@ -71,6 +71,10 @@ public class checkout extends Activity {
else{ else{
sqlite_ops so=new sqlite_ops(this); sqlite_ops so=new sqlite_ops(this);
if(so.check_out(slot_number,Long.parseLong(ticket_number))){ if(so.check_out(slot_number,Long.parseLong(ticket_number))){
Intent i = new Intent(this, ticket.class);
i.putExtra("ticket_no", Long.parseLong(ticket_number));
i.putExtra("checkout",true);
startActivity(i);
Toast.makeText(this,"Successfully,Checked Out",Toast.LENGTH_SHORT).show(); Toast.makeText(this,"Successfully,Checked Out",Toast.LENGTH_SHORT).show();
} }
else{ else{
......
...@@ -141,7 +141,7 @@ public class sqlite_ops extends SQLiteOpenHelper{ ...@@ -141,7 +141,7 @@ public class sqlite_ops extends SQLiteOpenHelper{
public ArrayList getTicketDetails(long ticket_no) { public ArrayList getTicketDetails(long ticket_no) {
ArrayList al=new ArrayList(); ArrayList al=new ArrayList();
SQLiteDatabase db=this.getWritableDatabase(); SQLiteDatabase db=this.getWritableDatabase();
Cursor cr=db.query("records",new String []{"tkt_no","slot","vehicle","check_in"},"tkt_no=?",new String[]{Long.toString(ticket_no)},null,null,null,null); Cursor cr=db.query("records",new String []{"tkt_no","slot","vehicle","check_in","check_out"},"tkt_no=?",new String[]{Long.toString(ticket_no)},null,null,null,null);
if(cr!=null){ if(cr!=null){
cr.moveToFirst(); cr.moveToFirst();
if(cr.getCount()>0){ if(cr.getCount()>0){
...@@ -149,6 +149,7 @@ public class sqlite_ops extends SQLiteOpenHelper{ ...@@ -149,6 +149,7 @@ public class sqlite_ops extends SQLiteOpenHelper{
al.add(1,cr.getString(cr.getColumnIndex("slot"))); al.add(1,cr.getString(cr.getColumnIndex("slot")));
al.add(2,cr.getString(cr.getColumnIndex("vehicle"))); al.add(2,cr.getString(cr.getColumnIndex("vehicle")));
al.add(3,cr.getString(cr.getColumnIndex("check_in"))); al.add(3,cr.getString(cr.getColumnIndex("check_in")));
al.add(4,cr.getString(cr.getColumnIndex("check_out")));
} }
else{ else{
al.add(0,ticket_no); al.add(0,ticket_no);
......
...@@ -3,6 +3,7 @@ package com.example.shady.parkingo; ...@@ -3,6 +3,7 @@ package com.example.shady.parkingo;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -10,7 +11,8 @@ import android.widget.Toast; ...@@ -10,7 +11,8 @@ import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
public class ticket extends Activity { public class ticket extends Activity {
TextView slot,tkt,time_tv,date_tv,vehicle; TextView slot,tkt,time_tv,date_tv,vehicle,ticket_title,checkout_label,checkout_time;
TextView checkout_date_label,checkout_date;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -21,6 +23,11 @@ public class ticket extends Activity { ...@@ -21,6 +23,11 @@ public class ticket extends Activity {
tkt=findViewById(R.id.ticket); tkt=findViewById(R.id.ticket);
time_tv=findViewById(R.id.time_tv); time_tv=findViewById(R.id.time_tv);
date_tv=findViewById(R.id.date_tv); date_tv=findViewById(R.id.date_tv);
ticket_title=findViewById(R.id.ticket_title);
checkout_label=findViewById(R.id.checkout_label);
checkout_time=findViewById(R.id.checkout_time);
checkout_date=findViewById(R.id.checkout_date);
checkout_date_label=findViewById(R.id.checkout_date_label);
Intent i=getIntent(); Intent i=getIntent();
long ticket_no; long ticket_no;
if(i.hasExtra("ticket_no")){ if(i.hasExtra("ticket_no")){
...@@ -33,6 +40,24 @@ public class ticket extends Activity { ...@@ -33,6 +40,24 @@ public class ticket extends Activity {
sqlite_ops so=new sqlite_ops(this); sqlite_ops so=new sqlite_ops(this);
ArrayList data=so.getTicketDetails(ticket_no); ArrayList data=so.getTicketDetails(ticket_no);
if(i.hasExtra("checkout")){
Log.d("CHECKOUT","successfully checkout out");
ticket_title.setText("Checkout Receipt");
checkout_label.setVisibility(View.VISIBLE);
checkout_time.setVisibility(View.VISIBLE);
checkout_date.setVisibility(View.VISIBLE);
checkout_date_label.setVisibility(View.VISIBLE);
String checkout_date_data=data.get(4).toString();
String[] checkoutdateandtime=checkout_date_data.split(" ");
checkout_date.setText(checkoutdateandtime[0]);
checkout_time.setText(checkoutdateandtime[1]);
}else {
ticket_title.setText("Parking Ticket");
checkout_label.setVisibility(View.INVISIBLE);
checkout_time.setVisibility(View.INVISIBLE);
checkout_date.setVisibility(View.INVISIBLE);
checkout_date_label.setVisibility(View.INVISIBLE);
}
slot.setText(data.get(1).toString()); slot.setText(data.get(1).toString());
tkt.setText(data.get(0).toString()); tkt.setText(data.get(0).toString());
String date_data=data.get(3).toString(); String date_data=data.get(3).toString();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
android:background="#fff" android:background="#fff"
android:padding="30sp"> android:padding="30sp">
<TextView <TextView
android:id="@+id/ticket_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Parking Ticket" android:text="Parking Ticket"
...@@ -127,6 +128,61 @@ ...@@ -127,6 +128,61 @@
android:textColor="#000" android:textColor="#000"
android:textSize="20sp" android:textSize="20sp"
android:text="parking slot"/> android:text="parking slot"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:gravity="left"
android:orientation="horizontal">
<TextView
android:id="@+id/checkout_date_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checkout Date:"
android:textColor="#000"
android:gravity="left"
android:textSize="20sp"
android:visibility="gone"/>
<TextView
android:id="@+id/checkout_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#000"
android:textStyle="bold"
android:paddingLeft="10dp"
android:text="Date here"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="left">
<TextView
android:id="@+id/checkout_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checkout Time:"
android:textSize="20sp"
android:textColor="#000"
android:visibility="gone"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkout_time"
android:textSize="20sp"
android:textColor="#000"
android:textStyle="bold"
android:paddingLeft="10dp"
android:text="time here"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment