forked from hzuapps/android-labs-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92c4fff
commit f26db92
Showing
12 changed files
with
368 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 61 additions & 3 deletions
64
...in/java/edu/hzuapps/androidlabs/homeworks/net1414080903135/Net1414080903135AddObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,71 @@ | ||
package edu.hzuapp.androidlabs.homeworks.net1414080903135; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.content.ContentValues; | ||
import android.content.Intent; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
public class Net1414080903135AddObject extends AppCompatActivity { | ||
import edu.hzuapp.androidlabs.R; | ||
|
||
public class Net1414080903135AddObject extends AppCompatActivity implements View.OnClickListener { | ||
|
||
private EditText ccourse; | ||
private EditText cteacher; | ||
private EditText cperiod; | ||
private EditText ccredit; | ||
private EditText cclassroom; | ||
private WorkDatabaseHelper dbHelper; | ||
private String mcourse; | ||
private String mteacher; | ||
private String mperiod; | ||
private String mcredit; | ||
private String mclassroom; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903135_add_object); | ||
dbHelper=new WorkDatabaseHelper(this,"Test.db",null,2); | ||
Button msubmit = (Button) findViewById(R.id.submit); | ||
msubmit.setOnClickListener(this); | ||
ccourse = (EditText) findViewById(R.id.vcourse); | ||
cteacher = (EditText) findViewById(R.id.vteacher); | ||
cperiod = (EditText) findViewById(R.id.vperiod); | ||
ccredit = (EditText) findViewById(R.id.vcredit); | ||
cclassroom = (EditText) findViewById(R.id.vclassroom); | ||
} | ||
|
||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.submit: | ||
mcourse = ccourse.getText().toString().trim(); | ||
mteacher = cteacher.getText().toString().trim(); | ||
mperiod = cperiod.getText().toString().trim(); | ||
mcredit = ccredit.getText().toString().trim(); | ||
mclassroom = cclassroom.getText().toString().trim(); | ||
|
||
insert(mcourse,mteacher,mperiod,mcredit,mperiod);// 插入课程信息 | ||
Intent intent3=new Intent(this,Net1414080903135AddObject.class); | ||
this.finish(); | ||
startActivity(intent3); | ||
} | ||
|
||
} | ||
|
||
public void insert(String mcourse,String mteacher,String mperiod,String mcredit,String mclassroom){ | ||
SQLiteDatabase db=dbHelper.getWritableDatabase(); | ||
ContentValues values=new ContentValues(); | ||
values.put("course",mcourse); | ||
values.put("teacher",mteacher); | ||
values.put("period",mperiod); | ||
values.put("credit",mcredit); | ||
values.put("classroom",mclassroom); | ||
db.insert("work",null,values); | ||
Toast.makeText(this,"成功提交课程",Toast.LENGTH_SHORT).show(); | ||
values.clear(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ava/edu/hzuapps/androidlabs/homeworks/net1414080903135/Net1414080903135AdminActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package edu.hzuapp.androidlabs.homeworks.net1414080903135; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import edu.hzuapp.androidlabs.R; | ||
|
||
public class Net1414080903135AdminActivity extends AppCompatActivity implements View.OnClickListener{ | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903135_admin); | ||
Button button = (Button) findViewById(R.id.add); | ||
button.setOnClickListener(this); | ||
Button change1 = (Button) findViewById(R.id.change); | ||
change1.setOnClickListener(this); | ||
} | ||
|
||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.add: | ||
/*跳转添加课表*/ | ||
Intent intent = new Intent(this,Net1414080903135AddObject.class); | ||
startActivity(intent); | ||
/*跳转修改课表*/ | ||
case R.id.change: | ||
Intent intento = new Intent(this,Net1414080903135ChangeActivity.class); | ||
startActivity(intento); | ||
} | ||
} | ||
} |
63 changes: 60 additions & 3 deletions
63
...va/edu/hzuapps/androidlabs/homeworks/net1414080903135/Net1414080903135ChangeActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,70 @@ | ||
package edu.hzuapp.androidlabs.homeworks.net1414080903135; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.content.ContentValues; | ||
import android.content.Intent; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import edu.hzuapp.androidlabs.R; | ||
|
||
public class Net1414080903135ChangeActivity extends AppCompatActivity { | ||
public class Net1414080903135ChangeActivity extends AppCompatActivity implements View.OnClickListener { | ||
|
||
private EditText ccourse; | ||
private EditText cteacher; | ||
private EditText cperiod; | ||
private EditText ccredit; | ||
private EditText cclassroom; | ||
private WorkDatabaseHelper dbHelper; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903135_change); | ||
dbHelper=new WorkDatabaseHelper(this,"Test.db",null,2); | ||
Button msubmit = (Button) findViewById(R.id.submit); | ||
msubmit.setOnClickListener(this); | ||
ccourse = (EditText) findViewById(R.id.vcourse); | ||
cteacher = (EditText) findViewById(R.id.vteacher); | ||
cperiod = (EditText) findViewById(R.id.vperiod); | ||
ccredit = (EditText) findViewById(R.id.vcredit); | ||
cclassroom = (EditText) findViewById(R.id.vclassroom); | ||
} | ||
|
||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.submit: | ||
String mcourse = ccourse.getText().toString().trim(); | ||
String mteacher = cteacher.getText().toString().trim(); | ||
String mperiod = cperiod.getText().toString().trim(); | ||
String mcredit = ccredit.getText().toString().trim(); | ||
String mclassroom = cclassroom.getText().toString().trim(); | ||
|
||
update(mcourse,mteacher,mperiod,mcredit,mclassroom);// 插入课程信息 | ||
Intent intent3=new Intent(this,Net1414080903135AddObject.class); | ||
this.finish(); | ||
startActivity(intent3); | ||
} | ||
|
||
} | ||
|
||
public void update(String mcourse,String mteacher,String mperiod,String mcredit,String mclassroom){ | ||
SQLiteDatabase db=dbHelper.getWritableDatabase(); | ||
ContentValues values=new ContentValues(); | ||
values.put("course",mcourse); | ||
values.put("teacher",mteacher); | ||
values.put("period",mperiod); | ||
values.put("credit",mcredit); | ||
values.put("classroom",mclassroom); | ||
db.update("work",values,"teacher=?",new String[]{mteacher}); | ||
// int course=db.update("work",values,"period=?",new String[]{mperiod}); | ||
// int course=db.update("work",values,"credit=?",new String[]{mcredit}); | ||
// int course=db.update("work",values,"classroom=?",new String[]{mclassroom}); | ||
Toast.makeText(this,"成功修改课程",Toast.LENGTH_SHORT).show(); | ||
values.clear(); | ||
} | ||
|
||
} |
Oops, something went wrong.