예제 #1
0
        public static List <Lens> GetLens()
        {
            List <Lens>   LensList = new List <Lens>();
            SqlConnection conn     = GetConnection();
            string        QuerySel = "Select * from LensTable Order by Name_Lens";
            SqlCommand    SelComm  = new SqlCommand(QuerySel, conn);

            try
            {
                conn.Open();
                SqlDataReader reader = SelComm.ExecuteReader();
                while (reader.Read())
                {
                    Lens lens = new Lens();
                    lens.IdLens     = (int)reader["IdLens"];
                    lens.NameLens   = reader["NameLens"].ToString();
                    lens.Aperture   = (double)reader["Aperture"];
                    lens.NA         = (double)reader["NA"];
                    lens.ManualLens = reader["sManualLens"].ToString();
                    lens.MicroLens  = reader["sMicroLens"].ToString();
                    LensList.Add(lens);
                }
                reader.Close();
            }
            catch (SqlException ex) { throw ex; }
            finally { conn.Close(); }
            return(LensList);
        }
 public static List<Lens> GetLens()
 {
     List<Lens> LensList = new List<Lens>();
     SqlConnection conn = GetConnection();
     string QuerySel = "Select * from LensTable Order by Name_Lens";
     SqlCommand SelComm = new SqlCommand(QuerySel, conn);
     try
     {
         conn.Open();
         SqlDataReader reader = SelComm.ExecuteReader();
         while (reader.Read())
         {
             Lens lens = new Lens();
             lens.IdLens = (int)reader["IdLens"];
             lens.NameLens = reader["NameLens"].ToString();
             lens.Aperture = (double)reader["Aperture"];
             lens.NA = (double)reader["NA"];
             lens.ManualLens = reader["sManualLens"].ToString();
             lens.MicroLens = reader["sMicroLens"].ToString();
             LensList.Add(lens);
         }
         reader.Close();
     }
     catch (SqlException ex) { throw ex; }
     finally { conn.Close(); }
     return LensList;
 }