• 简单的登陆页面


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using 人事考勤系统;
    using System.Collections;
    using AnbySQL;

    namespace 人事考勤系统
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    private string logintype = "";
    public string Logintype
    {
    get { return combRole.Text; }
    }
    public string LoginID
    {
    get { return txtUserid.Text.Trim(); }
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    DataTable dt = new DataTable();
    List<string> role=new List<string>();
    string sql = "select * from UserInfo";
    dt= AnbySQL.DbHelperSQL.DataQuery(sql).Tables[0];
    for(int i=0;i<dt.Rows.Count;i++)
    {
    role.Add(dt.Rows[i]["username"].ToString());
    }
    combRole.DataSource = role;
    }

    private void btnLogin_Click(object sender, EventArgs e)
    {
    ChkContol();
    logintype = combRole.Text;
    DataTable dt =GoLogin();

    if (dt.Rows.Count > 0)
    {
    this.DialogResult= DialogResult.OK;
    }
    else
    MessageBox.Show("登录失败");
    }


    private DataTable GoLogin()
    {
    DataTable dt = new DataTable();
    string sql = "select count(*) from userinfo where username='" + txtUserid.Text.Trim() + "' and Password='" + txtPwd.Text.Trim() + "'";
    return dt = AnbySQL.DbHelperSQL.DataQuery(sql).Tables[0];
    }


    private void btnCancel_Click(object sender, EventArgs e)
    {
    Application.Exit();
    }

    public void ChkContol()
    {
    if (txtUserid.Text == "" || txtPwd.Text == "" || combRole.Text == "")
    {
    MessageBox.Show("用户名,密码,角色不能为空");
    }

    }
    }
    }

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;

    namespace 人事考勤系统
    {
    static class Program
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main()
    {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    Form1 frmLogin = new Form1();
    Form frmMain = null;
    if (frmLogin.ShowDialog() == DialogResult.OK)
    {
    frmMain = new 主界面();
    UserHelper.LoginID = frmLogin.LoginID;
    UserHelper.LoginType = frmLogin.Logintype;
    }
    Application.Run(frmMain);


    }
    }
    }

  • 相关阅读:
    mybatis
    eclipse日志
    最大值与最小值问题
    常见的缓存算法设计策略
    常用垃圾回收算法
    Java中对象的三种状态
    Java中的内存泄漏问题
    单例模式
    约瑟夫环问题
    矩形覆盖问题
  • 原文地址:https://www.cnblogs.com/anbylau2130/p/2732160.html
Copyright © 2020-2023  润新知