查看学生受捐款记录信息

my
盛洁 5 years ago
parent 65a735bea0
commit ab759861df

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

@ -14,11 +14,12 @@ import java.util.ArrayList;
import hunnu.sj.raise_money.record.Record; import hunnu.sj.raise_money.record.Record;
import hunnu.sj.raise_money.donate_record.DonateRecordAdapter; 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 ArrayList<Record> records = new ArrayList<>();
private ListView lv_record; private ListView lv_record;
private DonateRecordAdapter recordAdapter; private DonateRecordAdapter recordAdapter;
private String username; private String username;
private long stu_id;
private Handler mhandler = new Handler(){ private Handler mhandler = new Handler(){
@Override @Override
public void handleMessage(@NonNull Message msg) { public void handleMessage(@NonNull Message msg) {
@ -33,14 +34,16 @@ public class BrowseRecordActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse_record); setContentView(R.layout.activity_browse_record);
Intent intent = getIntent(); Intent intent = getIntent();
int flags = intent.getIntExtra("flags",-1);
username = intent.getStringExtra("username"); username = intent.getStringExtra("username");
recordAdapter = new DonateRecordAdapter(this,records); recordAdapter = new DonateRecordAdapter(this,records);
lv_record = findViewById(R.id.lv_browse_denate_record); lv_record = findViewById(R.id.lv_browse_denate_record);
lv_record.setAdapter(recordAdapter); lv_record.setAdapter(recordAdapter);
new BrowseRecordThread().start(); new BrowseDonateRecordThread().start();
} }
class BrowseRecordThread extends Thread{ class BrowseDonateRecordThread extends Thread{
@Override @Override
public void run() { public void run() {
Message msg =mhandler.obtainMessage(); Message msg =mhandler.obtainMessage();
@ -49,4 +52,5 @@ public class BrowseRecordActivity extends AppCompatActivity {
mhandler.sendMessage(msg); 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); ResultSet rs = sttmt.executeQuery(sql);
while (rs.next()){ while (rs.next()){
News news= new News(); News news= new News();
news.setId(rs.getLong("id"));
news.setTitle(rs.getNString("name")); news.setTitle(rs.getNString("name"));
news.setDes(rs.getNString("descri")); news.setDes(rs.getNString("descri"));
news.setHead_icon(ContextCompat.getDrawable(context, R.drawable.ic_launcher_background)); 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); uService.getDonateRecords(recordlist,username);
return 1; 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.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@ -136,9 +135,11 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
News news = (News)parent.getItemAtPosition(position); News news = (News)parent.getItemAtPosition(position);
String title=news.getTitle(); String title=news.getTitle();
String des=news.getDes(); String des=news.getDes();
long stu_id = news.getId();
Intent intent = new Intent(this,NewsContentActivity.class); Intent intent = new Intent(this,NewsContentActivity.class);
intent.putExtra("news_title",title); intent.putExtra("news_title",title);
intent.putExtra("news_des",des); intent.putExtra("news_des",des);
intent.putExtra("stu_id",stu_id);
startActivity(intent); startActivity(intent);
} }
@ -172,8 +173,9 @@ public class MainActivity extends AppCompatActivity implements AdapterView.OnIte
} }
public void onBrowseDonateRecord(MenuItem item){ public void onBrowseDonateRecord(MenuItem item){
Intent intent = new Intent(this,BrowseRecordActivity.class); Intent intent = new Intent(this, BrowseDonateRecordActivity.class);
String username = user.getName(); String username = user.getName();
intent.putExtra("flags",0);//读取用户的捐助信息
intent.putExtra("username",username); intent.putExtra("username",username);
startActivity(intent); startActivity(intent);
} }

@ -11,24 +11,28 @@ import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
public class NewsContentActivity extends AppCompatActivity{ public class NewsContentActivity extends AppCompatActivity{
public static void actionStart(Context context, String newsTitle, String newsContent) { private long stu_id;
Intent intent = new Intent(context, NewsContentActivity.class); // public static void actionStart(Context context, String newsTitle, String newsContent) {
intent.putExtra("news_title", newsTitle); // Intent intent = new Intent(context, NewsContentActivity.class);
intent.putExtra("news_content", newsContent); // intent.putExtra("news_title", newsTitle);
context.startActivity(intent); // intent.putExtra("news_content", newsContent);
} // context.startActivity(intent);
// }
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
Log.v("news_title","here"); // Log.v("news_title","here");
setContentView(R.layout.news_content); setContentView(R.layout.news_content);
String newsTitle = getIntent().getStringExtra("news_title"); // 获取传入的新闻标题 String newsTitle = getIntent().getStringExtra("news_title"); // 获取传入的新闻标题
String newsContent = getIntent().getStringExtra("news_content"); // 获取传入的新闻内容 String newsContent = getIntent().getStringExtra("news_content"); // 获取传入的新闻内容
stu_id = getIntent().getLongExtra("stu_id",0);
NewsContentFragment newsContentFragment = (NewsContentFragment) NewsContentFragment newsContentFragment = (NewsContentFragment)
getFragmentManager().findFragmentById(R.id.news_content_fragment); getFragmentManager().findFragmentById(R.id.news_content_fragment);
newsContentFragment.refresh(newsTitle, newsContent); // 刷新NewsContentFragment界面 newsContentFragment.refresh(newsTitle, newsContent); // 刷新NewsContentFragment界面
onToDonate(); onToDonate();
onBrowseRecord();
} }
public void onToDonate( ){ public void onToDonate( ){
Button button1 = (Button) findViewById(R.id.button);//id后面为上方button的id 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; import android.graphics.drawable.Drawable;
public class News {//主界面浏览的信息的类 public class News {//主界面浏览的信息的类
private long id;
private String title; private String title;
private String des; private String des;
private Drawable head_icon; private Drawable head_icon;
@ -24,4 +25,12 @@ public class News {//主界面浏览的信息的类
public void setHead_icon(Drawable head_icon) { public void setHead_icon(Drawable head_icon) {
this.head_icon = 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_icon.setImageDrawable(news.getHead_icon());
item_title.setText(news.getTitle()); item_title.setText(news.getTitle());
item_des.setText(news.getDes()); item_des.setText(news.getDes());
return view; return view;
} }
} }

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

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

Loading…
Cancel
Save