为什么它不去判断VU方法啊啊啊?~~~namespace 自作账号密码验证
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{
this.Close();
} private void button1_Click(object sender, EventArgs e)
{
bool VU = true;
string message = ""; if (VU)
{
if (comboBox1.Text == "管理员")
{
Form2 form2 = new Form2();
form2.Show();
this.Visible = false;
} }
}
public bool VU(string loginId, string loginPwd, string loginType, ref string message)
{
if (loginType == "管理员")
{
string sql = string.Format("SELECT COUNT (*) FROM Admin WHERE LoginId='{0}'AND LoginPwd='{1}'", loginId, loginPwd);
try
{
SqlCommand command = new SqlCommand(sql, DBHelper.connection);
DBHelper.connection.Open();
int count = (int)command.ExecuteScalar();
if (count < 1)
{
message = "!!!!!!!!";
return false;
}
else { return true; }
}
catch (Exception ex)
{
message = "suju!!!";
Console.WriteLine(ex.Message);
return true;
}
finally { DBHelper.connection.Close(); }
}
message = "xuanze!";
return false;
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{
this.Close();
} private void button1_Click(object sender, EventArgs e)
{
bool VU = true;
string message = ""; if (VU)
{
if (comboBox1.Text == "管理员")
{
Form2 form2 = new Form2();
form2.Show();
this.Visible = false;
} }
}
public bool VU(string loginId, string loginPwd, string loginType, ref string message)
{
if (loginType == "管理员")
{
string sql = string.Format("SELECT COUNT (*) FROM Admin WHERE LoginId='{0}'AND LoginPwd='{1}'", loginId, loginPwd);
try
{
SqlCommand command = new SqlCommand(sql, DBHelper.connection);
DBHelper.connection.Open();
int count = (int)command.ExecuteScalar();
if (count < 1)
{
message = "!!!!!!!!";
return false;
}
else { return true; }
}
catch (Exception ex)
{
message = "suju!!!";
Console.WriteLine(ex.Message);
return true;
}
finally { DBHelper.connection.Close(); }
}
message = "xuanze!";
return false;
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
这个VU使用的是局部变量bool VU = true; 与方法VU()无关
调用方法应该带括号。还应该有参数的
...
}
bool VU= true;
VU=VU();
if(VU)
{}public bool VU()
{
}如果VU()有参数就带参数
如果不影响你的结果的话,不知道的参数可用“”或者null代替
{
bool flag=true;
flag= VU();
}
public bool VU()
{
return true;//返回值
}
其实就是VU方法返回是true与false