-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b9208b
commit 0e96e47
Showing
6 changed files
with
343 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
app/src/main/java/com/example/myapplication/CreateCoin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.example.myapplication; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
public class CreateCoin extends AppCompatActivity { | ||
|
||
Button cancel, add, update, delete; | ||
EditText id, name, max, min; | ||
DBHelper DB; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_create_coin); | ||
|
||
add = (Button) findViewById(R.id.addButton); | ||
add.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Create(); | ||
} | ||
}); | ||
|
||
cancel = (Button) findViewById(R.id.cancelButton); | ||
cancel.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
opentoMainPage(); | ||
} | ||
}); | ||
|
||
update = (Button) findViewById(R.id.updateButton); | ||
update.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Update(); | ||
} | ||
}); | ||
|
||
delete = (Button) findViewById(R.id.deleteButton); | ||
delete.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
Delete(); | ||
} | ||
}); | ||
} | ||
|
||
public void opentoMainPage() { | ||
Intent intent = new Intent(this, MainActivity.class); | ||
startActivity(intent); | ||
} | ||
|
||
public CoinTO getRequest() { | ||
CoinTO to = new CoinTO(); | ||
id = (EditText) findViewById(R.id.coinId); | ||
to.setId(Integer.parseInt(id.getText().toString())); | ||
|
||
name = (EditText) findViewById(R.id.coinName); | ||
to.setName(name.getText().toString()); | ||
|
||
min = (EditText) findViewById(R.id.coinMinValue); | ||
to.setMinPrice(min.getText().toString()); | ||
|
||
max = (EditText) findViewById(R.id.coinMaxValue); | ||
to.setMaxPrice(max.getText().toString()); | ||
|
||
return to; | ||
} | ||
|
||
public void Create() { | ||
DB = new DBHelper(this); | ||
boolean stat = DB.inserCoinData(getRequest()); | ||
if (stat) { | ||
Intent intent = new Intent(this, MainActivity.class); | ||
startActivity(intent); | ||
} else { | ||
Toast.makeText(getApplicationContext(), "Create Failed", Toast.LENGTH_LONG).show(); | ||
} | ||
} | ||
|
||
public void Update() { | ||
DB = new DBHelper(this); | ||
boolean stat = DB.updateCoinData(getRequest()); | ||
if (stat) { | ||
Intent intent = new Intent(this, MainActivity.class); | ||
startActivity(intent); | ||
} else { | ||
Toast.makeText(getApplicationContext(), "Update Failed", Toast.LENGTH_LONG).show(); | ||
} | ||
} | ||
|
||
public void Delete() { | ||
DB = new DBHelper(this); | ||
boolean stat = DB.deleteCoinData(getRequest()); | ||
if (stat) { | ||
Intent intent = new Intent(this, MainActivity.class); | ||
startActivity(intent); | ||
} else { | ||
Toast.makeText(getApplicationContext(), "Delete Failed", Toast.LENGTH_LONG).show(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.