loading.cs
上传用户:zhongfine
上传日期:2022-08-01
资源大小:2860k
文件大小:5k
- 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 System.Data.SqlClient;
- namespace 人事管理系统
- {
- public partial class loading : Form
- {
- Datacon mydatacon = new Datacon();
- password mypassword = new password();
- public loading()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.HideForm1.Start();
-
-
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //timer控件ShowForm1
- this.ShowForm1.Enabled = true; //控件是否激活
- this.ShowForm1.Interval = 50; //Elapsed 事件的频率
- //timer控件HideForm1
- this.HideForm1.Enabled = false;
- this.HideForm1.Interval = 30;
- this.Opacity = 0.0; //设置窗体透明度
- ShowForm1.Start(); //timer控件 ShowForm1开始
- }
- private void ShowForm1_Tick(object sender, EventArgs e)
- {
- if (this.Opacity == 1) //如果窗体透明度达到 1
- {
- this.ShowForm1.Stop();
- }
- else //透明度小于 1
- {
- this.Opacity = this.Opacity + 0.1; //透明度递增
- }
- }
- private void HideForm1_Tick(object sender, EventArgs e)
- {
- this.Opacity = this.Opacity - 0.1; //透明度不等于 0
- if (this.Opacity == 0) //透明度等于 0
- {
- this.HideForm1.Stop();
- Application.Exit();//退出系统,程序结束
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (user.Text == "")
- {
- MessageBox.Show("用户名不能为空!");
- return;
- }
- else
- if (password.Text == "")
- {
- MessageBox.Show("密码不能为空!");
- return;
- }
- else
- if (login_style.Text == "")
- {
- MessageBox.Show("请选择登陆方式!");
- return;
- }
-
-
- if (user.Text != "" && password.Text != "" && login_style.Text!= "")//如果三者都不为空,继续
- {
- SqlConnection sqlcn = mydatacon.getcon();//调用类mydatacon里面的连接字符串函数getcon()
-
-
- sqlcn.Open();//连接打开
- SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM [PERSON] WHERE ID='" + this.user.Text + "'", sqlcn);
- string q = cmd.ExecuteScalar().ToString();//用q来记录表PERSON中有没有该用户名存在
- SqlCommand hcmd = new SqlCommand("SELECT COUNT(*) FROM [PERSON] WHERE ID='" + this.user.Text + "'and PASSWD='" +mypassword.OUT(this.password.Text)+ "'and AUTHORITY='"+this.login_style.Text+"'", sqlcn);
- string t = hcmd.ExecuteScalar().ToString();//用t来记录表PERSON中有没有满足用户登陆方式的与之相对应的帐号与密码
- cmd.Connection.Close();
- if (q == "0")//q为0表示不存在这样的情况
- {
- MessageBox.Show("用户名不存在!");
- return;
- }
- else
- if (t == "1")//t为1表示这样的情况存在,且只有一种
- {
- sqlcn.Open();
- major mymajor = new major();
- String mysql = "SELECT NAME FROM [PERSON] where ID='" + this.user.Text + "' ;";
- SqlCommand sqlcm = new SqlCommand(mysql, sqlcn);
- SqlDataReader dr = sqlcm.ExecuteReader();
- dr.Read();//读取当前登陆用户的姓名
- mymajor.label9.Text = dr["NAME"].ToString();
- mymajor.label10.Text = this.login_style.Text;//将该用户的姓名与登陆方式传递给主界面上的lable控件
- mymajor.label14.Text = this.user.Text;
- this.Hide();
- mymajor.Show();//主窗口显示
- sqlcn.Close();
- }
- else
- {
- MessageBox.Show("密码不正确!");
- return;
- }
- }
-
- }
- }
- }