快捷搜索:

您的位置:澳门新葡4473网站 > 热门贴子 > 密码修改

密码修改

发布时间:2020-01-31 11:47编辑:热门贴子浏览(68)

    SqlConnection con = new SqlConnection("server = .; uid = sa; pwd= sa; database = TY_Action");
          con.Open();
          
          string Temp=null;
          Temp+="update TY_User set UserPassword='{0}' where UserName="+"'"+name+"'";

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;
    using System.Configuration;
    using MySchoolModel;

          string sql=string.Format(Temp,this.textNewPassword.Text);

    namespace MySchoolDAL
    {
          public class Student
        {

          SqlCommand com=new SqlCommand(sql,con);
          com.ExecuteNonQuery();

              public bool IsLogin(string name, string pwd)
              {
                  bool flag = false;
                  try
                  {
                      string str = "data source=.; initial Catalog=MySchool; uid=sa;pwd=mnbv";
                      SqlConnection conn = new SqlConnection(str);
                      conn.Open();
                      string sql = "select count(1) from Admin where Name='"+name+"' and Pwd='"+pwd+"'";
                      SqlCommand cmd = new SqlCommand(sql,conn);
                      int num = Convert.ToInt32(cmd.ExecuteScalar());
                      if(num>0){
                          flag = true;
                      }
                  }
                  catch(Exception ex)
                  {
                      Console.WriteLine(ex.Message);
                  }
                  return true;
              }
           
              public bool Add(string name,string pwd)
              {
                  bool flag = false;
                  try
                  {
                     
                      string str = "data source=.; initial Catalog=MySchool; uid=sa;pwd=mnbv";
                      SqlConnection conn = new SqlConnection(str);
                      conn.Open();
                      string sql = "insert into Student values('"+name+"','"+pwd+"')";
                      SqlCommand cmd = new SqlCommand(sql, conn);
                      int num = Convert.ToInt32(cmd.ExecuteScalar());
                      if (num > 0)
                      {
                        
                      }
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine(ex.Message);
                  }
                  return true;
              }
              public static List<Student> Const()
              {
                  List<Student> list = new List<Student>();

          con.Close();

                  DataSet da = new DataSet();
                  string sql = "select * from Student";
                  SqlConnection conn = new SqlConnection(SqlHelper.ConStr);

          MessageBox.Show("修改密码成功","提示");

                  try
                  {
                      conn.Open();
                     
                      SqlCommand cmd = new SqlCommand(sql, conn);
                      SqlDataReader dr = cmd.ExecuteReader();
                      while (dr.Read())
                      {
                          Student st = new Student();

                          st.name = dr["name"].ToString();
                          st.pwd = dr["pwd"].ToString();
                         
                         
                          list.Add(st);
                      }
                      dr.Close();
                      return list;
                  }
                  catch (Exception ex)
                  {
                      throw ex;
                  }
                  finally
                  {
                      conn.Close();
                  }
                 
              }

     

     

     

              public string name { get; set; }

              public string pwd { get; set; }
        }
    }

     

    本文由澳门新葡4473网站发布于热门贴子,转载请注明出处:密码修改

    关键词: