Merge pull request '添加功能:注册' (#7) from Litianhong_branch into dev
commit
2014c1e00e
@ -0,0 +1,84 @@
|
|||||||
|
package com.example.logistics.dao;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.example.logistics.tools.DBOpenHelper;
|
||||||
|
import com.example.logistics.tools.MD5Utils;
|
||||||
|
import com.example.logistics.ui.MainActivity;
|
||||||
|
import com.example.logistics.ui.MenuActivity;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class goodDao {
|
||||||
|
|
||||||
|
private static final String TAG = "goodDao";
|
||||||
|
|
||||||
|
public int search(String id, String phonenum, Context context){
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
|
Connection connection = DBOpenHelper.getConn();
|
||||||
|
|
||||||
|
int msg = 0;
|
||||||
|
try{
|
||||||
|
String sql = "select * from goods where id = ?";
|
||||||
|
|
||||||
|
if(connection != null){
|
||||||
|
PreparedStatement ps = connection.prepareStatement(sql);
|
||||||
|
if(ps != null){
|
||||||
|
Log.e(TAG, "id: " + id);
|
||||||
|
ps.setInt(1,Integer.parseInt(id));
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
int count = rs.getMetaData().getColumnCount();
|
||||||
|
while(rs.next()){
|
||||||
|
for(int i = 1; i <= count; i++){
|
||||||
|
String field = rs.getMetaData().getColumnName(i);
|
||||||
|
map.put(field, rs.getString(field));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection.close();
|
||||||
|
ps.close();
|
||||||
|
if(map.size() != 0){
|
||||||
|
StringBuilder s = new StringBuilder();
|
||||||
|
for(String key:map.keySet()){
|
||||||
|
if(key.equals("phonenum")){
|
||||||
|
if(phonenum.equals(map.get(key))){
|
||||||
|
msg = 1; //phonenum correct
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle("快件位置");
|
||||||
|
builder.setMessage("\n第 "+ map.get("shelfnum")+ " 号货架\n第 " + map.get("floornum")+ " 层");
|
||||||
|
Looper.prepare();
|
||||||
|
builder.show();
|
||||||
|
Looper.loop();
|
||||||
|
}else{
|
||||||
|
msg = 2; //phonenum incorrect
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.e(TAG, "result is null");
|
||||||
|
msg = 3; //result is null
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.e(TAG, "ps is null");
|
||||||
|
msg = 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
Log.e(TAG, "connection is null");
|
||||||
|
msg = 0;
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.d(TAG, "search bug: " + e.getMessage());
|
||||||
|
msg = 0;
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.example.logistics.entity;
|
||||||
|
|
||||||
|
public class Good {
|
||||||
|
private int id;
|
||||||
|
private String phoneNum;
|
||||||
|
private int shelfNum;
|
||||||
|
private int floorNum;
|
||||||
|
private String time;
|
||||||
|
|
||||||
|
public Good(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId(){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhoneNum(){
|
||||||
|
return phoneNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoneNum(String phoneNum){
|
||||||
|
this.phoneNum = phoneNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShelfNum(){
|
||||||
|
return shelfNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShelfNum(int shelfNum){
|
||||||
|
this.shelfNum = shelfNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFloorNum(){
|
||||||
|
return floorNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFloorNum(int floorNum){
|
||||||
|
this.floorNum = floorNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTime(){
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
public void setTime(String time){
|
||||||
|
this.time = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#FFFFFF" />
|
||||||
|
<corners
|
||||||
|
android:bottomLeftRadius="5dp"
|
||||||
|
android:bottomRightRadius="5dp"
|
||||||
|
android:topLeftRadius="5dp"
|
||||||
|
android:topRightRadius="5dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="@color/black" />
|
||||||
|
</shape>
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
|
||||||
|
<corners android:radius="0dp" /> <!-- 设置圆角弧度 -->
|
||||||
|
<solid android:color="@color/blue" /> <!-- 设置背景颜色 -->
|
||||||
|
<size
|
||||||
|
android:width="160dp"
|
||||||
|
android:height="160dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="0dp"
|
||||||
|
android:color="#fff" />
|
||||||
|
</shape>
|
@ -1,28 +1,71 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:padding="5dp">
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/btn_one"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#F5F5F5"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:layout_marginTop="100dp"
|
||||||
android:text="显示第一个消息"/>
|
android:orientation="vertical">
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/btn_two"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
style="@style/InputBoxStyle">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Sea_PickUpCode"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:hint="输入取件码"
|
||||||
android:text="第二个显示信息"/>
|
android:padding="15dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textSize="24dp"
|
||||||
|
style="@style/EditTextStyle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<LinearLayout
|
||||||
android:id="@+id/btn_three"
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
style="@style/InputBoxStyle">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Sea_PhoneNum"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:hint="输入手机尾号后四位"
|
||||||
android:text="第三个显示信息"/>
|
android:padding="15dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textSize="24dp"
|
||||||
|
style="@style/EditTextStyle"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/Sea_Button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/button_shape"
|
||||||
|
android:text="查询"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="38dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
Loading…
Reference in new issue