//初始窗体计时器,时间到则进入登录窗体 private void Go_Tick(object sender, EventArgs e) { //打开背景图片窗体 FormWallpaper FormWallpaper = new FormWallpaper(); FormWallpaper.Show(); //打开登录窗体 FormLogin FormLogin = new FormLogin(); FormLogin.Show(); //隐藏当前窗体 this.Hide(); //停止事件生成 Go.Enabled = false; }
private void FormMain_Load(object sender, EventArgs e) { //如果用户在登陆窗体未输入用户名,控件信息则显示临时游戏数据 FormLogin FormLogin = new FormLogin(); FormLogin.Close(); if (FormLogin.uname == null) { textBox6.Text = yes.ToString(); textBox7.Text = no.ToString(); } else { //读取数据库并填充数据 string key = "Data Source=.;Initial Catalog=DongDongNao;Integrated Security=True"; SqlConnection conn = new SqlConnection(key); conn.Open(); string strSql = " SELECT * FROM DdnAdmin WHERE name='" + name + "' "; SqlCommand cmd = new SqlCommand(strSql, conn); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { string name = read["name"].ToString(); textBox1.Text = name; string grade = read["grade"].ToString(); textBox2.Text = grade; string UpEmpiricalValue = read["UpEmpiricalValue"].ToString(); textBox3.Text = UpEmpiricalValue; string ThisEmpiricalValue = read["ThisEmpiricalValue"].ToString(); textBox4.Text = ThisEmpiricalValue; string Title = read["Title"].ToString(); textBox5.Text = Title; string yes = read["yes"].ToString(); textBox6.Text = yes; string no = read["no"].ToString(); textBox7.Text = no; } conn.Close(); } }