package tian.biye; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.SimpleAdapter; /** * 查询出库页面 * * @author 田志远 * */ public class Chaxunc extends Activity { private ListView listview; String id[]; String cname[]; String pname[]; String add[]; String city[]; String diqu[]; String youbian[]; String tel[]; String chuanzhen[]; String web[]; SqlHelpdemo db; int i = 0; SQLiteDatabase sDatabase = null; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.chaxunc1); setTitle("查询出库"); final AlertDialog.Builder builder = new AlertDialog.Builder(this); db = new SqlHelpdemo(getApplicationContext(), "store.db", null, 1); sDatabase = db.getWritableDatabase(); listview = (ListView) findViewById(R.id.kehulist); List<Map<String, Object>> slist = new ArrayList<Map<String, Object>>(); String selectStr = "select _id,comname,pername,tel,products,guige,danwei,danjia,num,date from chuku"; Cursor cursor = sDatabase.rawQuery(selectStr, null); cursor.moveToFirst(); int count = cursor.getCount(); id = new String[count]; cname = new String[count]; pname= new String[count]; add= new String[count]; city= new String[count]; diqu = new String[count]; youbian= new String[count]; tel= new String[count]; chuanzhen= new String[count]; web = new String[count]; do { try { id[i] = cursor.getString(0); cname[i] = cursor.getString(1); pname[i] = cursor.getString(2); add[i] = cursor.getString(3); city[i] = cursor.getString(4); diqu[i] = cursor.getString(5); youbian[i] = cursor.getString(6); tel[i] = cursor.getString(7); chuanzhen[i] = cursor.getString(8); web[i] = cursor.getString(9); i++; } catch (Exception e) { // TODO: handle exception } } while (cursor.moveToNext()); for (int i = 0; i < id.length; i++) { Map<String, Object> map = new HashMap<String, Object>(); map.put("id", id[i]); map.put("cname", cname[i]); map.put("pname", pname[i]); map.put("add", add[i]); map.put("city", city[i]); map.put("diqu", diqu[i]); map.put("youbian", youbian[i]); map.put("tel", tel[i]); map.put("chuanzhen", chuanzhen[i]); map.put("web", web[i]); slist.add(map); } SimpleAdapter simple = new SimpleAdapter(this, slist, R.layout.shanchukadpter1, new String[] { "id", "cname", "pname", "add" ,"city","diqu","youbian","tel","chuanzhen","web"}, new int[] { R.id.t1, R.id.t2, R.id.t3, R.id.t4, R.id.t5,R.id.t6,R.id.t7,R.id.t8,R.id.t9,R.id.t10,}); listview.setAdapter(simple); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub for(int i=0;i<cname.length;i++){ if(arg2==i){ builder.setTitle("确认消息"); builder.setMessage("确定要删除该出库吗?"); final int j=i; builder.setPositiveButton("确定", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub sDatabase.execSQL("delete from chuku where comname='"+cname[j]+"'"); Intent intent=new Intent(); intent.setClass(Chaxunc.this, Chaxunc.class); startActivity(intent); finish(); } }); builder.setNegativeButton("取消", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); builder.create().show(); } } } }); } }
最近下载更多
dou220 LV1
10月27日
hgy138339 LV1
6月29日
xueqian2568 LV1
2月3日
101589 LV1
2023年12月6日
1962940615 LV1
2023年8月25日
whdsichen LV1
2023年6月5日
170011771 LV1
2023年5月31日
lmroman LV8
2023年4月27日
tutou孙硕 LV1
2022年12月17日
17693282606 LV12
2022年9月16日