• 个人冲刺(五)——体温上报app(一阶段)


    任务:完成了体温录入、体温记录删除、体温修改以及历史记录查询操作

    体温录入

    public void insertDB(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"amydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            ContentValues contentvalues=new ContentValues();
            text1=(EditText)findViewById(R.id.tv_text1);
            text2=(EditText)findViewById(R.id.tv_text2);
            text3=(EditText)findViewById(R.id.tv_text3);
            text4=(EditText)findViewById(R.id.tv_text4);
            contentvalues.put("name",text1.getText().toString());
            contentvalues.put("dateandtime",text2.getText().toString());
            contentvalues.put("address",text4.getText().toString());
            contentvalues.put("wendu",text3.getText().toString());
            long flag=sqldb.insert("personwendu",null,contentvalues);
            Toast.makeText(this,"数据加入成功"+flag,Toast.LENGTH_LONG).show();
        }

    体温记录删除

    public void deleteDate(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"mydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            int flag=sqldb.delete("person","id=1",null);
            Toast.makeText(this,"已有"+flag+"条数据删除",Toast.LENGTH_LONG).show();
        }

    体温修改

    public void updateData(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"mydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            ContentValues contentvalues=new ContentValues();
            contentvalues.put("name","明明");
            contentvalues.put("age","12");
            int flag=sqldb.update("person",contentvalues,"name=?",new String[]{"李明"});
            Toast.makeText(this,"已有"+flag+"条数据修改",Toast.LENGTH_LONG).show();
        }

    历史记录查询

     public void queryData(View view)
        {
            MyDBHelper mydbh=new MyDBHelper(this,"amydb.db",1);
            SQLiteDatabase sqldb=mydbh.getReadableDatabase();
            Cursor cursor=sqldb.rawQuery("select * from personwendu",null);
            String str="";
            if(cursor.moveToFirst())
            {
                do{
                    String name=cursor.getString(cursor.getColumnIndex("name"));
                    String dateandtime=cursor.getString(cursor.getColumnIndex("dateandtime"));
                    String address=cursor.getString(cursor.getColumnIndex("address"));
                    String wendu=cursor.getString(cursor.getColumnIndex("wendu"));
                    str=str+name+"|"+dateandtime+"|"+wendu+"
    "+address+"
    ";
                }while(cursor.moveToNext());
            }
            AlertDialog.Builder builder=new AlertDialog.Builder(this);
            builder.setTitle("历史记录").setIcon(R.mipmap.ic_launcher).setMessage(str)
                    .setPositiveButton("ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                        }
                    });
            AlertDialog ad=builder.create();
            ad.show();
        }
  • 相关阅读:
    Delphi开发组件
    WPF界面开发.NET环境该如何配置?不知道VS版本支持的看过来
    Map控件是如何支持矢量切片的?DevExpress WPF界面开发者必看!
    数据可视化新方式,SankeyDiagramControl类的使用你不能错过!(Part 1)
    VCL界面开发工具!DevExpress VCL v20.1.7全新出发
    如何使用自动生成的序列创建3D图表?DevExpress WPF有妙招(Part 3)
    如何使用Kendo UI在Vue.js中轻松构建UI组件?
    php结合redis实现高并发下的抢购、秒杀功能
    书写高质量SQL的30条建议
    php 通过openresty搭载负载均衡
  • 原文地址:https://www.cnblogs.com/zyj3955/p/14869646.html
Copyright © 2020-2023  润新知