2016-11-08 48 views
0

我想創建一個表單來創建一個新賬戶,然後以第二種形式登錄到賬戶已創建。如何創建一個表單來創建一個新賬戶,然後以第二種形式登錄到已創建的賬戶

this is the first screen this is the secound

這裏是創建BTN代碼:

public partial class NewAccountForm : Form 
{ 
    Accounts account1; 

    public NewAccountForm() 
    { 
     InitializeComponent(); 
    } 

    private void button2_Click(object sender, EventArgs e) 
    { 
     Form1 login = new Form1(); 
     this.Hide(); 
     login.Show(); 
    } 

    private void btncreat_Click(object sender, EventArgs e) 
    { 
     // here am lost 
     int interest = '0'; 
     char type = '0'; 
     double amount = '0' ; 
     double balance = '0'; 

     switch (cboType.SelectedIndex) 
     { 
      case 0: type = '1'; break; 
      case 1: type = '2'; break; 
     } 

     account1.setname(txtName.Text); 
     account1.setCode(txtpinCode.Text); 
     account1.setcontact(txtContact.Text); 

     Saveing cust1 = new Saveing(interest, txtName.Text, txtContact.Text, 
      txtpinCode.Text, type, amount,balance); 

     Data.CSaveing.Add(cust1); //SList shows because its static if remove static will not appears 

     txtName.Text = ""; 
     txtContact.Text = ""; 
     txtpinCode.Text = ""; 
    } 
} 

這是登錄表單代碼。

public partial class Form1 : Form 

    public Form1() 
    { 
     InitializeComponent(); 
    } 

    private void Form1_Load(object sender, EventArgs e) 
    { 
    } 

    private void label1_Click(object sender, EventArgs e) 
    { 
    } 

    private void textBox1_TextChanged(object sender, EventArgs e) 
    { 
    } 

    private void button1_Click(object sender, EventArgs e) 
    { 
     if (txtCode.Text.Equals(txtCode.Text)) 
     { 
      int i; 
      progressBar1.Maximum = 100; 
      progressBar1.Minimum = 0; 
      progressBar1.Step = 1; 
      timer1.Start(); 

      for (i = 0; i <= 50; i++) 
      { 
       progressBar1.Value = i; 
      } 
     } 
     else 
     { 
      MessageBox.Show("Please enter correct Pin Code"); 
     } 
    } 

    private void button2_Click(object sender, EventArgs e) 
    { 
     NewAccountForm naf = new NewAccountForm(); 
     this.Hide(); 
     naf.Show(); 
    } 

    private void timer1_Tick(object sender, EventArgs e) 
    { 
     progressBar1.PerformStep(); 
     if (progressBar1.Value == 99) 
     { 
      LoginForm login = new LoginForm(); 
      this.Hide(); 
      login.Show(); 
     } 
    } 

    private void label3_Click(object sender, EventArgs e) 
    { 
    } 

    private void label4_Click(object sender, EventArgs e) 
    { 
    } 
} 

}

+0

請添加您的第二種形式的代碼 – Jules

+0

是什麼賬戶呢? if(txtCode.Text.Equals(txtCode.Text))== if(true)?基本上你想要將所有的賬戶存儲在列表中。在您的NewAccountForm中添加一個帳戶到該列表。在您的LoginForm中迭代列表直到找到所需的帳戶。 – Skynet

+0

你有問題... [如何提出問題在SO](http://stackoverflow.com/help/mcve) – JohnG

回答

0

空Refrence異常是未處理

when i try do create a new account

public partial class NewAccountForm : Form 
{ 
    public NewAccountForm() 
    { 
     InitializeComponent(); 
    } 
    Accounts account1; 


    private void btnCreate_Click(object sender, EventArgs e) 
    { 




    } 

    private void button1_Click(object sender, EventArgs e) 
    { 

    } 

    private void button2_Click(object sender, EventArgs e) 
    { 
     Form1 login = new Form1(); 
     this.Hide(); 
     login.Show(); 
    } 

    private void btnlogout_Click(object sender, EventArgs e) 
    { 


     int interest = '0'; 
     char type = '0'; 
     double amount = '0' ; 
     double balance = '0'; 





     switch (cboType.SelectedIndex) 
     { 
      case 0: type = '1'; break; 

      case 1: type = '2'; break; 

     } 



     Saveing cust1 = new Saveing(interest, txtName.Text, txtContact.Text, 
      txtpinCode.Text, type, amount,balance); 

     Data.CSaveing.Add(cust1); //SList shows because its static if remove static will not appears 


     account1.setname(txtName.Text); 
     account1.setCode(txtpinCode.Text); 
     account1.setcontact(txtContact.Text); 




    } 
    } 
} 
相關問題