请问如何用C#编写用户登陆界面,最好带一个简单的示例。谢谢!
解决方案 »
- 【WIN32API】监控发生复制操作的窗口(word、pdf reader等)当前打开的文件的路径
- 正则表达式获取回复内容中的数字号码
- 文件拖放时候鼠标跟随的图标
- 关于如何显示数据的问题
- 项目中的最后一个亟待解决的小问题,回答者给分!!!
- 求最新 全国 区号 邮政编码数据库
- 我要在页面的Page_Load里执行一个发邮件的函数,页面只有这个功能,防止别人重复刷新重复提交,请指教
- 急!!高分求关于水晶报表Web服务的数据源绑定问题!!!!!
- visual studio 的安装项目中,怎么设置把一个dll安装到GAC中
- 谁来帮帮我?????
- 节假日提个小问题
- 多个项目时如何发布.................................在线等......急!!!!!!!!!!!!!!!!!!!
2个文本框输入用户名秘密,在BUTTON下查询两个输入结果,与数据库相应的字段匹配,如果匹配,。如果不匹配,提示错误,文本清空
{
MessageBox.Show("请输入用户名和密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
try
{
myConnection = new SqlConnection(Login.Connection);
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "SELECT UserSort " +
"From Users " +
"Where UserID = '" + txtUser.Text +
"' And UserPassword = '" + txtPassword.Text + "'";
myConnection.Open();
Sort = myCommand.ExecuteReader();
try
{
Sort.Read();
//如果由返回的项得到 “System”,则弹出完整功能界面
if (Sort.GetString(0) == "System")
{
this.Hide();
MMForm.ManageForm myMF = new MMForm.ManageForm(true);
myMF.ShowDialog();
this.Close(); //在主功能界面退出后同时关闭登录界面
}
//如果由返回的项得到 "User" ,则屏蔽用户信息维护功能
if (Sort.GetString(0) == "User")
{
this.Hide();
MMForm.ManageForm myMF = new MMForm.ManageForm(false);
myMF.ShowDialog();
this.Close(); //在主功能界面退出后同时关闭登录界面
}
}
catch
{
MessageBox.Show("请输入正确的用户名和密码!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
catch (SqlException ex)
{
MessageBox.Show("连接数据库错误:" + ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close(); //释放数据库连接
}
{
MessageBox.Show("请输入用户名和密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
try
{
myConnection = new SqlConnection(Login.Connection);
SqlCommand myCommand = myConnection.CreateCommand();
myCommand.CommandText = "SELECT UserSort " +
"From Users " +
"Where UserID = '" + txtUser.Text +
"' And UserPassword = '" + txtPassword.Text + "'";
myConnection.Open();
Sort = myCommand.ExecuteReader();
try
{
Sort.Read();
//如果由返回的项得到 “System”,则弹出完整功能界面
if (Sort.GetString(0) == "System")
{
this.Hide();
MMForm.ManageForm myMF = new MMForm.ManageForm(true);
myMF.ShowDialog();
this.Close(); //在主功能界面退出后同时关闭登录界面
}
//如果由返回的项得到 "User" ,则屏蔽用户信息维护功能
if (Sort.GetString(0) == "User")
{
this.Hide();
MMForm.ManageForm myMF = new MMForm.ManageForm(false);
myMF.ShowDialog();
this.Close(); //在主功能界面退出后同时关闭登录界面
}
}
catch
{
MessageBox.Show("请输入正确的用户名和密码!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
catch (SqlException ex)
{
MessageBox.Show("连接数据库错误:" + ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
myConnection.Close(); //释放数据库连接
}