基本信息
源码名称:学生成绩信息系统
源码大小:81.12M
文件格式:.zip
开发语言:C#
更新时间:2016-08-15
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

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

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



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 Student
{
    public partial class land : Form
    {
        public land()
        {
            InitializeComponent();
        }

       

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            { MessageBox.Show("用户名不能为空!", "提示"); textBox1.Focus(); }
            else if (textBox2.Text == "")
            { MessageBox.Show("密码不能为空!", "提示"); textBox2.Focus(); }
            else
            {
                try     //try...catch...异常处理语句
                {
                    string usr,pwd,pwdm;
                    bool flag = false;
                    usr = textBox1.Text.Trim();
                    pwd = textBox2.Text.Trim();
                    pwdm =DESEncrypt.Encrypt(pwd);  //密码加密
                    SqlConnection myConn = new SqlConnection(comm.str_sql_sever);//创建数据库连接类的对象
                    myConn.Open();    //将连接打开
                    string sqlstring = "select usr,pwd from users where usr='" usr "'and pwd='" pwdm "'";
                    SqlCommand command = new SqlCommand(sqlstring, myConn);
                    SqlDataReader thisReader = command.ExecuteReader();

                    while (thisReader.Read())  //判断用户名及密码是否正确,对flag进行赋值
                    {
                        if ((thisReader.GetValue(0).ToString().Trim()) == (usr.ToString().Trim()))
                        {
                            if (thisReader.GetValue(1).ToString().Trim() == pwdm.ToString().Trim())
                            {
                                flag = true;
                            }
                        }
                    }
                    myConn.Close();  //关闭连接
                    if (flag)
                    {
                        comm.current_user = usr;
                        comm.login_time = DateTime.Now.ToString();
                        Log log = new Log(AppDomain.CurrentDomain.BaseDirectory @"/log/Log.txt");
                        log.log("用户" comm.current_user "登录系统");
                        main f = new main();
                        f.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("请检查你的用户名和密码!", "提示");
                        textBox2.Text = "";
                        textBox1.Focus();
                    }
                }
                catch (Exception ex2)
                {
                    MessageBox.Show("连接SQL数据库发生错误:" ex2.ToString(), "错误!");
                }
            }
        }

        private void land_Load(object sender, EventArgs e)
        {
            IniFile f = new IniFile();
            f.ReadIni();
           
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            frm_sz f= new frm_sz();
            f.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //使登陆的窗口以0.05秒渐渐的清晰
            if (this.Opacity < 1)
            {
                this.Opacity = 0.1;
            }
            else
            {
                timer1.Enabled = false;
            }
        }

        private void panel2_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}