package com.jqyd.son;
import java.util.ArrayList;
import java.util.HashMap;
import com.jqyd.adapter.MyAdapter;
import com.jqyd.app.MyApp;
import com.jqyd.manager.R;
import com.jqyd.model.ProTypeModule;
import com.jqyd.shareInterface.Optdb_interfce;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;
public class Xssb extends Activity implements OnClickListener {
private EditText zdmd;
private EditText spmc;
private EditText xsdj;
private EditText jldw;
private EditText spsl;
private Button add_cust;
private Button add_good;
private Button add;
private Button up;
private ListView listView;
private MyApp myApp;
private String cid;//客户id
private String pid;//商品id
private Optdb_interfce db;
private MyAdapter adapter;
private ArrayList<HashMap<String,String>> list = new ArrayList<HashMap<String,String>>();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.xssb);
zdmd = (EditText) this.findViewById(R.id.zdmd);
spmc = (EditText) this.findViewById(R.id.spmc);
xsdj = (EditText) this.findViewById(R.id.xsdj);
jldw = (EditText) this.findViewById(R.id.jldw);
spsl = (EditText) this.findViewById(R.id.spsl);
add_cust = (Button) this.findViewById(R.id.add_cust);
add_good = (Button) this.findViewById(R.id.add_good);
add = (Button) this.findViewById(R.id.add);
up = (Button) this.findViewById(R.id.up);
listView = (ListView) this.findViewById(R.id.list);
add_cust.setOnClickListener(this);
add_good.setOnClickListener(this);
add.setOnClickListener(this);
up.setOnClickListener(this);
myApp = (MyApp) this.getApplication();
//initEnter();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v == add_cust){
myApp.setModuleName("xssb_cust");
startActivity(new Intent().setClass(Xssb.this, MyOneData.class).putExtra("moduleName", "xssb_cust"));
finish();
}else if(v == add_good){
myApp.setModuleName("xssb_good");
startActivity(new Intent().setClass(Xssb.this, MyOneData.class).putExtra("moduleName", "xssb_good"));
finish();
}else if(v == add){
}else if(v == up){
}
}
/**
* 判断是否二次进入当前界面
*/
public void initEnter(){
String cName = "";
String pName = "";
//为客户赋值--单选客户
ArrayList<String> list_cids = myApp.getCustId();
ArrayList<String> list_cnames = myApp.getCustIdAndName();
if(list_cids.size()>0){
cName = list_cnames.get(0);
cid = list_cids.get(0);
zdmd.setText(cName);
}
//为商品赋值--单选商品
ArrayList<String> list_pids = myApp.getLxrTel();
ArrayList<String> list_pnames = myApp.getLxrTelAndName();
if(list_pids.size()>0){
pName = list_pnames.get(0);
pid = list_pids.get(0);
spmc.setText(pName);
//根据商品id,查询商品相关信息
db = new Optdb_interfce(Xssb.this);
ProTypeModule product = db.searchProductById(pid);
jldw.setText(product.getUnit());
xsdj.setText(product.getLsPrise());
}
//每次回到当前界面,判断是否已经添加过数据至共享池了,如果有显示,否则不显示
ArrayList<HashMap<String,String>> ls = myApp.getOrderList();
System.out.println("共享池中保存数据--------"+ls.size());
if(ls.size()>0){
for(int i=0;i<ls.size();i++){
HashMap<String,String> map = ls.get(i);
map.put("pid", map.get("pid"));
map.put("sjsj", map.get("sjsj"));
map.put("dgsl", map.get("dgsl"));
map.put("fhrq", map.get("fhrq"));
map.put("bz", map.get("bz"));
map.put("textView1", map.get("textView1"));
map.put("textView2", map.get("textView2"));
map.put("textView3", map.get("textView3"));
list.add(map);
}
setShow();
}
}
//设置界面显示
public void setShow(){
adapter=new MyAdapter(list, this,11);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
}
});
}
}