Li Tianhong 3 years ago
parent 13c0def691
commit f5a1bb7aba

@ -24,7 +24,7 @@
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/fragment_my.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment1.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment2.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment3.xml" value="0.18489583333333334" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/my_fragment3.xml" value="0.1" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/pickup.xml" value="0.5" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/tab1.xml" value="0.10235507246376811" />
<entry key="..\:/shijianer/xcr_se/src/Logistics/app/src/main/res/layout/top.xml" value="0.3717105263157895" />

@ -24,6 +24,7 @@ public class goodDao {
Connection connection = DBOpenHelper.getConn();
int msg = 0;
try{
String sql = "select * from goods where id = ?";
@ -83,4 +84,36 @@ public class goodDao {
}
return msg;
}
public boolean delete(String pickupcode){
Connection connection = DBOpenHelper.getConn();
try{
String sql = "delete from goods where id = ?";
if(connection != null){
PreparedStatement ps = connection.prepareStatement(sql);
if(ps != null){
Log.e(TAG, "pickupcode: " + pickupcode);
ps.setString(1,pickupcode);
ps.executeUpdate();
connection.close();
ps.close();
return true;
}else{
Log.e(TAG, "ps is null");
return false;
}
}else{
Log.e(TAG, "connection is null");
return false;
}
}catch(Exception e){
e.printStackTrace();
Log.d(TAG, "delete bug" + e.getMessage());
}
return false;
}
}

@ -29,8 +29,7 @@ public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(MainActivity.this, MenuActivity.class);
startActivity(intent);
Button loginButton = (Button) this.findViewById(R.id.LoginButton);
Button signUpButton = (Button) this.findViewById(R.id.SignUpButton);
@ -68,8 +67,9 @@ public class MainActivity extends Activity {
if(msg == 1){
User owner = userDao.findUser(userName.getText().toString().trim());
Intent intent = new Intent(MainActivity.this, MenuActivity.class);
intent.putExtra("name", owner.getPhoneNum());
intent.putExtra("user", owner.getPhoneNum());
startActivity(intent);
finish();
}
}
}.start();

@ -35,7 +35,7 @@ public class MenuActivity extends AppCompatActivity implements View.OnClickListe
bindView();
Intent intent = getIntent();
owner = intent.getStringExtra("name");
owner = intent.getStringExtra("user");
selectTab(0);
}

@ -21,6 +21,7 @@ import android.widget.Toast;
import androidx.annotation.Nullable;
import com.example.logistics.R;
import com.example.logistics.dao.goodDao;
import com.example.logistics.dao.operationDao;
import com.example.logistics.dao.userDao;
import com.example.logistics.entity.User;
@ -91,33 +92,52 @@ public class MyFragment2 extends Fragment implements View.OnClickListener{
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(mContext, "取件成功", Toast.LENGTH_LONG).show();
String pickupcode = PickUpCode.getText().toString().trim();
String phonenum = PhoneNum.getText().toString().trim();
Log.d("onclick", "123");
String QR_pickup = result.split(" ")[0];
String QR_phone = result.split(" ")[1];
if (pickupcode.equals(QR_pickup) && pickupcode.equals(QR_phone)) {
Toast.makeText(mContext, "取件成功", Toast.LENGTH_LONG).show();
if (pickupcode.equals(QR_pickup) && phonenum.equals(QR_phone)) {
new Thread() {
@Override
public void run() {
int msg = 0;
operationDao operationDao = new operationDao();
goodDao goodDao = new goodDao();
Bundle bundle = getArguments();
String user = bundle.getString("user");
boolean flag = operationDao.add(pickupcode, user);
boolean flag1 = operationDao.add(pickupcode, user);
boolean flag2 = goodDao.delete(pickupcode);
boolean flag = flag1 & flag2;
if (flag) {
Log.d("add", "success");
} else {
Log.d("add", "failed");
msg = 1;
}
hand1.sendEmptyMessage(msg);
}
}.start();
} else {
Toast.makeText(mContext, "取件失败", Toast.LENGTH_LONG).show();
}
}
});
}
@SuppressLint("HandlerLeak")
final Handler hand1 = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == 1) {
Toast.makeText(mContext, "取件成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mContext, "取件失败", Toast.LENGTH_SHORT);
}
}
};
}

@ -1,16 +1,28 @@
package com.example.logistics.ui;
import androidx.fragment.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.example.logistics.R;
import org.w3c.dom.Text;
public class MyFragment3 extends Fragment implements View.OnClickListener{
TextView tv_waiting;
TextView tv_history;
TextView tv_exit;
Context mContext;
public MyFragment3(){
}
@ -20,12 +32,35 @@ public class MyFragment3 extends Fragment implements View.OnClickListener{
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.my_fragment3,container,false);
tv_waiting = (TextView) view.findViewById(R.id.waiting);
tv_history = (TextView) view.findViewById(R.id.history);
tv_exit = (TextView) view.findViewById(R.id.exit);
tv_waiting.setOnClickListener(this);
tv_history.setOnClickListener(this);
tv_exit.setOnClickListener(this);
mContext = getActivity();
return view;
}
@Override
public void onClick(View view) {
switch(view.getId()){
case R.id.waiting:
Toast.makeText(mContext, "waiting", Toast.LENGTH_SHORT).show();
break;
case R.id.history:
Toast.makeText(mContext, "history", Toast.LENGTH_SHORT).show();
break;
case R.id.exit:
Toast.makeText(mContext, "exit", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mContext, MainActivity.class);
startActivity(intent);
getActivity().finish();
break;
}
}
}

@ -3,12 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
android:padding="5dp"
android:background="#F5F5F5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<Button

@ -1,14 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<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_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5F5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
android:gravity="center">
<ImageView
android:id="@+id/userLogo"
android:layout_width="match_parent"
android:layout_height="160dp"
android:layout_marginTop="100dp"
android:src="@drawable/logo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/waiting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:text="待取件 >"
android:padding="15dp"
android:clickable="true"
android:textSize="24dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:id="@+id/history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:text="历史取件 >"
android:padding="15dp"
android:clickable="true"
android:textSize="24dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="vertical">
<TextView
android:id="@+id/exit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="50sp"
android:text="frag3" />
</LinearLayout>
android:background="#ffffff"
android:text="退出登录 >"
android:padding="15dp"
android:clickable="true"
android:textSize="24dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Loading…
Cancel
Save