/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_service_search); // setHeader(getString(R.string.FeedbackActivityTitle), true, false); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.list_transactions); setHeader(getString(R.string.transactions), true, true); fromDate = this.getIntent().getStringExtra("fromdate"); toDate = this.getIntent().getStringExtra("todate"); fromAmount = this.getIntent().getStringExtra("fromamount"); toAmount = this.getIntent().getStringExtra("toamount"); listTransactions = (ListView) this.findViewById(R.id.listTransactions); // form condition based on input if (fromDate.length() > 0) condition += " and " + Database.TRANSACTIONS_TRANSDATE + " >= '" + fromDate + "'"; if (toDate.length() > 0) condition += " and " + Database.TRANSACTIONS_TRANSDATE + " <= '" + toDate + "'"; if (fromAmount.length() > 0) condition += " and " + Database.STOCK_NAME + " = '" + fromAmount + "'"; if (toAmount.length() > 0) condition += " and " + Database.TRANSACTIONS_TRANSTYPE + " = '" + toAmount + "'"; listTransactions.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View selectedView, int arg2, long arg3) { TextView textTransId = (TextView) selectedView.findViewById(R.id.textTransId); Intent intent = new Intent(ListTransactions.this, TransactionDetails.class); intent.putExtra("transid", textTransId.getText().toString()); startActivity(intent); } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search_transactions); setHeader(getString(R.string.Search), true, true); editFromDate = (EditText) this.findViewById(R.id.editFromDate); editToDate = (EditText) this.findViewById(R.id.editToDate); editFromAmount = (Spinner) this.findViewById(R.id.editFromAmount); // Database.populateAccounts(editFromAmount); editToAmount = (Spinner) this.findViewById(R.id.editToAmount); // get the current date final Calendar c = Calendar.getInstance(); fromYear = toYear = c.get(Calendar.YEAR); fromMonth = toMonth = c.get(Calendar.MONTH); toDay = c.get(Calendar.DAY_OF_MONTH); fromDay = 1; // from is set to 1st of the current month DataFromDB(); // method to get data from sqlite database updateToDateDisplay(); updateFromDateDisplay(); }
@Override public void onStart() { super.onStart(); try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ListTransactions.this); String username = prefs.getString("user", "anon"); DBHelper dbhelper = new DBHelper(this); SQLiteDatabase db = dbhelper.getReadableDatabase(); Cursor trans = db.rawQuery( "select t._id,t.uid, item,quantity, transdate,transamount,transtype,cheque_no,cheque_party,cheque_details, t.remarks from transactions t inner join stock a on ( a._id = t.account_id) where " + condition + "and t.uid='" + username + "'", null); if (trans.getCount() == 0) this.findViewById(R.id.textError).setVisibility(View.VISIBLE); else this.findViewById(R.id.textError).setVisibility(View.INVISIBLE); ArrayList<Map<String, String>> listTrans = new ArrayList<Map<String, String>>(); while (trans.moveToNext()) { // get trans details for display LinkedHashMap<String, String> tran = new LinkedHashMap<String, String>(); tran.put("transid", trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_ID))); tran.put("acno", trans.getString(trans.getColumnIndex(Database.STOCK_NAME))); tran.put( "transdate", trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_TRANSDATE))); tran.put( "transtype", trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_TRANSTYPE))); tran.put( "transamount", trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_TRANSAMOUNT))); tran.put( "transremarks", trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_CHEQUE_PARTY))); String chequeno = trans.getString(trans.getColumnIndex(Database.TRANSACTIONS_CHEQUE_NO)); String transDetails = "Cash"; if (!chequeno.trim().equals("")) transDetails = chequeno; tran.put("transdetails", transDetails); listTrans.add(tran); } trans.close(); db.close(); dbhelper.close(); SimpleAdapter adapter = new SimpleAdapter( this, listTrans, R.layout.transaction, new String[] { "transid", "acno", "transdate", "transdetails", "transtype", "transamount", "transremarks" }, new int[] { R.id.textTransId, R.id.textAcno, R.id.textTransDate, R.id.textTransDetails, R.id.textTransType, R.id.textTransAmount, R.id.textTransRemarks }); listTransactions.setAdapter(adapter); } catch (Exception ex) { Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show(); } }