@Override
 protected void onDestroy() {
   super.onDestroy();
   Globals.setWhichShop(-1);
   Globals.setModuleUseWarehouseId(-1);
   Globals.setWhichPrice(-1);
   Globals.setCustomer(null);
 }
  private void setDefaultPrice() {
    Context context = CashSaleSetActivity.this;
    final SharedPreferences sharedPref =
        context.getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE);
    int defaultPrice = sharedPref.getInt(PrefKeys.DEFAULT_PRICE, 0);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setTitle(R.string.default_price)
        .setSingleChoiceItems(
            CashSaleSpec.getPrices(),
            defaultPrice,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                int selectedPosition =
                    ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                SharedPreferences.Editor editor = sharedPref.edit();
                editor.putInt(PrefKeys.DEFAULT_PRICE, selectedPosition);
                editor.commit();
              }
            })
        .show();
  }
  private void goToList() {
    Globals.setWhichShop(mWhichShop);
    Globals.setShopName(mShops[mWhichShop].shopName);
    Globals.setWhichWarehouse(mWhichWarehouse);
    Globals.setModuleUseWarehouseId(mWarehouses[mWhichWarehouse].warehouseId);
    Globals.setCashSaleWarehouseNO(mWarehouses[mWhichWarehouse].warehouseNO);
    Intent intent = new Intent(getBaseContext(), CashSaleGoodsListActivity.class);

    if (!mNotRecordCustomerCheck.isChecked()) {
      String customerName = mCustomerNameEdit.getText().toString();
      String tel = mTelEdit.getText().toString();
      if (TextUtils.isEmpty(customerName) || TextUtils.isEmpty(tel)) {
        Util.toast(getApplicationContext(), "客户姓名和电话不能为空");
        return;
      }
      String zipCode = mZipCodeEdit.getText().toString();
      String streetAddress = mStreetAddressEdit.getText().toString();
      String email = mEmailEdit.getText().toString();
      Customer customer =
          new Customer(
              -1,
              null,
              customerName,
              tel,
              zipCode,
              mProvince,
              mCity,
              mDistrict,
              streetAddress,
              email);
      Globals.setCustomer(customer);
    }

    startActivity(intent);
  }
  private void onQueryShopsSuccess() {
    ArrayAdapter<Shop> adapter =
        new ArrayAdapter<Shop>(this, R.layout.simple_spinner_dropdown_item, mShops);
    mShopSp.setAdapter(adapter);
    final SharedPreferences sharedPref =
        getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE);
    int defaultShop = sharedPref.getInt(PrefKeys.DEFAULT_SHOP, 0);
    mShopSp.setSelection(defaultShop, false);
    mWhichShop = defaultShop;
    mShopSp.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mWhichShop = position;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    WDTQuery.getinstance().queryInterfaceWarehouses(this, this);
  }
 @Override
 protected void onResume() {
   super.onResume();
   mPriceSp.setSelection(Globals.getWhichPrice());
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cash_sale_set_activity);

    final ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(R.string.cash_sale);
    actionBar.setDisplayHomeAsUpEnabled(true);

    mProgressLayout = (RelativeLayout) findViewById(R.id.progress_layout);
    mContentLayout = (LinearLayout) findViewById(R.id.content_layout);
    mShopSp = (Spinner) findViewById(R.id.shop_sp);
    mWarehouseSp = (Spinner) findViewById(R.id.warehouse_sp);
    mPriceSp = (Spinner) findViewById(R.id.price_sp);
    mNotRecordCustomerCheck = (CheckBox) findViewById(R.id.not_record_customer_check);
    mSearchCustomerBtn = (Button) findViewById(R.id.search_customer_btn);
    mCustomerInfoLayout = (GridLayout) findViewById(R.id.customer_info_layout);
    mCustomerNameEdit = (EditText) findViewById(R.id.customer_name_edit);
    mTelEdit = (EditText) findViewById(R.id.tel_edit);
    mZipCodeEdit = (EditText) findViewById(R.id.zip_code_edit);

    mToDistrictAddressBtn = (Button) findViewById(R.id.to_district_address_btn);
    mToDistrictAddressBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent(CashSaleSetActivity.this, AddressSelectActivity.class);
            startActivityForResult(intent, REQUEST_CODE_ADDRESS);
          }
        });
    mStreetAddressEdit = (EditText) findViewById(R.id.street_address_edit);

    mEmailEdit = (EditText) findViewById(R.id.email_edit);

    mNotRecordCustomerCheck.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
            showCustomerInfo(!isChecked);
          }
        });

    mSearchCustomerBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent(CashSaleSetActivity.this, SearchCustomerActivity.class);
            startActivityForResult(intent, REQUEST_CODE_CUSTOMER);
          }
        });

    Util.initSpinner(
        this, mPriceSp, R.layout.simple_spinner_dropdown_item, CashSaleSpec.getPrices());
    final SharedPreferences sharedPref =
        getSharedPreferences(Globals.getUserPrefsName(), Context.MODE_PRIVATE);
    int defaultPrice = sharedPref.getInt(PrefKeys.DEFAULT_PRICE, 0);
    mPriceSp.setSelection(defaultPrice);
    Globals.setWhichPrice(defaultPrice);
    mPriceSp.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            Globals.setWhichPrice(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    if (Globals.getWhichPrice() == -1) {
      Globals.setWhichPrice(0);
    }
    mOkBtn = (Button) findViewById(R.id.ok_btn);

    WDTQuery.getinstance().queryShops(this, this);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fast_in_examine_goods_set_activity);

    final ActionBar actionBar = getActionBar();
    actionBar.setTitle(R.string.fast_in_examine_goods);
    actionBar.setDisplayHomeAsUpEnabled(true);

    mProgressLayout = (RelativeLayout) findViewById(R.id.progress_layout);
    mSupplierSp = (Spinner) findViewById(R.id.supplier_sp);
    mInWarehouseSp = (Spinner) findViewById(R.id.in_warehouse_sp);
    mDoPriceSp = (Spinner) findViewById(R.id.do_price_sp);
    mOkBtn = (Button) findViewById(R.id.ok_btn);

    Globals.setWhichSupplier(-1);
    Globals.setWhichWarehouse(-1);
    Globals.setWhichPrice(-1);

    mTempSuppliers = null;
    mWarehouses = null;

    mSupplierSp.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mWhichSupplier = position;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });
    mWhichSupplier = -1 != Globals.getWhichPrice() ? Globals.getWhichSupplier() : 0;

    mInWarehouseSp.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int positioin, long id) {
            mWhichWarehouse = positioin;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });
    mWhichWarehouse = -1 != Globals.getWhichWarehouse() ? Globals.getWhichWarehouse() : 0;

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this,
            R.layout.simple_spinner_dropdown_item,
            getResources().getStringArray(R.array.prices));
    mDoPriceSp.setAdapter(adapter);
    mWhichPrice = -1 != Globals.getWhichPrice() ? Globals.getWhichPrice() : 0;
    mDoPriceSp.setSelection(mWhichPrice);

    mDoPriceSp.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mWhichPrice = position;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    mSupplierPos = 0;
    mSuppliers = null;
    WDTQuery.getinstance().querySupplierCount(this, this);

    mOkBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Globals.setWhichSupplier(mWhichSupplier);
            Globals.setWhichWarehouse(mWhichWarehouse);
            Globals.setModuleUseWarehouseId(mWarehouses[mWhichWarehouse].warehouseId);
            Globals.setWhichPrice(mWhichPrice);
            Globals.setSupplierId(mTempSuppliers[mWhichSupplier].supplierId);
            Intent intent = new Intent(getBaseContext(), FastInExamineGoodsListActivity.class);
            intent.putExtra(Extras.SCAN_TYPE, ScanType.TYPE_FAST_IN_EXAMINE_GOODS);
            startActivity(intent);
          }
        });
  }