Skip to content

Commit

Permalink
Merge pull request #5 from harshshinde07/v2
Browse files Browse the repository at this point in the history
Added facility for importing to database from csv file
  • Loading branch information
harshshinde07 authored Nov 1, 2019
2 parents fbb4d8f + 2afa9ef commit 5f07694
Show file tree
Hide file tree
Showing 22 changed files with 522 additions and 370 deletions.
4 changes: 2 additions & 2 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation group: 'com.opencsv', name: 'opencsv', version: '4.1'

// ButterKnife (for sample code brevity)
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// // ButterKnife (for sample code brevity)
// implementation 'com.jakewharton:butterknife:8.8.1'
// annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ protected void onCreate(Bundle savedInstanceState) {
button.setChecked(true);
memDetails.setVisibility(View.VISIBLE);
}

todayDate.setText(date.getText().toString());
totAmt.setText(String.valueOf(dbClass.getCattleAmtFromDate(date.getText().toString())));
cattleDetails.setVisibility(View.VISIBLE);
}

qty.addTextChangedListener(new TextWatcher() {
Expand Down Expand Up @@ -197,13 +201,19 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String p;
String p, cashCr;
if (date.getText().toString().equals("") || rate.getText().toString().equals("") || amt.getText().toString().equals("") || qty.getText().toString().equals("") || item.getSelectedItem().equals("Select Item") || cashCredit.getCheckedRadioButtonId() == -1) {
Toast.makeText(CattleFeedActivity.this, "Please enter required values", Toast.LENGTH_SHORT).show();
} else {
int memId = 0;
String memName = "Not available";
int cashCrId = cashCredit.getCheckedRadioButtonId();
RadioButton crDr = findViewById(cashCrId);
if (crDr.getText().toString().equals("Cash"))
cashCr = "1";
else
cashCr = "2";

if (cashCrId == R.id.radioButtonCredit) {
if (!txtCode.getText().toString().equals(""))
memId = Integer.parseInt(txtCode.getText().toString());
Expand All @@ -220,9 +230,9 @@ public void onClick(View view) {
p = particulars.getText().toString();

if (bundle != null) {
dbClass.editCattle(id, date.getText().toString(), memId, memName, label, quantity, r, a, p);
dbClass.editCattle(id, date.getText().toString(), memId, memName, label, quantity, r, a, p, cashCr);
} else {
dbClass.addCattle(date.getText().toString(), memId, memName, label, quantity, r, a, p);
dbClass.addCattle(date.getText().toString(), memId, memName, label, quantity, r, a, p, cashCr);
Toast.makeText(CattleFeedActivity.this, "Added Successfully", Toast.LENGTH_LONG).show();
}
// date.setText(R.string.select_date);
Expand All @@ -232,7 +242,10 @@ public void onClick(View view) {
qty.setText("");
item.setSelected(false);
particulars.setText("");
cattleDetails.setVisibility(View.GONE);
//Update day wise details
todayDate.setText(date.getText().toString());
totAmt.setText(String.valueOf(dbClass.getCattleAmtFromDate(date.getText().toString())));

txtCode.requestFocus();

cashCredit.clearCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ protected void onCreate(Bundle savedInstanceState) {
radioGroup = findViewById(R.id.cowBuff);
radioGroup.clearCheck();

swapBoth = findViewById(R.id.swapBoth);
swapCB = findViewById(R.id.swapCB);

collectionDetails = findViewById(R.id.collection_details);
todayDate = findViewById(R.id.today_date);
totAmt = findViewById(R.id.tot_amt);
totLit = findViewById(R.id.tot_lit);

final Bundle bundle = getIntent().getExtras();
if (bundle != null) {
typeLayout.setVisibility(View.GONE);
Expand Down Expand Up @@ -138,6 +146,11 @@ protected void onCreate(Bundle savedInstanceState) {
((RadioButton) radioGroup.findViewById(R.id.radioButtonBoth)).setChecked(true);
break;
}

todayDate.setText(date.getText().toString());
totAmt.setText(String.valueOf(dbClass.getCollecedAmtFromDate(date.getText().toString())));
totLit.setText(String.valueOf(dbClass.getCollecedMilkFromDate(date.getText().toString())));
collectionDetails.setVisibility(View.VISIBLE);
}

if (settingsPrefs.equals("false")) {
Expand Down Expand Up @@ -291,21 +304,13 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
}
});

swapBoth = findViewById(R.id.swapBoth);
swapCB = findViewById(R.id.swapCB);

collectionDetails = findViewById(R.id.collection_details);
todayDate = findViewById(R.id.today_date);
totAmt = findViewById(R.id.tot_amt);
totLit = findViewById(R.id.tot_lit);

radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton rb = group.findViewById(checkedId);
if (null != rb) {
//Toast.makeText(SaleActivity.this, rb.getText(), Toast.LENGTH_SHORT).show();
cowBuff = rb.getText().toString();
cowBuf.setText(cowBuff);
}

}
Expand All @@ -329,6 +334,8 @@ public void onClick(View view) {
snf.setText("");
radioGroup.clearCheck();
radioGroupMorEve.clearCheck();
swapBoth.setVisibility(View.GONE);
swapCB.setVisibility(View.VISIBLE);
collectionDetails.setVisibility(View.GONE);
if (todayDetails.getVisibility() == View.VISIBLE)
todayDetails.setVisibility(View.GONE);
Expand Down Expand Up @@ -441,17 +448,17 @@ public void onClick(View view) {
swapBoth.setVisibility(View.GONE);
swapCB.setVisibility(View.VISIBLE);
txtCode.requestFocus();
collectionDetails.setVisibility(View.GONE);
if (todayDetails.getVisibility() == View.VISIBLE)
todayDetails.setVisibility(View.GONE);
//Update day wise details
todayDate.setText(date.getText().toString());
totAmt.setText(String.valueOf(dbClass.getCollecedAmtFromDate(date.getText().toString())));
totLit.setText(String.valueOf(dbClass.getCollecedMilkFromDate(date.getText().toString())));
}
// else {
// Toast.makeText(CollectionActivity.this, "Please enter required values", Toast.LENGTH_SHORT).show();
// }
} else {
Toast.makeText(CollectionActivity.this, "Please enter required values", Toast.LENGTH_SHORT).show();
}
// else {
// Toast.makeText(CollectionActivity.this, "Please enter required values", Toast.LENGTH_SHORT).show();
// }
}

}
Expand Down Expand Up @@ -566,35 +573,26 @@ private void initNames() {
}

public void getRateAmt(float deg, float fat, float qty, String cobf) {
Cursor c;
float val;

if (degree.getHint().toString().equals("SNF")) {
c = dbQuery.getRateFromSNF(deg, fat, cobf, rateGroupNo);
val = dbQuery.getRateFromSNF(deg, fat, cobf, rateGroupNo);
} else {
if (settingsPrefs.equals("true")) {
float s = 0;
if (!snf.getText().toString().equals(""))
s = Float.parseFloat(snf.getText().toString());
c = dbQuery.getRateFromSNF(s, fat, cobf, rateGroupNo);
val = dbQuery.getRateFromSNF(s, fat, cobf, rateGroupNo);
} else if (settingsPrefs.equals("false")) {
c = dbQuery.getRate(deg, fat, cobf, rateGroupNo);
val = dbQuery.getRate(deg, fat, cobf, rateGroupNo);
} else {
// Toast.makeText(this, String.valueOf(fat) + " " + cobf + rateGroupNo, Toast.LENGTH_SHORT).show();
c = dbQuery.getRateFromFat(fat, cobf, rateGroupNo);
val = dbQuery.getRateFromFat(fat, cobf, rateGroupNo);
}
}
float val;
c.moveToFirst();
if (c.getCount() > 0) {
val = c.getFloat(c.getColumnIndex("rate"));
rate.setText(String.valueOf(val));
a = qty * val;
amt.setText(String.valueOf(a));
} else {
Toast.makeText(this, "Value not found!", Toast.LENGTH_SHORT).show();
rate.setText("");
amt.setText("");
}
c.close();

rate.setText(String.valueOf(val));
a = qty * val;
amt.setText(String.valueOf(a));
}

public void getMemNameFromID(int id) {
Expand Down
Loading

0 comments on commit 5f07694

Please sign in to comment.