public List<BillModel> Daily_Sales_Report(String from) {// passing the
获取数据的日期,从两个表中按日期排列 列表列表= new ArrayList(); 字符串query =“ select BILLING中的sum(Discount),sum(Del_ch),sum(Pkg_ch),substr(Created_Date,0,11),其中substr(Created_Date,0,11)就像'” + from +“'一样,由substr( Created_Date,0,11)“; 字符串query1 =“ select count(*),sum(Amount),sum(gst_price),来自购物车的Created_Date,其中Created_Date类似于'” + from +“',按Created_Date”分组;
//here i used to cursor for getting the result from two different table and setting in the model class setter.
Cursor cursor = this.getwritabledatabase().rawQuery(query,null);
Cursor cursor1= this.getwritabledatabase().rawQuery(query1,null);
if (cursor.moveToFirst()&& cursor1.moveToFirst()){// cursor and cursor1 will check the data from first positon
String bill_date= cursor1.getString(3 ); //getting the date from table bill
String cart_date= cursor.getString( 3);//getting the cart_date from cart_table
try {
do {
if (bill_date==cart_date){ //if cart_date from cart_table,and bill_date from bill_table will match then it will set in the setter other wise condition will check countiue in while loop BillModel model = new BillModel(); //model class
model.setbill_count( cursor1.getInt( 0 ) ); // here its for count total number of item
model.setC_Amount( cursor1.getFloat( 1 ) );
model.setB_total_gst( cursor1.getFloat( 2 ) );
model.setB_discount( cursor.getFloat( 0 ) );
model.setB_del_ch( cursor.getInt( 1 ) );
model.setB_pack_ch( cursor.getInt( 2 ) );
model.setB_create_date( cursor.getString( 3) );
list.add( model );
}
} while (cursor.moveToNext()&& cursor1.moveToNext());// using while loop for both the cursor
} catch (Exception e) {
Log.e( "Error",String.valueOf( e ) );
} finally {
cursor.close();
cursor1.close();
}
}
return list;
}
i am trying to this,What's I am doing wrong here,not getting the result in model class variable. Is it write way or not?