FrmLogin.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WinStudent
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            //获取用户输入信息
            string uName=txt_account.Text.Trim();
            string uPwd=txt_pwd.Text.Trim();
            //判断是否为空
            if(string.IsNullOrEmpty(uName))
            {
                MessageBox.Show("请输入账号!","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                txt_account.Focus();//定位焦点
                return;
            }
            if (string.IsNullOrEmpty(uPwd))
            {
                MessageBox.Show("请输入密码!", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_pwd.Focus();//定位焦点
                return;
            }
            //与数据库通信,检查输入与数据库中是否一致
            {
                /* //1.建立连接
                 //连接字符串---钥匙
                 //string connString = "server=.;database=StudentDB;Intergrated Security=true";//Windows身份验证字符串
                 string connString = "server=.;database=StudentDB;uid=Shawn;pwd=123456;";//SQLServer身份验证字符串
                 //Server 身份验证,DataBase 数据库,Initial Catalog ,User Id,Password

                 SqlConnection conn = new SqlConnection(connString);
                 //2.写查询语句
                 string sql="select count(1) from UserInfo where UserName=" +
                     "@UserName and UserPwd=@UserPwd";
                 //添加参数
                 //SqlParameter paraUName = new SqlParameter("@UserName", uName);
                 //SqlParameter paraUPwd = new SqlParameter("@UserName", uPwd);
                 SqlParameter[] paras =
                 {
                     new SqlParameter("@UserName",uName),
                     new SqlParameter("@UserPwd",uPwd)
                 };
                 //3.创建Command对象
                 SqlCommand cmd = new SqlCommand(sql,conn);
后面还有 52 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。