Skip to content

Commit

Permalink
Merge pull request #4 from harshshinde07/v2
Browse files Browse the repository at this point in the history
Cash credit preferences added
  • Loading branch information
harshshinde07 authored Oct 31, 2019
2 parents 2c278b6 + 04b129b commit fbb4d8f
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_cattle_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@
android:padding="4dp">

<RadioButton
android:id="@+id/radioButtonCredit"
android:id="@+id/radioButtonCash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/credit"
android:text="@string/cash"
android:textSize="@dimen/text_small" />

<RadioButton
android:id="@+id/radioButtonCash"
android:id="@+id/radioButtonCredit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cash"
android:text="@string/credit"
android:textSize="@dimen/text_small" />

</RadioGroup>
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/res/layout/activity_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,19 @@
android:padding="4dp">

<RadioButton
android:id="@+id/radioButtonCredit"
android:id="@+id/radioButtonCash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/credit"
android:layout_weight="1.1"
android:text="@string/cash"
android:textSize="@dimen/text_small" />

<RadioButton
android:id="@+id/radioButtonCash"
android:id="@+id/radioButtonCredit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/cash"
android:text="@string/credit"
android:textSize="@dimen/text_small" />

</RadioGroup>
Expand Down Expand Up @@ -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" />

Expand Down

0 comments on commit fbb4d8f

Please sign in to comment.