当用户登陆验证通过后,要调用一个新窗体,然后把登陆窗体给御掉,请问该怎样写?谢谢
解决方案 »
- 菜鸟求解~~~
- 匹配文章中含有“FTP-QUEUE-CEN”字符窜的正则表达式如何写
- C#如何提取一个数组中的元素不在另一数组中?
- 请问在程序中如何调用某个Button事件
- (急)如何保持dataset的内容到数据库
- 怎么把字符串"ad你好bd|123"以"|"分为"ad你好bd"和"123"两部分
- C#中怎样去除字符串中的回车?
- RDLC报表中使用矩阵时数据列如何自动累加;筛选器如何实现启用或禁用
- 求助:::ServerVersion = “sqlconn.ServerVersion”引发了“System.InvalidOperationException”类型的异常
- web form 中如何从一个form提交到另一个form
- 高手请进,高分请教!!
- 通过事件窗体A显示窗体B,通过窗体B的事件更新窗体A的数据;谢谢!!在线等!!
在“确定”按钮的响应事件里:
if(idText.Text == "id" & pswText.Text == "psw")
{
NewForm f = new NewForm();
f.Show();
this.Hide();
}
我感觉也 没有必要去隐藏他 Login Form=new Login();
Form.StartPosition=FormStartPosition.CenterScreen;
if(Form.ShowDialog()==DialogResult.OK)
{
Form.Show();
}
三楼的"在原来的窗体上完成新页加载",请详细一些,本人以前用VB,现在初学C#,望指教.谢谢!
using System.Threading;
private void button2_Click(object sender, System.EventArgs e)
{
//调用zhuangtai5
ZhuangTai=new Thread(new ThreadStart(zhuangtai5));
ZhuangTai.Start();
}
//点击系统信息后的状态
private void zhuangtai5()
{
string path = Application.StartupPath ;
Ini ini = new Ini(path+"\\Set.ini");
this.label9.Image=this.button2.Image; this.label9.Text=" "+this.button2.Text;
this.button1.Enabled=true;
this.textBox6.Text="";
this.panel2.Visible=true;
this.button2.Enabled=true;
this.button3.Enabled=true;
this.button4.Enabled=true;
this.label11.Visible=false;
this.textBox10.Visible=false;
this.button5.Visible=false;
this.button6.Visible=false;
this.label12.Visible=false;
this.button7.Visible=false;
this.label13.Visible=false;
this.label14.Visible=false;
this.label15.Visible=false;
this.label16.Visible=false;
this.label18.Visible=false;
this.label19.Visible=false;
this.label20.Visible=false;
this.label21.Visible=false;
this.textBox14.Visible=false;
this.textBox11.Visible=false;
this.textBox12.Visible=false;
this.textBox13.Visible=false;
this.button8.Visible=false;
this.button9.Visible=false;
this.button10.Visible=false;
this.button11.Visible=false;
this.textBox15.Visible=false;
this.textBox16.Visible=true;
this.textBox17.Visible=true;
this.textBox18.Visible=true;
this.textBox19.Visible=true;
this.button12.Visible=true;
this.label26.Visible=true;
this.button13.Visible=true;
this.label27.Visible=true;
this.button14.Visible=true;
this.label28.Visible=true;
this.button15.Visible=true;
this.label29.Visible=true;
this.label30.Visible=true;
this.label31.Visible=true;
this.label32.Visible=true;
this.label33.Visible=true;
this.label34.Visible=true;
this.label30.Text=ini.IniReadValue("CPUInfo","CpuN");
this.label31.Text=ini.IniReadValue("CPUInfo","CpuT");
this.label32.Text=ini.IniReadValue("CPUInfo","CpuS");
this.label33.Text=ini.IniReadValue("CPUInfo","CpuI");
this.label34.Text=ini.IniReadValue("CPUInfo","CpuB");
}
private void button1_Click(object sender, System.EventArgs e)
{
if (textUser.Text=="" || textPass.Text=="" )
{
string msg="用户名、密码不能为空!";
MessageBox.Show(msg,"提示");
return;
}
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = chillcoder.mdb " ;
OleDbConnection chkconn = new OleDbConnection(strCon);
string testsql="select count(*) from cc_admin where username='"+textUser.Text.ToString()+"'and password='"+textPass.Text.ToString()+"'"; chkconn.Open();
OleDbCommand chkcmd = new OleDbCommand(testsql,chkconn);
int Count=(int)chkcmd.ExecuteScalar();
chkconn.Close();
if(Count==0)
{
MessageBox.Show("没有这个用户!请核对您是否输入正确!","提示!");
textUser.Text="";
textPass.Text="";
return;
}
try
{
this.Hide();
MainForm frm=new MainForm();
frm.ShowDialog();
frm.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
} }
public bool UserCanCannel = false; //用户有退出权限
public frmSystemMain CloseForm;
private void butOk_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("用户名称不能为空!");
}
else
{
switch (textBox1.Text)
{
case "001":
if (textBox2.Text != "002")
{
MessageBox.Show("密码不正确!请重新输入!");
}
else
{
UserCanCannel = true;
}
break;
case "RECON_E":
if (textBox2.Text != "E_RECON")
{
MessageBox.Show("密码不正确!请重新输入!");
}
else
{
UserCanCannel = true;
}
break;
}
}
if (UserCanCannel)
{
this.Visible = false;
this.Close();
CloseForm.Close();
}
}
运行程序时CloseForm.Close();这个报错,请高手解释解释,并且希望告诉实现方法!谢谢!