formlogin.cs

来自「数据库开发与实例(1+1混合数据库开发实例丛书)人事管理系统的源代码」· CS 代码 · 共 56 行

CS
56
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HRMan
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
            fl = this;
        }

        private void FormLogin_Load(object sender, EventArgs e)
        {
            string SqlText = "select * from UserInfo";
            DataAccess DA = new DataAccess();
            DataTable dt = new DataTable();
            dt = DA.ExeSQLdt(SqlText);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.comboBox1.Items.Add(dt.Rows[i]["uName"].ToString());
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string SqlText = "select * from UserInfo where uName='" + this.comboBox1.Text + "' and uPassword='" + this.textBox1.Text + "'";
            DataAccess DA = new DataAccess(); 
            if (DA.IsRead(SqlText) == true)
            {
                string ss = "select * from UserInfo where uName='" + this.comboBox1.Text + "'";
                DataTable dt = DA.ExeSQLdt(ss);
                this.Competence = dt.Rows[0]["uPower"].ToString();
                FormLogin.Can = true;
                this.Close();
                
            }
            else
            {
                MessageBox.Show("用户和密码不一致!");
            }
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?