基本信息
源码名称:winform 登陆,修改简单功能实现,带数据库
源码大小:0.73M
文件格式:.rar
开发语言:C#
更新时间:2015-06-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
using System.Threading;


namespace JL
{
    public partial class Login : Form
    {
        
        
        public Login()
        {
            InitializeComponent();
        }

        private void Login_Load(object sender, EventArgs e)
        {
            DateTime dt = System.DateTime.Now;
            lab_systemtime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt);
            timer1.Start();
            this.FormClosed  = new FormClosedEventHandler(Login_FormClosed);

        }

        void Login_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btn_exit_Click(object sender, EventArgs e)
        {
            if ((MessageBox.Show("你确定要退出计量系统吗?", "提示:", MessageBoxButtons.OKCancel)).ToString().Equals(MessageBoxButtons.OK.ToString()))
            {
                Application.Exit();
            }
        }

        private void btn_login_Click(object sender, EventArgs e)
        {
            string suserid = this.txt_yhbm.Text.ToString().Trim();
            string userkl = this.txt_kl.Text.ToString().Trim();

            if (suserid == string.Empty)
            {
                MessageBox.Show("用户名不存在!", "登录失败!");
                return;
            }

            string constring = ConfigurationManager.ConnectionStrings["connString"].ConnectionString.ToString();

            SqlConnection conn = new SqlConnection(constring);

            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }

            string sql = "select userid,username from T_USERINFO where userid='"   suserid   "' and userpass='"   userkl   "'";

            SqlCommand cmd = new SqlCommand(sql, conn);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);

            string _userName = "";

            if (ds.Tables[0].Rows.Count == 1)
            {
                _userName = ds.Tables[0].Rows[0][1].ToString();
                userInfo.userId = suserid;
                userInfo.userName = _userName;
                userInfo.userPassWord = userkl;
                //ProBar pb = new ProBar();
                //pb.Show();
                formmain main = new formmain();
                main.Show();
                this.Hide();
                conn.Close();
            }
            else
            {
                this.txt_kl.Text = "";
                MessageBox.Show("您输入的密码不正确,请重新输入","提示");
            }

        }
       

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = System.DateTime.Now;
            lab_systemtime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dt);
        }



    }
}