如何创建一个表单来创建一个新帐户,然后在第二个表单中,您可以登录到已创建的帐户
本文关键字:创建 表单 一个 登录 何创建 新帐户 然后 第二个 | 更新日期: 2023-09-27 18:16:49
我想创建一个表单来创建一个新帐户,然后在第二个表单中您可以登录到已创建的帐户。
这是第一个屏幕这是第二个
下面是创建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)
{
}
}
}
Null reference Exception未处理
当我尝试创建一个新帐户
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);
}
}
}