package com.jqyd.newprocess; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import com.jqyd.app.MyApp; import com.jqyd.manager.R; import com.jqyd.shareInterface.Optdb_interfce; import com.jqyd.shareInterface.Optsharepre_interface; import com.jqyd.son.Rzsb; import android.app.Activity; import android.app.DatePickerDialog; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.DatePicker; import android.widget.EditText; public class CustEdit extends Activity implements OnClickListener { private EditText xdr; private EditText khmc; private EditText shr; private EditText lxdh; private EditText jhrq; private EditText jhdz; private EditText bz; private Button next; private Bundle bundle = null; private Optsharepre_interface share_obj = null; private Optdb_interfce db = null; private MyApp myApp; private Calendar c; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.custedit); xdr = (EditText) this.findViewById(R.id.xdr); khmc = (EditText) this.findViewById(R.id.khmc); shr = (EditText) this.findViewById(R.id.shr); lxdh = (EditText) this.findViewById(R.id.lxdh); jhrq = (EditText) this.findViewById(R.id.jhrq); jhdz = (EditText) this.findViewById(R.id.jhdz); bz = (EditText) this.findViewById(R.id.bz); next = (Button) this.findViewById(R.id.next); next.setOnClickListener(this); jhrq.setOnClickListener(this); //指定默认获得焦点 shr.setFocusable(true); shr.setFocusableInTouchMode(true); shr.requestFocus(); myApp = (MyApp) this.getApplication(); bundle = myApp.getCustBundle(); loadData(); } /** * 加载数据 */ public void loadData(){ //获得下单人姓名 db = new Optdb_interfce(this); share_obj = new Optsharepre_interface(CustEdit.this); String userName = db.searchEmpName(share_obj.getDataFromPres("GUID")); db.close_SqlDb(); xdr.setText(userName); khmc.setText(bundle.getString("cname")); shr.setText(bundle.getString("linkman")); lxdh.setText(bundle.getString("link_sim")); jhdz.setText(bundle.getString("address")); c = Calendar.getInstance(); // 默认当天 Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String mDateTime1 = formatter.format(date); jhrq.setText(mDateTime1); } @Override public void onClick(View v) { // TODO Auto-generated method stub if(next == v){ //清楚上次记忆的分组编号 myApp.setGroupNums(""); Intent intent = new Intent(); Bundle newBundle = new Bundle(); newBundle.putString("khmc", khmc.getText().toString()); newBundle.putString("shr", shr.getText().toString()); newBundle.putString("lxdh", lxdh.getText().toString()); newBundle.putString("jhdz", jhdz.getText().toString()); newBundle.putString("xdr", xdr.getText().toString()); newBundle.putString("jhrq", jhrq.getText().toString()); newBundle.putString("bz", bz.getText().toString()); newBundle.putString("cid", bundle.getString("cid")); myApp.setCustBundle(newBundle);//保存客户信息 myApp.setDataType("2");//商品 intent.setClass(CustEdit.this, GoodGroupList.class); startActivity(intent); finish(); }else if(jhrq == v){ getDate(); } } // 弹出日期框 public void getDate() { new DatePickerDialog(CustEdit.this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker arg0, int year, int month, int date) { // TODO Auto-generated method stub String m = ""; String d = ""; if ((month + 1) < 10) { m = "0" + (month + 1); } else { m = (month + 1) + ""; } if (date < 10) { d = "0" + date; } else { d = date + ""; } String time = year + "-" + m + "-" + d; jhrq.setText(time); } }, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)).show(); } }