- 博客(1)
- 资源 (1)
- 收藏
- 关注
翻译 JS年月日三级联动下拉框日期选择代码
3个 select下拉选择时间 html代码 <form name="reg_testdate"> <select name="YYYY" onChange="YYYYDD(this.value)"> <option value="">请选择 年</option> </select> &...
2020-04-27 14:40:57 1655 1
C#编程登陆界面代码
C#编程登陆界面代码
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.OleDb;
namespace 人事管理系统
{
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
private void FormLogin_Load(object sender, EventArgs e)
{
}
public void buttonLogin_Click_1(object sender, EventArgs e)
{
try
{
if (textBoxName .Text =="")
{
MessageBox.Show ("用户名不能为空!","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning );
}
else
{
if (textBoxPassword .Text =="")
{
MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
}
else
{
String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\人事数据库.mdb";
OleDbConnection conn = new OleDbConnection(connStr);
//String sql = "select count(*) from 用户密码表 where username='" + textBoxName.Text + "' and password='" + textBoxPassword.Text + "'";
conn.Open();
string sql = "select count(*) from 用户密码表 where username=@name and password=@pass";
OleDbCommand cmd = new OleDbCommand(sql ,conn );
cmd.Parameters.Add(new OleDbParameter ("@name",OleDbType .Char ));
cmd.Parameters["@name"].Value = textBoxName.Text;
cmd.Parameters.Add(new OleDbParameter("@pass", OleDbType.Char));
cmd.Parameters["@pass"].Value = textBoxPassword.Text;
//OleDbDataAdapter da = new OleDbDataAdapter(sql, conn);
//DataTable dt = new DataTable();
//da.Fill(dt);
//int i = dt.Rows.Count;
int i =(int )cmd.ExecuteScalar ();
conn.Close();
if (i > 0)
{
FormMain fm = new FormMain();
fm.admintime = DateTime.Now.ToShortDateString();
fm.adminname = textBoxName.Text;
fm.Show();
this.Hide ();
}
else
{
MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error );
{
textBoxName.Text = "";
textBoxPassword.Text = "";
textBoxName.Focus();
}
}
}
}
}
catch (Exception ex)
{ MessageBox.Show(ex.ToString()); }
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("您确定要退出本系统吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
Application.Exit();
}
}
private void textBoxName_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
textBoxPassword.Focus();
e.Handled = true;
}
}
private void textBoxPassword_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
buttonLogin.Focus();
e.Handled = true;
}
}
private void linkLabeladd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Form添加 fpty = new Form添加();
fpty.Show();
}
private void linkLabelpass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Formpasswordmodify fpmd = new Formpasswordmodify();
fpmd.Show();
}
}
}
2012-01-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人