查看学生受捐款记录信息

my
盛洁 5 years ago
parent 65a735bea0
commit ab759861df

@ -11,8 +11,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".DonateActivity"></activity>
<activity android:name=".BrowseRecordActivity" />
<activity android:name=".BrowseDonatedRecordActivity"></activity>
<activity android:name=".DonateActivity" />
<activity android:name=".BrowseDonateRecordActivity" />
<activity android:name=".NewsContentActivity" />
<activity android:name=".RegiteActivity" />
<activity android:name=".SignInActivity">

@ -14,11 +14,12 @@ import java.util.ArrayList;
import hunnu.sj.raise_money.record.Record;
import hunnu.sj.raise_money.donate_record.DonateRecordAdapter;
public class BrowseRecordActivity extends AppCompatActivity {
public class BrowseDonateRecordActivity extends AppCompatActivity {
private ArrayList<Record> records = new ArrayList<>();
private ListView lv_record;
private DonateRecordAdapter recordAdapter;
private String username;
private long stu_id;
private Handler mhandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
@ -33,14 +34,16 @@ public class BrowseRecordActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse_record);
Intent intent = getIntent();
int flags = intent.getIntExtra("flags",-1);
username = intent.getStringExtra("username");
recordAdapter = new DonateRecordAdapter(this,records);
lv_record = findViewById(R.id.lv_browse_denate_record);
lv_record.setAdapter(recordAdapter);
new BrowseRecordThread().start();
new BrowseDonateRecordThread().start();
}
class BrowseRecordThread extends Thread{
class BrowseDonateRecordThread extends Thread{
@Override
public void run() {
Message msg =mhandler.obtainMessage();
@ -49,4 +52,5 @@ public class BrowseRecordActivity extends AppCompatActivity {
mhandler.sendMessage(msg);
}
}
}

@ -0,0 +1,54 @@
package hunnu.sj.raise_money;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ListView;
import java.util.ArrayList;
import hunnu.sj.raise_money.donated_record.DonatedRecordAdapter;
import hunnu.sj.raise_money.record.Record;
public class BrowseDonatedRecordActivity extends AppCompatActivity {
private ArrayList<Record> records = new ArrayList<>();
private ListView lv_record;
private DonatedRecordAdapter donatedRecordAdapter;
private long stu_id;
private Handler mhandler = new Handler(){
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
if(msg.what==1){
donatedRecordAdapter.notifyDataSetChanged();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse_record);
Intent intent = getIntent();
stu_id = intent.getLongExtra("stu_id",0);
donatedRecordAdapter = new DonatedRecordAdapter(this,records);
lv_record = findViewById(R.id.lv_browse_denate_record);
lv_record.setAdapter(donatedRecordAdapter);
new BrowseDonateRecordThread().start();
}
class BrowseDonateRecordThread extends Thread{
@Override
public void run() {
Message msg =mhandler.obtainMessage();
int flags = InfoUtils.getDonatedRecords(records,stu_id);
msg.what = flags;
mhandler.sendMessage(msg);
}
}
}

@ -122,6 +122,7 @@ public class UserService {
ResultSet rs = sttmt.executeQuery(sql);
while (rs.next()){
News news= new News();
news.setId(rs.getLong("id"));
news.setTitle(rs.getNString("name"));
news.setDes(rs.getNString("descri"));
news.setHead_icon(ContextCompat.getDrawable(context, R.drawable.ic_launcher_background));
@ -154,4 +155,24 @@ public class UserService {
}
}
public void getDonatedRecords(ArrayList<Record> recordlist,long id){
String sql = "select * from record where id= '"+id+"'";
conn = db.getConnection();
try{
Statement sttmt = conn.createStatement();
ResultSet rs = sttmt.executeQuery(sql);
while(rs.next()){
Record record = new Record();
record.setUsername(rs.getNString("username"));
record.setTime(rs.getNString("time"));
record.setDonatemon(rs.getFloat("donatemon"));
recordlist.add(record);
}
rs.close();
sttmt.close();
}catch (SQLException e){
e.printStackTrace();
}
}
}

@ -20,4 +20,10 @@ public class InfoUtils {
uService.getDonateRecords(recordlist,username);
return 1;
}
public static int getDonatedRecords(ArrayList<Record> recordlist,long id){
UserService uService = new UserService();
uService.getDonatedRecords(recordlist,id);
return 1;
}
}

@ -2,7 +2,6 @@ package hunnu.sj.raise_money;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@ -136,9 +135,11 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
News news = (News)parent.getItemAtPosition(position);
String title=news.getTitle();
String des=news.getDes();
long stu_id = news.getId();
Intent intent = new Intent(this,NewsContentActivity.class);
intent.putExtra("news_title",title);
intent.putExtra("news_des",des);
intent.putExtra("stu_id",stu_id);
startActivity(intent);
}
@ -172,8 +173,9 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
}
public void onBrowseDonateRecord(MenuItem item){
Intent intent = new Intent(this,BrowseRecordActivity.class);
Intent intent = new Intent(this, BrowseDonateRecordActivity.class);
String username = user.getName();
intent.putExtra("flags",0);//读取用户的捐助信息
intent.putExtra("username",username);
startActivity(intent);
}

@ -11,24 +11,28 @@ import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class NewsContentActivity extends AppCompatActivity{
public static void actionStart(Context context, String newsTitle, String newsContent) {
Intent intent = new Intent(context, NewsContentActivity.class);
intent.putExtra("news_title", newsTitle);
intent.putExtra("news_content", newsContent);
context.startActivity(intent);
}
private long stu_id;
// public static void actionStart(Context context, String newsTitle, String newsContent) {
// Intent intent = new Intent(context, NewsContentActivity.class);
// intent.putExtra("news_title", newsTitle);
// intent.putExtra("news_content", newsContent);
// context.startActivity(intent);
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.v("news_title","here");
// Log.v("news_title","here");
setContentView(R.layout.news_content);
String newsTitle = getIntent().getStringExtra("news_title"); // 获取传入的新闻标题
String newsContent = getIntent().getStringExtra("news_content"); // 获取传入的新闻内容
stu_id = getIntent().getLongExtra("stu_id",0);
NewsContentFragment newsContentFragment = (NewsContentFragment)
getFragmentManager().findFragmentById(R.id.news_content_fragment);
newsContentFragment.refresh(newsTitle, newsContent); // 刷新NewsContentFragment界面
onToDonate();
onBrowseRecord();
}
public void onToDonate( ){
Button button1 = (Button) findViewById(R.id.button);//id后面为上方button的id
@ -43,4 +47,16 @@ public class NewsContentActivity extends AppCompatActivity{
});
}
public void onBrowseRecord(){
Button button = findViewById(R.id.browse_donated_btn);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(NewsContentActivity.this, BrowseDonatedRecordActivity.class);
intent.putExtra("stu_id",stu_id);
startActivity(intent);
}
});
}
}

@ -3,6 +3,7 @@ package hunnu.sj.raise_money.news;
import android.graphics.drawable.Drawable;
public class News {//主界面浏览的信息的类
private long id;
private String title;
private String des;
private Drawable head_icon;
@ -24,4 +25,12 @@ public class News {//主界面浏览的信息的类
public void setHead_icon(Drawable head_icon) {
this.head_icon = head_icon;
}
public void setId(long id) {
this.id = id;
}
public long getId() {
return id;
}
}

@ -51,7 +51,6 @@ public class NewsAdapter extends BaseAdapter {
item_icon.setImageDrawable(news.getHead_icon());
item_title.setText(news.getTitle());
item_des.setText(news.getDes());
return view;
}
}

@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BrowseRecordActivity">
tools:context=".BrowseDonateRecordActivity">
<ListView
android:id="@+id/lv_browse_denate_record"

@ -61,7 +61,7 @@
android:orientation="horizontal">
<Button
android:id="@+id/button2"
android:id="@+id/browse_donated_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="75dp"
@ -72,6 +72,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="75dp"
android:onClick="onBrowseRecord"
android:text="捐助" />
</LinearLayout>

Loading…
Cancel
Save