final myDBClass myDb = new myDBClass(POrderActivity.this);
final ArrayList<HashMap<String, String>> ProList = myDb.SelectAllOrder();
final Spinner productList = (Spinner)findViewById(R.id.ProductList);
SimpleAdapter sAdap;
sAdap = new SimpleAdapter(POrderActivity.this, ProList, R.layout.activity_column_product,
new String[] {"ProductID", "Space","Name", "Price"}, new int[] {R.id.ColProductID, R.id.ColSpace, R.id.ColName, R.id.ColPrice});
productList.setAdapter(sAdap);
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String ProID = ProList.get(position).get("ProductID").toString();
//ลบข้อมูลเดิมก่อนเลือกสินค้าใหม่
final EditText txtInNum=(EditText)findViewById(R.id.txtInNum);
final TextView txtQuantity=(TextView)findViewById(R.id.txtQuantity);
txtInNum.setText(null);
txtQuantity.setText(null);
//***********************************
final TextView txtProductID=(TextView)findViewById(R.id.txtProductID);
final TextView txtName=(TextView)findViewById(R.id.txtName);
final TextView txtPrice=(TextView)findViewById(R.id.txtPrice);
// Show Data
String arrData[] = myDb.SelectProduct(ProID);
if(arrData != null)
{
strProductID=(arrData[0]);
strName=(arrData[1]);
strPrice=(arrData[3]);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
final Button btnCheckPro=(Button)findViewById(R.id.btnCheckPro);
btnCheckPro.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final EditText txtInNum=(EditText)findViewById(R.id.txtInNum);
if (txtInNum.getText().length()==0){
final AlertDialog.Builder adb = new AlertDialog.Builder(POrderActivity.this);
AlertDialog ad = adb.create();
ad.setMessage("กรุณาระบุจำนวนสินค้าที่ต้องการ :");
ad.show();
txtInNum.requestFocus();
}
final ListView lisView1 = (ListView)findViewById(R.id.listView1);
ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
map = new HashMap<String, String>();
map.put("ProductID", "A00001");
map.put("Name","Pen");
map.put("Price","45");
map.put("Num","1");
map.put("Sum","45");
MyArrList.add(map);
SimpleAdapter sAdap;
sAdap = new SimpleAdapter(POrderActivity.this, MyArrList, R.layout.activity_column_seletepro,
new String[] {"ProductID", "Name", "Price", "Num", "Sum"}, new int[] {R.id.ColProductID,R.id.ColName, R.id.ColPrice, R.id.ColNum, R.id.ColSum});
lisView1.setAdapter(sAdap);
}
});
final Button btnCancel=(Button)findViewById(R.id.btnCancel);
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});