新客户应该能够:
P http://puu.sh/hiYKZ/01e0da1578.png
这是数据库,AcctNo
应该全部打印在文档的最后一个表单上,
问题是,我尝试用AccountList
编写代码,但它没有提取信息吗?
欢迎客户输入您的CID:
public partial class WelcomeCust : Form
{
OleDbConnection db = new OleDbConnection();
OleDbDataAdapter da = new OleDbDataAdapter();
DataTable dt = new DataTable();
public WelcomeCust()
{
InitializeComponent();
db.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\ChattBankMDB.mdb";
}
private void button1_Click(object sender, EventArgs e)
{
db.Open();
da = new OleDbDataAdapter("select Cid From Accounts", db);
}
}
输入Cid(客户ID)后,AcctNo
应该全部列出。
AccountsList:
class AccountList : Accounts
{
private static List<Accounts> custAccounts = new List<Accounts>();
private String userID = "";
public AccountList() {
}
public AccountList(String userID) {
this.userID = userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String getUserID() {
return this.userID;
}
public List<Accounts> getCustAccounts () {
return custAccounts;
}
public void clearAccounts() {
custAccounts.Clear();
}
}
如果问题需要,请至少使用帐户:
class Accounts
{
private String acctNo;
private String custId;
private String type;
private double balance;
private String message;
/**
* No-Arg Constructor
*/
/**
*sets account number
*@param acctNo
*/
public void setAcctNo(String acctNo) {
this.acctNo = acctNo;
}
/**
*sets customer id
* @param custId
*/
public void setCustId(String custId) {
this.custId = custId;
}
/**
* sets account type
* @param acctType
*/
public void setType(String type) {
this.type = type;
}
/**
* sets balance for the account
* @param balance
*/
public void setBalance(double balance) {
this.balance = balance;
}
/**
* returns account number
* @return String
*/
public String getAcctNo() {
return acctNo;
}
/**
* returns customer id
* @return String
*/
public String getCustId() {
return custId;
}
/**
* returns account type
* @return String
*/
public String getType() {
return type;
}
/**
* returns account balance
* @return double
*/
public double getBalance() {
return balance;
}
/**
* returns account information into string form
* @return String
*/
public String getAcct() {
return this.acctNo + " " + this.custId + " " + this.type + " " + this.balance;
}
/**
* returns message set by other methods in class
* @return String
*/
public String getMessage(){
return this.message;
}
}
最后:
以下是所有应在listbox1上打印出来的表单。
public partial class AllAccounts : Form
{
public AllAccounts()
{
InitializeComponent();
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}