예제 #1
0
        public User getUser(string _login, string _pass)
        {
            User u = null;

             try
             {
                 conn = db.openConn();
                 sb = new StringBuilder();
                 sb.Remove(0, sb.Length);
                 sb.Append(" select name,login,password,level_no,create_date,status from  users");
                 sb.Append(" where  login  ='******'");
                 sb.Append(" and  password  ='******'");

                 string sql;
                 sql = sb.ToString();
                 comm = new SqlCommand();
                 comm.CommandText = sql;
                 comm.CommandType = CommandType.Text;
                 comm.Connection = conn;
                 dr = comm.ExecuteReader();
                 if (dr.HasRows)
                 {

                     DataTable dt = new DataTable();
                     dt.Load(dr);
                     foreach (DataRow drw in dt.Rows)
                     {
                         u = new User();
                         u.Name = drw["name"].ToString();
                         u.Login = drw["login"].ToString();
                         u.Password = drw["password"].ToString();
                         u.LevelNo = drw["level_no"].ToString();
                         u.CreateDate = Convert.ToDateTime(drw["create_date"].ToString());
                         u.Status = drw["status"].ToString();

                     }
                 }

             }
             catch (Exception ex)
             {
                 dr.Close();
                 conn.Close();
                 return null;
                 throw ex;

             }
             finally
             {
                 conn.Close();
             }
             return u;
        }
예제 #2
0
 public frmMain(User _usr)
 {
     InitializeComponent();
     user = _usr;
 }