예제 #1
0
        public Labsc SearchLabs(string Labcode)
        {
            cmd.CommandText = "SELECT * FROM labs WHERE labcode=@lbc";
            try
            {
                cmd.Parameters.AddWithValue("lbc", Labcode);
                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    Labsc u = new Labsc();
                    while (reader.Read())
                    {
                        u.Labcode = reader["labcode"].ToString();
                        u.Numstu  = reader["numstu"].ToString();
                    }

                    return(u);
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
            finally
            {
                con.Close();
            }
        }
예제 #2
0
        public List <Labsc> GetComLabs()
        {
            List <Labsc> studetails = new List <Labsc>();

            try
            {
                cmd.CommandText = "SELECT id AS 'Explorer',labcode AS 'Lab Code',numstu AS 'Stu Number' FROM labs WHERE fac='Business'";
                cmd.CommandType = CommandType.Text;

                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Labsc lecgv = new Labsc()
                    {
                        Id      = reader[0].ToString(),
                        Labcode = reader[1].ToString(),
                        Numstu  = reader[2].ToString(),
                    };
                    studetails.Add(lecgv);
                }
                return(studetails);
            }
            catch (Exception) { throw; }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
예제 #3
0
        // Labs

        public int AddLabs(Labsc lbd)
        {
            try
            {
                cmd.CommandText = "INSERT INTO labs(labcode,numstu,fac) VALUES (@lbc,@ns,'Business')";
                cmd.Parameters.AddWithValue("lbc", lbd.Labcode);
                cmd.Parameters.AddWithValue("ns", lbd.Numstu);

                con.Open();
                cmd.CommandType = CommandType.Text;
                return(cmd.ExecuteNonQuery());
            }
            catch (Exception) { throw; }
            finally
            {
                con.Close();
            }
        }
예제 #4
0
 public int UpdateComLabs(Labsc clbu)
 {
     try
     {
         cmd.CommandText = "UPDATE labs set labcode=@lbc, numstu=@ns, fac='Business' WHERE labcode=@lbc";
         cmd.Parameters.AddWithValue("lbc", clbu.Labcode);
         cmd.Parameters.AddWithValue("ns", clbu.Numstu);
         con.Open();
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (con != null)
         {
             con.Close();
         }
     }
 }
예제 #5
0
        public int DeleteComLabs(Labsc clbdel)
        {
            try
            {
                cmd.CommandText = "DELETE labs WHERE labcode=@lbc";
                cmd.Parameters.AddWithValue("lbc", clbdel.Labcode);
                cmd.CommandType = CommandType.Text;
                con.Open();

                return(cmd.ExecuteNonQuery());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }