diff --git a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CattleFeedActivity.java b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CattleFeedActivity.java index ee0e1c6..d9b26a8 100644 --- a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CattleFeedActivity.java +++ b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CattleFeedActivity.java @@ -20,6 +20,7 @@ import android.widget.DatePicker; import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner; import android.widget.TextView; @@ -101,6 +102,16 @@ protected void onCreate(Bundle savedInstanceState) { particulars.setText(bundle.getString("part")); amt.setText(bundle.getString("amt")); item.setSelection(((ArrayAdapter) item.getAdapter()).getPosition(bundle.getString("itemName"))); + + RadioButton button; + if (bundle.getString("memId").equals("0")) { + button = findViewById(R.id.radioButtonCash); + button.setChecked(true); + } else { + button = findViewById(R.id.radioButtonCredit); + button.setChecked(true); + memDetails.setVisibility(View.VISIBLE); + } } qty.addTextChangedListener(new TextWatcher() { diff --git a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionActivity.java b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionActivity.java index 1647c64..6c46f67 100644 --- a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionActivity.java +++ b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionActivity.java @@ -55,7 +55,7 @@ public class CollectionActivity extends AppCompatActivity { RadioGroup radioGroup, radioGroupMorEve; LinearLayout swapCB, swapBoth, addSNF, collectionDetails, todayDetails, typeLayout; String cowBuff; - String mornEve; + String mornEve = ""; String[] memb_type = {"Member", "Contractor", "Labour Contractor"}; String settingsPrefs = "empty"; int rateGroupNo; @@ -405,10 +405,26 @@ public void onClick(View view) { if (!cowBuf.getText().toString().equals("")) { + String cb, me, m = ""; + if (cowBuf.getText().toString().equals("Cow")) + cb = "C"; + else + cb = "B"; + if (mE.getText().toString().equals("Morning")) + me = "1"; + else + me = "2"; + + if (!mornEve.equals("")) { + if (mornEve.equals("Morning")) + m = "1"; + else + m = "2"; + } if (bundle != null) - dbClass.editColl(id, date.getText().toString(), memCode, edtName.getText().toString(), cowBuf.getText().toString(), mE.getText().toString(), deg, lit, f, r, a); + dbClass.editColl(id, date.getText().toString(), memCode, edtName.getText().toString(), cb, me, deg, lit, f, r, a); else - dbClass.addColl(date.getText().toString(), memCode, edtName.getText().toString(), cowBuf.getText().toString(), mornEve, deg, lit, f, r, a); + dbClass.addColl(date.getText().toString(), memCode, edtName.getText().toString(), cb, m, deg, lit, f, r, a); Toast.makeText(CollectionActivity.this, "Added Successfully", Toast.LENGTH_LONG).show(); edtName.setText(""); membType.setText(""); diff --git a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionDetailActivity.java b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionDetailActivity.java index 22ce108..e462db3 100644 --- a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionDetailActivity.java +++ b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/CollectionDetailActivity.java @@ -10,6 +10,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.SearchView; +import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -67,8 +68,19 @@ public void getCollDetails() { Toast.makeText(this, "No records found.", Toast.LENGTH_SHORT).show(); cursor.moveToFirst(); while (!cursor.isAfterLast()) { - Collection collection = new Collection(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), cursor.getString(10)); + + String cb, me; + if (cursor.getString(4).equals("C")) + cb = "Cow"; + else + cb = "Buffalo"; + if (cursor.getString(5).equals("1")) + me = "Morning"; + else + me = "Evening"; + Collection collection = new Collection(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cb, me, cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), cursor.getString(10)); collectionList.add(collection); + Log.e("TAG ERROR:-", cursor.getString(0) + cursor.getString(1) + cursor.getString(2) + cursor.getString(3) + cursor.getString(4) + cb + me + cursor.getString(7) + cursor.getString(8) + cursor.getString(9) + cursor.getString(10)); cursor.moveToNext(); } cursor.close(); diff --git a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleActivity.java b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleActivity.java index 20159c5..bd481fc 100644 --- a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleActivity.java +++ b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleActivity.java @@ -53,7 +53,7 @@ public class SaleActivity extends AppCompatActivity { // LinearLayout swapCB; LinearLayout swapBoth, saleDetails; String cowBuff; - String mornEve; + String mornEve = ""; TextView todayDate, totLit, totAmt; String id; RadioGroup cashCredit; @@ -120,6 +120,17 @@ protected void onCreate(Bundle savedInstanceState) { default: break; } + + RadioButton button; + if (bundle.getString("memId").equals("0")) { + button = findViewById(R.id.radioButtonCash); + button.setChecked(true); + } else { + button = findViewById(R.id.radioButtonCredit); + button.setChecked(true); + memDetails.setVisibility(View.VISIBLE); + } + } rate.addTextChangedListener(new TextWatcher() { @@ -328,10 +339,26 @@ public void onClick(View view) { int selected = radioGroupCB.getCheckedRadioButtonId(); RadioButton tempCB = findViewById(selected); + String cb, me, m = ""; + if (tempCB.getText().toString().equals("Cow")) + cb = "C"; + else + cb = "B"; + if (mE.getText().toString().equals("Morning")) + me = "1"; + else + me = "2"; + + if (!mornEve.equals("")) { + if (mornEve.equals("Morning")) + m = "1"; + else + m = "2"; + } if (bundle != null) - dbClass.editSale(id, date.getText().toString(), memCode, memName, mE.getText().toString(), tempCB.getText().toString(), lit, f, r, Float.parseFloat(amt.getText().toString())); + dbClass.editSale(id, date.getText().toString(), memCode, memName, me, cb, lit, f, r, Float.parseFloat(amt.getText().toString())); else - dbClass.addSale(date.getText().toString(), memCode, memName, mornEve, tempCB.getText().toString(), lit, f, r, Float.parseFloat(amt.getText().toString())); + dbClass.addSale(date.getText().toString(), memCode, memName, m, cb, lit, f, r, Float.parseFloat(amt.getText().toString())); Toast.makeText(SaleActivity.this, "Added Successfully", Toast.LENGTH_LONG).show(); edtName.setText(""); // branch.setText(""); diff --git a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleDetailActivity.java b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleDetailActivity.java index cf2038e..1ce015e 100644 --- a/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleDetailActivity.java +++ b/app/src/main/java/com/kshitijharsh/dairymanagement/activities/SaleDetailActivity.java @@ -67,7 +67,17 @@ public void getSaleDetails() { Toast.makeText(this, "No records found.", Toast.LENGTH_SHORT).show(); cursor.moveToFirst(); while (!cursor.isAfterLast()) { - Sale sale = new Sale(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9)); + + String cb, me; + if (cursor.getString(5).equals("C")) + cb = "Cow"; + else + cb = "Buffalo"; + if (cursor.getString(4).equals("1")) + me = "Morning"; + else + me = "Evening"; + Sale sale = new Sale(cursor.getString(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), me, cb, cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9)); saleList.add(sale); cursor.moveToNext(); } diff --git a/app/src/main/res/layout/activity_cattle_feed.xml b/app/src/main/res/layout/activity_cattle_feed.xml index 801e01f..56de101 100644 --- a/app/src/main/res/layout/activity_cattle_feed.xml +++ b/app/src/main/res/layout/activity_cattle_feed.xml @@ -154,19 +154,19 @@ android:padding="4dp"> diff --git a/app/src/main/res/layout/activity_sale.xml b/app/src/main/res/layout/activity_sale.xml index 35ce0d8..80f654a 100644 --- a/app/src/main/res/layout/activity_sale.xml +++ b/app/src/main/res/layout/activity_sale.xml @@ -208,19 +208,19 @@ android:padding="4dp"> @@ -273,7 +273,7 @@ android:id="@+id/radioButtonCow" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" + android:layout_weight="1.2" android:text="@string/cow" android:textSize="@dimen/text_small" />