1.今日收获内容
按班级查出
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="wrap_content" android:layout_height="46dp" android:text="班级:" android:textSize="30dp" /> <EditText android:id="@+id/edit_66" android:layout_width="match_parent" android:layout_height="55dp" android:hint="请输入班级"/> <Button android:id="@+id/button6" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> <TextView android:id="@+id/nn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="15dp"/> </LinearLayout>
package com.example.myapplication2; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.EditText; import android.widget.TextView; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import java.text.SimpleDateFormat; import java.util.Date; public class chakan extends AppCompatActivity implements View.OnClickListener{ private DatabaseHelper dbHelper; private DatabaseHelper2 dbHelper2; private EditText editText66; private TextView tv; int m=0; int n1=0,n2=0,n3=0; String k=""; double j; String h=""; protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chakan2); tv=(TextView)findViewById(R.id.nn); editText66 = (EditText) findViewById(R.id.edit_66); m3(); } private void m3() { findViewById(R.id.button6).setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.button6://执行按钮1 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");// HH:mm:ss //获取当前时间 Date date = new Date(System.currentTimeMillis()); k=simpleDateFormat.format(date); String mm=editText66.getText().toString(); dbHelper2=new DatabaseHelper2(this,"TTList2.db",null,3); SQLiteDatabase db=dbHelper2.getWritableDatabase(); Cursor cursor=db.query("TTList2",null,"班级=?",new String[]{mm}, null,null,null);//读取数据库里面专业是软件工程的所有信息 if(cursor.moveToFirst()){ do{ String name=cursor.getString(cursor.getColumnIndex("姓名")); dbHelper=new DatabaseHelper(this,"TTList3.db",null,3); SQLiteDatabase db2=dbHelper.getWritableDatabase(); Cursor cursor2 = db2.query("TTList3", null, "姓名=?", new String[]{name}, null, null, null);//读取数据库所有信息 // Cursor cursor=db.query("tt",null,"专业=?",new String[]{"软件工程"}, //null,null,null);//读取数据库里面专业是软件工程的所有信息 if(cursor2.moveToFirst()){ do{ Log.i("chakan","ss"); String time=cursor2.getString(cursor2.getColumnIndex("日期时间")); String str = time.substring(0, time.indexOf(" ")); Log.i("chakan",str); Log.i("chakan",k); if(str.equals(k)) { String tt = cursor2.getString(cursor2.getColumnIndex("体温")); j = Double.parseDouble(tt); n1++; if (j < 37.3 &&j > 35) { n2++; } else { n3++; } } }while (cursor2.moveToNext()); } cursor2.close(); m++; }while (cursor.moveToNext()); } cursor.close(); h="(体温t,35.0<t<37.3正常) "+k+" "+"一共"+String.valueOf(m)+"人 正常上报"+String.valueOf(n2)+"人,体温异常"+String.valueOf(n3)+"人,未上报体温"+String.valueOf(m-n1)+"人"; tv.setText(h);//打印信息 } } }
2.遇到的问题
班级里是否填写调出,同一个人写两次就出问题
3.明天目标
解决问题