Exemplo n.º 1
0
        public Modulesc SearchModules(string Modcode)
        {
            cmd.CommandText = "SELECT * FROM modules WHERE modcode=@mc";
            try
            {
                cmd.Parameters.AddWithValue("mc", Modcode);
                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    Modulesc u = new Modulesc();
                    while (reader.Read())
                    {
                        u.Modcode = reader["modcode"].ToString();
                        u.Modname = reader["modname"].ToString();
                        u.Lecname = reader["lecname"].ToString();
                    }

                    return(u);
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 2
0
        public List <Modulesc> GetComModules()
        {
            List <Modulesc> studetails = new List <Modulesc>();

            try
            {
                cmd.CommandText = "SELECT id AS 'Explorer',modcode AS 'Mode Code',modname AS 'Mode Name',lecname AS 'Lec Name' FROM modules WHERE fac='Business'";
                cmd.CommandType = CommandType.Text;

                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Modulesc lecgv = new Modulesc()
                    {
                        Id      = reader[0].ToString(),
                        Modcode = reader[1].ToString(),
                        Modname = reader[2].ToString(),
                        Lecname = reader[3].ToString(),
                    };
                    studetails.Add(lecgv);
                }
                return(studetails);
            }
            catch (Exception) { throw; }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 3
0
        public int AddModules(Modulesc md)
        {
            try
            {
                cmd.CommandText = "INSERT INTO modules(modcode,modname,lecname,fac) VALUES (@mc,@mn,@l,'Business')";
                cmd.Parameters.AddWithValue("mc", md.Modcode);
                cmd.Parameters.AddWithValue("mn", md.Modname);
                cmd.Parameters.AddWithValue("l", md.Lecname);

                con.Open();
                cmd.CommandType = CommandType.Text;
                return(cmd.ExecuteNonQuery());
            }
            catch (Exception) { throw; }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 4
0
        public int DeleteComModules(Modulesc cmdel)
        {
            try
            {
                cmd.CommandText = "DELETE modules WHERE modcode=@mc";
                cmd.Parameters.AddWithValue("mc", cmdel.Modcode);
                cmd.CommandType = CommandType.Text;
                con.Open();

                return(cmd.ExecuteNonQuery());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 5
0
 public int UpdateComModules(Modulesc cmu)
 {
     try
     {
         cmd.CommandText = "UPDATE modules set modcode=@mc, modname=@mn, lecname=@ln, fac='Business' WHERE modcode=@mc";
         cmd.Parameters.AddWithValue("mc", cmu.Modcode);
         cmd.Parameters.AddWithValue("mn", cmu.Modname);
         cmd.Parameters.AddWithValue("ln", cmu.Lecname);
         con.Open();
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (con != null)
         {
             con.Close();
         }
     }
 }