Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70665
  • 博文数量: 42
  • 博客积分: 2025
  • 博客等级: 大尉
  • 技术积分: 437
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-03 12:17
文章分类

全部博文(42)

文章存档

2010年(12)

2009年(30)

我的朋友

分类:

2010-08-17 23:15:58

User.cs文件
using System;
using System.Collections.Generic;
using System.Text;
namespace workpeople
{
    public class User
    {
        private int _ID;
        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        private string _UserName;
        public string UserName
        {
            get { return _UserName; }
            set { _UserName = value; }
        }
        private string _Password;
        public string Password
        {
            get { return _Password; }
            set { _Password = value; }
        }
    }
}
 
FrmLogin.cs文件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.IO;
 
namespace workpeople
{
   
    public partial class FrmLogin : Form
    {
        private MySqlCommand mycomm;
        private MySqlDataAdapter myadap;
        private MySqlDataReader dr;
        public FrmLogin()
        {
            InitializeComponent();
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
           
            //string M_str_sqlcon = "server=localhost;user id=mm03;password=mm03123;database=studb";
            //MySqlConnection myCon = new MySqlConnection(M_str_sqlcon);
         
            //myCon.Open();
            //string sql = "select uname as 用户名,paswd as 密码 from uinfo";
            //mycomm = new MySqlCommand(sql, myCon);
            //MySqlDataAdapter myadap = new MySqlDataAdapter(mycomm);
            //DataSet ds = new DataSet();
            //myadap.Fill(ds, "uinfo");
            //dataGridView1.DataSource = ds.Tables[0].DefaultView;
           
            ////dr = mycomm.ExecuteReader();
            ////while (dr.Read())
            ////{
            ////    MessageBox.Show(dr["uname"].ToString());
            ////}
            ////mycomm.Dispose();
            //myCon.Close();
            User user = new User();
            user.UserName = txtUsername.Text.Trim();
            user.Password = txtPassword.Text;
            this.Tag = user;
          this.DialogResult = DialogResult.OK;  //如果验证通过,则转到系统主界面
        }
        private void FrmLogin_Load(object sender, EventArgs e)
        {

         
        }
       
    }
}
 
FrmMain.cs文件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace workpeople
{
    public partial class FrmMain : Form
    {
        public FrmMain()
        {
            InitializeComponent();
        }
        private void FrmMain_Load(object sender, EventArgs e)
        {
            FrmLogin frm = new FrmLogin();
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                User user = frm.Tag as User;

                this.Text += string.Format("-  欢迎:  {0}", user.UserName);
            }
            else
            {
                this.Close();
            }

        }
    }
}
 
阅读(314) | 评论(0) | 转发(0) |
0

上一篇:CKEditor用法

下一篇:没有了

给主人留下些什么吧!~~