Skip to content

Commit

Permalink
hzuapps#2 hzuapps#42 第二次作业
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouchenghai committed Jun 16, 2017
1 parent f175bda commit dbd022d
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package edu.androidlabs.homeworks.Net1414080903113;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.administrator.studentjob.R;

public class Net1414080903113AddActivity extends AppCompatActivity {

EditText etName;
EditText etSalary;
EditText etTime;
EditText etLocation;

Button bt;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1414080903113_add);
etName= (EditText) findViewById(R.id.et_name);
etSalary= (EditText) findViewById(R.id.et_salary);
etTime= (EditText) findViewById(R.id.et_time);
etLocation= (EditText) findViewById(R.id.et_location);
bt= (Button) findViewById(R.id.bt_submit);
bt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Net1414080903113JobInfo net1414080903113JobInfo =new Net1414080903113JobInfo();
net1414080903113JobInfo.setName(etName.getText().toString());
net1414080903113JobInfo.setLocation(etLocation.getText().toString());
net1414080903113JobInfo.setOccurTime(etTime.getText().toString());
net1414080903113JobInfo.setSalary(etSalary.getText().toString());
save(net1414080903113JobInfo);
}
});

}

public void save(Net1414080903113JobInfo bean){
SQLiteOpenHelper helper=new Net1414080903113MySQLiteOpenHelper(this);
SQLiteDatabase db=helper.getWritableDatabase();
ContentValues values=new ContentValues();
values.put("name",bean.getName());
values.put("salary",bean.getSalary());
values.put("time",bean.getOccurTime());
values.put("location",bean.getLocation());
db.insert("job",null,values);
db.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package edu.androidlabs.homeworks.Net1414080903113;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.example.administrator.studentjob.R;

public class Net1414080903113MainActivity extends AppCompatActivity {


Button btJson;
Button btAdd;
Button btQuery;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1414080903113_main);
btAdd= (Button) findViewById(R.id.bt_add);
btJson= (Button) findViewById(R.id.bt_json);
btQuery= (Button) findViewById(R.id.bt_query);
btAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Intent(Net1414080903113MainActivity.this,Net1414080903113AddActivity.class);
}
});
btQuery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Intent(Net1414080903113MainActivity.this,Net1414080903113ListInfoActivity.class);
}
});
btJson.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Intent(Net1414080903113MainActivity.this,Net1414080903113ShowJsonActivity.class);
}
});
}
}

0 comments on commit dbd022d

Please sign in to comment.