Android源碼之倉(cāng)庫(kù)管理
ndroid源碼之倉(cāng)庫(kù)管理,一個(gè)簡(jiǎn)單的倉(cāng)庫(kù)管理系統(tǒng)、適合新手學(xué)習(xí)。
源碼簡(jiǎn)介
一個(gè)簡(jiǎn)單的倉(cāng)庫(kù)管理系統(tǒng)、適合新手學(xué)習(xí)。
源碼截圖
源碼片段
- 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, "錯(cuò)誤信息", "請(qǐng)?zhí)顚懲暾畔ⅲ?quot;);
- } else if (!pass.getText().toString()
- .equals(passsure.getText().toString())) {
- DialogDemo.builder(UserRegister.this, "錯(cuò)誤信息", "兩次密碼輸入不一致!");
- } else {
- String ename = name.getText().toString();
- String epass = pass.getText().toString();
- String eid = workid.getText().toString();
- // 查詢語(yǔ)句
- 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, "錯(cuò)誤信息",
- "用戶名已存在,請(qǐng)另設(shè)用戶名");
- select_cursor.close();
- break;
- }
- } while (select_cursor.moveToNext());
- // 沒有重名注冊(cè)開始
- 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, "提示", "注冊(cè)成功,請(qǐng)返回登錄界面登錄");
- seCursor.close();
- }
- }
- }
- }
責(zé)任編輯:chenqingxiang
來(lái)源:
網(wǎng)絡(luò)整理