C#关于this.Tag问题,求大神解决!!!!
privatevoidbutClose_Click(objectsender,EventArgse){if((int)(this.Tag)==1)------>错误地方{...
private void butClose_Click(object sender, EventArgs e)
{
if ((int)(this.Tag) == 1) ------>错误地方
{
DataClass.MyMeans.Login_n = 3;
Application.Exit();
}
else
if ((int)(this.Tag) == 2) ------>错误地方
this.Close();
}
private void butLogin_Click(object sender, EventArgs e)
{
if (textName.Text != "" & textPass.Text != "")
{
SqlDataReader temDR = MyClass.getcom("select * from tb_Login where Name='" + textName.Text.Trim() + "' and Pass='" + textPass.Text.Trim() + "'");
bool ifcom = temDR.Read();
if (ifcom)
{
DataClass.MyMeans.Login_Name = textName.Text.Trim();
DataClass.MyMeans.Login_ID = temDR.GetString(0);
DataClass.MyMeans.My_con.Close();
DataClass.MyMeans.My_con.Dispose();
DataClass.MyMeans.Login_n = (int)(this.Tag); ------>错误地方
this.Close();
}
登陆代码是这样的。问题如图 展开
{
if ((int)(this.Tag) == 1) ------>错误地方
{
DataClass.MyMeans.Login_n = 3;
Application.Exit();
}
else
if ((int)(this.Tag) == 2) ------>错误地方
this.Close();
}
private void butLogin_Click(object sender, EventArgs e)
{
if (textName.Text != "" & textPass.Text != "")
{
SqlDataReader temDR = MyClass.getcom("select * from tb_Login where Name='" + textName.Text.Trim() + "' and Pass='" + textPass.Text.Trim() + "'");
bool ifcom = temDR.Read();
if (ifcom)
{
DataClass.MyMeans.Login_Name = textName.Text.Trim();
DataClass.MyMeans.Login_ID = temDR.GetString(0);
DataClass.MyMeans.My_con.Close();
DataClass.MyMeans.My_con.Dispose();
DataClass.MyMeans.Login_n = (int)(this.Tag); ------>错误地方
this.Close();
}
登陆代码是这样的。问题如图 展开
展开全部
private void butClose_Click(object sender, EventArgs e)
{
int r=0;
if (int.TryParse((string)this.Tag,out r)) {
if (r == 1) ------>错误地方
{
DataClass.MyMeans.Login_n = 3;
Application.Exit();
}
else
if (r == 2) ------>错误地方
this.Close();
}
}
private void butLogin_Click(object sender, EventArgs e)
{
if (textName.Text != "" & textPass.Text != "")
{
SqlDataReader temDR = MyClass.getcom("select * from tb_Login where Name='" + textName.Text.Trim() + "' and Pass='" + textPass.Text.Trim() + "'");
bool ifcom = temDR.Read();
if (ifcom)
{
DataClass.MyMeans.Login_Name = textName.Text.Trim();
DataClass.MyMeans.Login_ID = temDR.GetString(0);
DataClass.MyMeans.My_con.Close();
DataClass.MyMeans.My_con.Dispose();
int r=0;
if (int.TryParse((string)this.Tag,out r))
DataClass.MyMeans.Login_n =r; ------>错误地方
this.Close();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询