源码简介
一个简单的仓库管理系统、适合新手学习。
源码截图
源码片段
rotected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.userregister);
name = (EditText) findViewById(R.id.usename);
pass = (EditText) findViewById(R.id.password);
passsure = (EditText) findViewById(R.id.passwordsure);
workid = (EditText) findViewById(R.id.useide);
db = new SqlHelpdemo(getApplicationContext(), "store.db", null, 1);
sDatabase = db.getWritableDatabase();
}
public void sure(View v) {
db = new SqlHelpdemo(getApplicationContext(), "store.db", null, 1);
sDatabase = db.getWritableDatabase();
if (name.getText().toString().equals("")
|| pass.getText().toString().equals("")
|| passsure.getText().toString().equals("")
|| workid.getText().toString().equals("")) {
DialogDemo.builder(UserRegister.this, "错误信息", "请填写完整信息!");
} else if (!pass.getText().toString()
.equals(passsure.getText().toString())) {
DialogDemo.builder(UserRegister.this, "错误信息", "两次密码输入不一致!");
} else {
String ename = name.getText().toString();
String epass = pass.getText().toString();
String eid = workid.getText().toString();
// 查询语句
String selectStr = "select username from user_info";
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
select_cursor.moveToFirst();
String string = null;
do {
try {
string = select_cursor.getString(0);
} catch (Exception e) {
// TODO: handle exception
string = "";
}
if (string.equals(ename)) {
DialogDemo.builder(UserRegister.this, "错误信息",
"用户名已存在,请另设用户名");
select_cursor.close();
break;
}
} while (select_cursor.moveToNext());
// 没有重名注册开始
if (!string.equals(ename)) {
// 定义ID
int id = 0;
String select = "select max(_id) from user_info";
Cursor seCursor = sDatabase.rawQuery(select, null);
try {
seCursor.moveToFirst();
id = Integer.parseInt(seCursor.getString(0));
id += 1;
} catch (Exception e) {
// TODO: handle exception
id = 0;
}
sDatabase.execSQL("insert into user_info values('" + id + "','"
+ ename + "','" + epass + "','"
+ eid + "')");
DialogDemo.builder(UserRegister.this, "提示", "注册成功,请返回登录界面登录");
seCursor.close();
}
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
- 55.
- 56.
- 57.
- 58.
- 59.
- 60.
- 61.
- 62.
- 63.
- 64.
- 65.
- 66.
- 67.
- 68.
- 69.
- 70.
- 71.
- 72.
- 73.
- 74.
- 75.
- 76.
- 77.
- 78.