求助:c#窗体初始化异常

图片说明

namespace AutoShop
{
public partial class Form1 : Form
{
///
/// 数据库连接字符串
///
private static string cgConnstr = System.Configuration.ConfigurationManager.ConnectionStrings["DBconnStr"].ToString();
DataAccess dataAcc = new DataAccess(cgConnstr);
List admins = null;
public Form1()
{
InitializeComponent();
}

    private void button1_Click(object sender, EventArgs e)
    {
        string loginName = txtName.Text,pwd=txtPwd.Text;
        int statue = 0;
        foreach (Administer admin in admins)
        {
            if (admin.phoneNum.Equals(loginName))
            {
                statue = 1;
                if (admin.password.Equals(pwd))
                {
                    MessageBox.Show("登录成功!");
                }
                else
                    MessageBox.Show("密码不正确!");
                break;
            }
        }
        if (statue == 0)
        {
            MessageBox.Show("不存在用户名!");
        }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        admins = dataAcc.GetAdministers();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        JoinForm join=new JoinForm();
        join.Show();
    }
}

}

查看全部
qq_41087101
巴格梅
2019/04/29 17:37
  • c#
  • visual studio
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复