登录界面:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace _123
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
private void quxaio_Click(object sender, EventArgs e)
{
MessageBox.Show("确定退出吗?");
this.Close();
}
private void denglu_Click(object sender, EventArgs e)
{
if (this.zhanghao.Text.Trim() == ""|this.mima.Text.Trim()=="")
{
if(this.zhanghao.Text.Trim()=="")
{
MessageBox.Show("帐号不能为空!请从洙新输入!");
}
else if (this.mima.Text.Trim() == "")
{
MessageBox.Show("密码不能为空!请从新输入!");
网页界面设计代码 }
}
else
{
string ConnStr = @"server=.;database=user_db;uid=sa;pwd=zhangrui;";
SqlConnection conn = new SqlConnection(ConnStr);
conn.Open();
string sql = "select * from tb_user where username='" + this.zhanghao.Text.Trim() + "' and paswd='" + this.mima.Text.Trim() + "'";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader read = cmd.ExecuteReader();
if (read.Read())
{
//MessageBox.Show("登录成功");
menu Menu = new menu();
Menu.ShowDialog(this);
this.Hide();
}
else
{
MessageBox.Show("用户名或密码错误,请从洙新输入!");
read.Close();
cmd.Clone();
conn.Close();
}
}
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论