private void stdexit_Click(object sender, EventArgs e)
 {
     f0 = new Form0();
     f0.Show();
     this.Close();
     f0.Show();
 }
Exemple #2
0
        private void shuaxin_Click(object sender, EventArgs e)
        {
            f0 = new Form0();
            string username = f0.userName;

            try
            {
                //获取所有用户信息
                //string sql = "select cjb.课程号,课程名,成绩 from cjb,kcb where cjb.课程号=kcb.课程号 and 学号=(select CardID from StdInfo where UserName=N'" + username + "')";
                string  sql = "select cjb.课程号,课程名,成绩 from cjb,kcb where cjb.课程号=kcb.课程号 and 学号=(select CardID from StdInfo where UserName=N'zhaojie')";
                DataSet ds  = SqlHelper.ExecuteDataset(conn, CommandType.Text, sql);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    //先清空列表
                    this.listView1.Items.Clear();

                    //有用户存在
                    //循环数据库中每一个用户信息,将每个姓名和班级当作一行存到列表变量中
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        //获取用户姓名信息
                        string cj = ds.Tables[0].Rows[i]["成绩"].ToString();

                        string kcm = ds.Tables[0].Rows[i]["课程名"].ToString();

                        string kch = ds.Tables[0].Rows[i]["课程号"].ToString();
                        //在列表第一列显示班级信息
                        ListViewItem lvi = new ListViewItem(kch);

                        //在列表第二列显示姓名信息
                        lvi.SubItems.Add(kcm);

                        lvi.SubItems.Add(cj);


                        this.listView1.Items.Add(lvi);
                    }
                }
                else
                {
                    //没有数据,将现有数据清空
                    this.listView1.Items.Clear();
                }
            }
            catch
            {
            }
        }
Exemple #3
0
        private void SureAlert_Click(object sender, EventArgs e)
        {
            f0 = new Form0();
            string newpassword  = NewPassword.Text;
            string surepassword = SurePassword.Text;
            string username     = f0.userName;
            string password     = f0.password;
            string type         = f0.type;

            try
            {
                if (OldPassword.Text == "" || OldPassword.Text == null)
                {
                    MessageBox.Show("请输入正确的旧密码");
                }
                else if (/*NewPassword.Text*/ newpassword == "" || /*NewPassword.Text*/ newpassword == null || /*SurePassword.Text*/ surepassword == "" || /*SurePassword.Text*/ surepassword == null)
                {
                    MessageBox.Show("请输入密码");
                }
                else if (Regex.IsMatch(newpassword, @"^[a-zA-Z0-9]\w{5,17}$") == false)
                {
                    MessageBox.Show("密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线");
                }
                else
                {
                    //  if (type == "学生")
                    //  {
                    string SelectSQL = "select * from StdInfo where UserName=N'" + username + "'";

                    DataSet ds       = SqlHelper.ExecuteDataset(conn, CommandType.Text, SelectSQL);
                    string  goodhash = ds.Tables[0].Rows[0]["Password"].ToString();

                    //判断用户输入的密码是否匹配
                    if (PasswordSecurity.PasswordStorage.VerifyPassword(password, goodhash))
                    {
                        if (newpassword != surepassword)
                        {
                            MessageBox.Show("两次输入的密码不一致");
                        }
                        else if (newpassword == surepassword)
                        {
                            try
                            {
                                int result;
                                password = PasswordSecurity.PasswordStorage.CreateHash(newpassword);
                                string alertSQL = "update StdInfo set Password ='******' where UserName = '******'";
                                result = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, alertSQL);

                                MessageBox.Show("密码修改成功,请重新登录");
                                f0 = new Form0();
                                f0.Show();
                                this.Close();
                            }
                            catch
                            {
                                MessageBox.Show("密码修改失败");
                            }
                        }
                        //   }
                    }
                }
            }
            catch
            {
                MessageBox.Show("密码修改失败");
            }
        }
 private void backandlogin_Click(object sender, EventArgs e)
 {
     this.Close();
     f0 = new Form0();
     f0.Show();
 }
 private void back_Click(object sender, EventArgs e)
 {
     f1 = new Form0();
     f1.Show();
     this.Close();
 }