网上订餐系统_后台功能实现

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Car.java:购物车文件,在此可以提交订单;package com.example.homework;
public class Car
{
String Dish_ID;
String Dish_Name;
String Price;
String Url;
String Type_ID;
String User_ID;
String num;
// 构造函数
public Car(){
Dish_ID = "";
Dish_Name = "";
Url = "";
Type_ID = "";
Price = "";
User_ID="";
num="";
}
public String getDish_ID()
{
return Dish_ID;
}
public String getDish_Name()
{
return Dish_Name;
}
public String getPrice()
{
return Price;
}
public String getUrl()
{
return Url;
}
public String getType_ID()
{
return Type_ID;
}
public String getUser_ID()
{
return User_ID;
}
public String getnum()
{
return num;
}
// Set 方法
public void setDish_ID(String Dish_ID)
{
this.Dish_ID = Dish_ID;
}
public void setDish_Name(String Dish_Name) {
this.Dish_Name = Dish_Name;
}
public void setPrice(String Price)
{
this.Price = Price;
}
public void setUrl(String Url)
{
this.Url = Url;
}
public void setType_ID(String Type_ID)
{
this.Type_ID = Type_ID;
}
public void setUser_ID(String User_ID)
{
er_ID = User_ID;
}
public void setnum(String num)
this.num = num;
}
}
Chinese.java中餐文件:在此文件中显示从数据库中取出关于中餐的有关数据;
package com.example.homework;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@SuppressLint("HandlerLeak")
public class Chinese extends Activity {
public String SERVER_URL = "http://192.168.3.38:8080/ProjectFinal/DishServlet?method=getData";
ListView listview = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(yout.chinese);
Intent intent = getIntent();
Bundle b = intent.getExtras();
String json = b.getString("json");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(json);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for (int i = 0; i < jsonArray.length(); i++) {
Gson gson = new Gson();
try {
Dish d = gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
Map<String, Object> map = new HashMap<String, Object>();
map.put("Dish_Name",d.Dish_Name);
map.put("Price", d.Price );
map.put("Dish_ID",d.Dish_ID);
map.put("Type_ID", d.Type_ID );
map.put("Url", d.Url );
list.add(map);
//Log.d("test", s.sname + " " + s.password);
} catch (JsonSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
listview = (ListView)findViewById(R.id.listView);
SimpleAdapter adapter = new SimpleAdapter(Chinese.this,list,yout.chineseitem,
new String[]{"Dish_Name","Price"},
new int[]{R.id.ChinesedishnameD ,R.id.ChinesedishpriceD});
listview.setAdapter(adapter);
//添加点击按钮
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Chinese.this,Xiangqing.class);
@SuppressWarnings("unchecked")
Map<String, String> map = (Map<String, String>)listview.getItemAtPosition(arg2);
intent.putExtra("Dish_Name", map.get("Dish_Name"));
intent.putExtra("Price",map.get("Price"));
intent.putExtra("Dish_ID", map.get("Dish_ID"));
intent.putExtra("Type_ID",map.get("Type_ID"));
String url= map.get("Url");
String newurl=url.substring(7,stIndexOf("."));
Log.d("test",newurl+"jjjjjjjjjjjjjjjjjjjjj");
intent.putExtra("newurl",map.get("newurl"));
intent.putExtra("Url", newurl);
Chinese.this.startActivity(intent);
}
});
}
public void onClick(View v) {
// new Thread(new Runnable() {
// public void run() {
// /*HttpClient发送GET请求
// * 1.创建HttpClient对象
// * 2.创建HttpGet对象
// * 3.如果需要发送请求参数,可以直接将要发送的参数连接到URL地址中,也可以调用HttpGet的setParams()方法来添加请求参数
// * 4.调用HttpClient对象的execute()方法发送请求。

执行该方法将返回一个HttpResponse对象
// * 5.调用HttpResponse的getEntity()方法,可获得包含服务器响应内容的HttpEntity对象,通过该对象可以获取服务器的响应内容
// * */
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(SERVER_URL);
// HttpResponse response = null;
// try {
// response = client.execute(get);
// } catch (ClientProtocolException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// } catch (IOException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// }
// if (response.getStatusLine().getStatusCode() == 200) {
// // Toast.makeText(MainActivity.this, "连接成功",
// // Toast.LENGTH_SHORT).show();
// Log.d("test", "k hk");
// }
// HttpEntity entity = response.getEntity();
// String json = null;
// try {
// json = EntityUtils.toString(entity, "UTF-8");
// } catch (ParseException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// if (json != null) {
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//
//
// JSONArray jsonArray = null;
// try {
// jsonArray = new JSONArray(json);
// } catch (JSONException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
//
// for (int i = 0; i < jsonArray.length(); i++) {
//
// Gson gson = new Gson();
// try {
// Dish d =
gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
// Map<String, Object> map = new HashMap<String, Object>();
// map.put("Dish_Name",d.Dish_Name);
// map.put("Price", d.Price );
// list.add(map);
// //Log.d("test", s.sname + " " + s.password);
// } catch (JsonSyntaxException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (JSONException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// mHandler.sendMessage(mHandler.obtainMessage(1, list));
// }
//
// }
// }).start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.chinese, menu);
return true;
}
}
Dessert。

Java甜点文件:在此文件中显示从数据库中取出关于甜点的有关数据;package com.example.homework;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@SuppressLint("HandlerLeak")
public class Dessert extends Activity {
public String SERVER_URL = "http://192.168.3.38:8080/ProjectFinal/DishServlet?method=getData";
ListView listview = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(yout.dessert);
Intent intent = getIntent();
Bundle b = intent.getExtras();
String json = b.getString("json");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(json);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for (int i = 0; i < jsonArray.length(); i++) {
Gson gson = new Gson();
try {
Dish d = gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
Map<String, Object> map = new HashMap<String, Object>();
map.put("Dish_Name",d.Dish_Name);
map.put("Price", d.Price );
map.put("Dish_ID",d.Dish_ID);
map.put("Type_ID", d.Type_ID );
map.put("Url", d.Url );
list.add(map);
//Log.d("test", s.sname + " " + s.password);
} catch (JsonSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
listview = (ListView)findViewById(R.id.listView);
SimpleAdapter adapter = new SimpleAdapter(Dessert.this,list,yout.dessertitem,
new String[]{"Dish_Name","Price"},
new int[]{R.id.DessertdishnameD ,R.id.DessertdishpriceD});
listview.setAdapter(adapter);
//添加点击按钮
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Dessert.this,Xiangqing.class);
@SuppressWarnings("unchecked")
Map<String, String> map = (Map<String, String>)listview.getItemAtPosition(arg2);
intent.putExtra("Dish_Name", map.get("Dish_Name"));
intent.putExtra("Price",map.get("Price"));
intent.putExtra("Dish_ID", map.get("Dish_ID"));
intent.putExtra("Type_ID",map.get("Type_ID"));
String url= map.get("Url");
String newurl=url.substring(7,stIndexOf("."));
Log.d("test",newurl+"jjjjjjjjjjjjjjjjjjjjj");
intent.putExtra("newurl",map.get("newurl"));
intent.putExtra("Url", newurl);
Dessert.this.startActivity(intent);
}
});
}
public void onClick(View v) {
// new Thread(new Runnable() {
// public void run() {
// /*HttpClient发送GET请求
// * 1.创建HttpClient对象
// * 2.创建HttpGet对象
// * 3.如果需要发送请求参数,可以直接将要发送的参数连接到URL地址中,也可以调用HttpGet的setParams()方法来添加请求参数
// * 4.调用HttpClient对象的execute()方法发送请求。

执行该方法将返回一个HttpResponse对象
// * 5.调用HttpResponse的getEntity()方法,可获得包含服务器响应内容的HttpEntity对象,通过该对象可以获取服务器的响应内容
// * */
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(SERVER_URL);
// HttpResponse response = null;
// try {
// response = client.execute(get);
// } catch (ClientProtocolException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// } catch (IOException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// }
// if (response.getStatusLine().getStatusCode() == 200) {
// // Toast.makeText(MainActivity.this, "连接成功",
// // Toast.LENGTH_SHORT).show();
// Log.d("test", "k hk");
// }
// HttpEntity entity = response.getEntity();
// String json = null;
// try {
// json = EntityUtils.toString(entity, "UTF-8");
// } catch (ParseException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// if (json != null) {
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//
//
// JSONArray jsonArray = null;
// try {
// jsonArray = new JSONArray(json);
// } catch (JSONException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
//
// for (int i = 0; i < jsonArray.length(); i++) {
//
// Gson gson = new Gson();
// try {
// Dish d = gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
// Map<String, Object> map = new HashMap<String, Object>();
// map.put("Dish_Name",d.Dish_Name);
// map.put("Price", d.Price );
// list.add(map);
// //Log.d("test", s.sname + " " + s.password);
// } catch (JsonSyntaxException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (JSONException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// mHandler.sendMessage(mHandler.obtainMessage(1, list));
// }
//
// }
// }).start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.dessert, menu);
return true;
}
}
Estern.java西餐文件:在此文件中显示从数据库中取出关于西餐的有关数据;
package com.example.homework;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@SuppressLint("HandlerLeak")
public class Estern extends Activity {
public String SERVER_URL = "http://192.168.3.38:8080/ProjectFinal/DishServlet?method=getData";
ListView listview = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(yout.estern);
Intent intent = getIntent();
Bundle b = intent.getExtras();
String json = b.getString("json");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(json);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for (int i = 0; i < jsonArray.length(); i++) {
Gson gson = new Gson();
try {
Dish d = gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
Map<String, Object> map = new HashMap<String, Object>();
map.put("Dish_Name",d.Dish_Name);
map.put("Price", d.Price );
map.put("Dish_ID",d.Dish_ID);
map.put("Type_ID", d.Type_ID );
map.put("Url", d.Url );
list.add(map);
//Log.d("test", s.sname + " " + s.password);
} catch (JsonSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
listview = (ListView)findViewById(R.id.listView);
SimpleAdapter adapter = new
SimpleAdapter(Estern.this,list,yout.esternitem,
new String[]{"Dish_Name","Price"},
new int[]{R.id.EsterndishnameD ,R.id.EsterndishpriceD});
listview.setAdapter(adapter);
//添加点击按钮
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Intent intent = new Intent(Estern.this,Xiangqing.class);
@SuppressWarnings("unchecked")
Map<String, String> map = (Map<String, String>)listview.getItemAtPosition(arg2);
intent.putExtra("Dish_Name", map.get("Dish_Name"));
intent.putExtra("Price",map.get("Price"));
intent.putExtra("Dish_ID", map.get("Dish_ID"));
intent.putExtra("Type_ID",map.get("Type_ID"));
String url= map.get("Url");
String newurl=url.substring(7,stIndexOf("."));
Log.d("test",newurl+"jjjjjjjjjjjjjjjjjjjjj");
intent.putExtra("newurl",map.get("newurl"));
intent.putExtra("Url", newurl);
Estern.this.startActivity(intent);
}
});
}
public void onClick(View v) {
// new Thread(new Runnable() {
// public void run() {
// /*HttpClient发送GET请求
// * 1.创建HttpClient对象
// * 2.创建HttpGet对象
// * 3.如果需要发送请求参数,可以直接将要发送的参数连接到URL地址中,也可以调用HttpGet的setParams()方法来添加请求参数
// * 4.调用HttpClient对象的execute()方法发送请求。

执行该方法将返回一个HttpResponse对象
// * 5.调用HttpResponse的getEntity()方法,可获得包含服务器响
应内容的HttpEntity对象,通过该对象可以获取服务器的响应内容
// * */
// HttpClient client = new DefaultHttpClient();
// HttpGet get = new HttpGet(SERVER_URL);
// HttpResponse response = null;
// try {
// response = client.execute(get);
// } catch (ClientProtocolException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// } catch (IOException e2) {
// // TODO Auto-generated catch block
// e2.printStackTrace();
// }
// if (response.getStatusLine().getStatusCode() == 200) {
// // Toast.makeText(MainActivity.this, "连接成功",
// // Toast.LENGTH_SHORT).show();
// Log.d("test", "k hk");
// }
// HttpEntity entity = response.getEntity();
// String json = null;
// try {
// json = EntityUtils.toString(entity, "UTF-8");
// } catch (ParseException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (IOException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
//
// if (json != null) {
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//
//
// JSONArray jsonArray = null;
// try {
// jsonArray = new JSONArray(json);
// } catch (JSONException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
//
//
// for (int i = 0; i < jsonArray.length(); i++) {
//
// Gson gson = new Gson();
// try {
// Dish d = gson.fromJson(jsonArray.getString(i).toString(), Dish.class);
// Map<String, Object> map = new HashMap<String, Object>();
// map.put("Dish_Name",d.Dish_Name);
// map.put("Price", d.Price );
// list.add(map);
// //Log.d("test", s.sname + " " + s.password);
// } catch (JsonSyntaxException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// } catch (JSONException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// mHandler.sendMessage(mHandler.obtainMessage(1, list));
// }
//
// }
// }).start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.estern, menu);
return true;
}
}

Xiangqing.java详情文件:显示美食的详情。

package com.example.homework;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.ImageView;
public class Xiangqing extends Activity {
TextView Dish_ID1 = null;
TextView Dish_Name1 = null;
TextView Price1 = null;
TextView Type_ID1 = null;
ImageView Url1 = null;
TextView newurl=null;
Button gouwuche=null;
Button see=null;
EditText num1=null;
private String Dish_ID=null;
public String SERVER_URL = "http://192.168.3.38:8080/ProjectFinal/DishServlet?method=android_gouwuche";
public String SERVER_URL1 = "http://192.168.3.38:8080/ProjectFinal/DishServlet?method=getcar";
@SuppressLint("HandlerLeak")
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
// Intent intent = new Intent();
// intent.setClass(Xiangqing.this,Xiangqing.class);
// Xiangqing.this.startActivity(intent);
///JSONObject js=new JSONObject(json);
// String result=js.getString("result").toString();
// if("success".equals(result)){
// Toast.makeText(this, "登录成功!", Toast.LENGTH_SHORT).show();
//
// }else{
// Toast.makeText(this, "登录失败!", Toast.LENGTH_SHORT).show();
// }
}
};
@SuppressLint("HandlerLeak")
Handler mHandler1 = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
Bundle b1 = new Bundle();
b1.putString("json", msg.obj.toString());
Intent intent = new Intent();
intent.putExtras(b1);
intent.setClass(Xiangqing.this, Gouwuche.class);
Xiangqing.this.startActivity(intent);
}
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(yout.xiangqing);
Intent intent = getIntent();
gouwuche =(Button)findViewById(R.id.view_btn);
see = (Button)findViewById(R.id.view_btn1);
num1= (EditText)findViewById(R.id.fenshu);
Dish_ID = intent.getStringExtra("Dish_ID");
String Dish_Name = intent.getStringExtra("Dish_Name");
String Price = intent.getStringExtra("Price");
String Type_ID = intent.getStringExtra("Type_ID");
// String Url = intent.getStringExtra("Url");
// String newurl = intent.getStringExtra("newurl");
Dish_ID1 = (TextView)findViewById(R.id.dishid);
Dish_Name1 = (TextView)findViewById(R.id.dishname);
Price1 = (TextView)findViewById(R.id.price);
Type_ID1 = (TextView)findViewById(R.id.typeid);
Url1 = (ImageView)findViewById(R.id.xqdishurl);
Dish_ID1.setText(Dish_ID);
Type_ID1.setText(Type_ID);
Dish_Name1.setText(Dish_Name);
Price1.setText(Price);
gouwuche.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stu
String price=null;
String dishname=null;
String DishId=null;
// String dish=null;
String type=null;
String num=null;
price= Price1.getText().toString();
dishname=Dish_Name1.getText().toString();
type=Type_ID1.getText().toString();
Global global=new Global();
String userid=global.getUserName();
DishId=Dish_ID ;
num=num1.getText().toString();
final Map<String, String> gouwucheinfo = new HashMap<String, String>();
gouwucheinfo.put("Price", price);
gouwucheinfo.put("Dish_Name", dishname);
gouwucheinfo.put("Dish_ID", DishId);
gouwucheinfo.put("Type", type);
gouwucheinfo.put("User_ID", userid);
gouwucheinfo.put("num", num);
try {
new Thread(new Runnable() {
public void run() {
try {
Androidgouwuche(SERVER_URL, gouwucheinfo);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
see.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Global global=new Global();
String userid=global.getUserName();
final Map<String, String> carinfo = new HashMap<String, String>();
carinfo.put("User_ID", userid);
try {
new Thread(new Runnable() {
public void run() {
try {
SeeCar(SERVER_URL1, carinfo);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}).start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
private void Androidgouwuche(String SERVER_URL, Map<String, String> param)
throws Exception {
String dishname1=param.get("Dish_Name");
String username1=param.get("User_ID");
String price1=param.get("Price");
String Dish_ID=param.get("Dish_ID");
String type=param.get("Type");
String num=param.get("num");
String newurl = SERVER_URL + "&" + "Dish_Name=" +dishname1+ "&" + "User_ID="
+username1+ "&" + "Price="+price1+ "&" + "Dish_ID="+Dish_ID+ "&"+"Type_ID="+type+ "&"+"num="+num;
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(newurl);
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
// Toast.makeText(MainActivity.this, "连接成功",Toast.LENGTH_SHORT).show();
}
HttpEntity entity = response.getEntity();
String json = EntityUtils.toString(entity, "utf-8");
mHandler.sendMessage(mHandler.obtainMessage(1, json));
}
private void SeeCar(String SERVER_URL1, Map<String, String> param1) throws Exception {
String username1=param1.get("User_ID");
String newurl = SERVER_URL1 + "&" +"User_ID="+username1;
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(newurl);
HttpResponse response = client.execute(get);
if (response.getStatusLine().getStatusCode() == 200) {
// Toast.makeText(MainActivity.this, "连接成功",Toast.LENGTH_SHORT).show();
}
HttpEntity entity = response.getEntity();
String json = EntityUtils.toString(entity, "utf-8");
mHandler1.sendMessage(mHandler1.obtainMessage(1, json));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.xiangqing, menu);
return true;
}
}。

相关文档
最新文档