Esempio n. 1
0
        public List <IPlacementConsultant> SelectPlacementConsultantIfExistsisActive(string placementConsultantName)
        {
            //ADO.NET program for retriving placement consultant
            SqlConnection connection = DBUtility.GetConnection();

            using (connection)
            {
                SqlCommand    cmd = new SqlCommand();
                SqlDataReader r;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "sp_SelectPlacementConsultantIfExistsinActive_667437";
                cmd.Connection  = connection;
                cmd.Parameters.AddWithValue("@placementconsultantname", placementConsultantName);


                connection.Open();
                placementConsultantList.Clear();
                // Displaying normally placement consultant who is inactive
                r = cmd.ExecuteReader();
                while (r.Read())
                {
                    int    PlacementConsultantID      = r.GetInt32(0);
                    string consultantName             = r.GetString(1);
                    string placementConsultantDetails = r.GetString(2);
                    placementConsultant = PlacementConsultantFactory.CreatePlacementConsultant(PlacementConsultantID, consultantName, placementConsultantDetails);
                    placementConsultantList.Add(placementConsultant);
                }

                connection.Close();
            }
            return(placementConsultantList);
        }
        // To retrieve all the placement consultants
        public List <IPlacementConsultant> getPlacementConsultants()
        {
            List <IPlacementConsultant> lstPlacementConsultant = new List <IPlacementConsultant>();
            SqlCommand    mycommand;
            SqlConnection myconnection = DBUtility.getConnection();

            try
            {
                using (myconnection)
                {
                    mycommand             = new SqlCommand("sp_getPlacementConsultants", myconnection);
                    mycommand.CommandType = CommandType.StoredProcedure;
                    myconnection.Open();
                    SqlDataReader objSqlDataReader = mycommand.ExecuteReader();


                    while (objSqlDataReader.Read())
                    {
                        int    PlacementConsultantID   = Int32.Parse(objSqlDataReader["PlacementConsultantID"].ToString());
                        string PlacementConsultantName = (string)objSqlDataReader["PlacementConsultantName"];
                        string password = (string)objSqlDataReader["Password"];
                        string details  = (string)objSqlDataReader["Details"];


                        IPlacementConsultant objPlacementConsultant = PlacementConsultantFactory.Create_PlacementConsultant(PlacementConsultantID, PlacementConsultantName, password, details);

                        lstPlacementConsultant.Add(objPlacementConsultant);
                    }
                    objSqlDataReader.Close();
                }
                return(lstPlacementConsultant);
            }

            catch (Exception EE)
            {
                Console.WriteLine(EE);
                Console.Read();
                return(null);
            }
            finally
            {
                myconnection.Close();
            }
        }