xtdl.cs

(开头部分) 3KB

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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using GongZi.GongZiClass;
namespace GongZi
{
    public partial class xtdl : Form
    {
        public xtdl()
        {
            InitializeComponent();
        }
        DBOperate operate = new DBOperate();//创建操作数据库对象
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //try
            //{
                if (txtUserName.Text == "" || txtUserPwd.Text == "")//判断用户名和密码是否为空
                {
                    MessageBox.Show("用户名或密码不能为空!",//弹出消息对话框
                        "提示", MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    return;//退出事件
                }
                else
                {
                    string name = txtUserName.Text.Trim();//移除用户名前部和后部的空格
                    string pwd = txtUserPwd.Text.Trim();//移除密码前部和后部的空格
                    SqlConnection conn = GongZiClass.DBConnection.MyConnection();//创建数据库连接对象
                    conn.Open();//连接到SQL数据库
                    SqlCommand cmd = new SqlCommand(//创建数据库命令对象
                        "select * from tb_User where UserName='" + 
                        name + "' and UserPwd='" + pwd + "'", conn);
                    SqlDataReader sdr = cmd.ExecuteReader();//得到数据读取器对象
                    sdr.Read();//读取一条记录
                    if (sdr.HasRows)//判断是否包含数据
                    {
                        string time = DateTime.Now.ToString();//得到系统时间字符串
                        string sql = "update tb_User set LoginTime='" //设置更新数据库的SQL语句
                            + time + "' where UserName='" + name + "'";
                        operate.OperateData(sql);//更新数据库内容
                        conn.Close();//关闭数据库连接
                        this.Hide();//隐藏窗体
                        Main Main = new Main();//创建主窗体对象
                        Main.User = name;//为主窗体字段赋值
                        Main.Logintime = time;//为主窗体字段赋值
                        Main.Show();//显示主窗体
                    }
                    else
                    {
                        txtUserName.Text = "";//清空用户名
                        txtUserPwd.Text = "";//清空密码
                        MessageBox.Show("用户名或密码错误!", "提示",//弹出消息对话框
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
后面还有 14 行代码,购买后查看完整代码

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

AI 解读 AI

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

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