Exemplo n.º 1
0
        public int SaveLecturers(Lecturersc ld)
        {
            try
            {
                cmd.CommandText = "INSERT INTO lecturers(fname,lname,adone,adtwo,city,num,fac,modone,modtwo,modthree,jdate,rdate,username,password) VALUES (@fn,@ln,@ao,@at,@ct,@nm,@fc,@mo,@mtw,@mtr,@jd,@rd,@u,@p)";
                cmd.Parameters.AddWithValue("fn", ld.Fname);
                cmd.Parameters.AddWithValue("ln", ld.Lname);
                cmd.Parameters.AddWithValue("ao", ld.Adone);
                cmd.Parameters.AddWithValue("at", ld.Adtwo);
                cmd.Parameters.AddWithValue("ct", ld.City);
                cmd.Parameters.AddWithValue("nm", ld.Number);
                cmd.Parameters.AddWithValue("fc", ld.Faculty);
                cmd.Parameters.AddWithValue("mo", ld.Moduleone);
                cmd.Parameters.AddWithValue("mtw", ld.Moduletwo);
                cmd.Parameters.AddWithValue("mtr", ld.Modulethree);
                cmd.Parameters.AddWithValue("jd", ld.Jdate);
                cmd.Parameters.AddWithValue("rd", ld.Rdate);
                cmd.Parameters.AddWithValue("u", ld.Username);
                cmd.Parameters.AddWithValue("p", Encrypt(ld.Password));

                con.Open();
                cmd.CommandType = CommandType.Text;
                return(cmd.ExecuteNonQuery());
            }
            catch (Exception) { throw; }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 2
0
 public int UpdateLecturers(Lecturersc lu)
 {
     try
     {
         cmd.CommandText = "UPDATE lecturers set fname=@fname, lname=@lname, adone=@ao, adtwo=@at, city=@ct, num=@nm, modone=@mo, modtwo=@mtw, modthree=@mtr, rdate=@rd, username=@u, password=@p WHERE username=@u";
         cmd.Parameters.AddWithValue("u", lu.Username);
         cmd.Parameters.AddWithValue("fname", lu.Fname);
         cmd.Parameters.AddWithValue("lname", lu.Lname);
         cmd.Parameters.AddWithValue("ao", lu.Adone);
         cmd.Parameters.AddWithValue("at", lu.Adtwo);
         cmd.Parameters.AddWithValue("ct", lu.City);
         cmd.Parameters.AddWithValue("nm", lu.Number);
         cmd.Parameters.AddWithValue("mo", lu.Moduleone);
         cmd.Parameters.AddWithValue("mtw", lu.Moduletwo);
         cmd.Parameters.AddWithValue("mtr", lu.Modulethree);
         cmd.Parameters.AddWithValue("rd", lu.Rdate);
         cmd.Parameters.AddWithValue("p", Encrypt(lu.Password));
         con.Open();
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (con != null)
         {
             con.Close();
         }
     }
 }
Exemplo n.º 3
0
        // Computing Lecs And Stu

        public Lecturersc SearchLecsForm(string Username)
        {
            cmd.CommandText = "SELECT * FROM lecturers WHERE username=@u";
            try
            {
                cmd.Parameters.AddWithValue("u", Username);
                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    Lecturersc u = new Lecturersc();
                    while (reader.Read())
                    {
                        u.Fname       = reader["fname"].ToString();
                        u.Lname       = reader["lname"].ToString();
                        u.Adone       = reader["adone"].ToString();
                        u.Adtwo       = reader["adtwo"].ToString();
                        u.City        = reader["city"].ToString();
                        u.Number      = reader["num"].ToString();
                        u.Faculty     = reader["fac"].ToString();
                        u.Moduleone   = reader["modone"].ToString();
                        u.Moduletwo   = reader["modtwo"].ToString();
                        u.Modulethree = reader["modthree"].ToString();
                        u.Jdate       = reader["jdate"].ToString();
                        u.Rdate       = reader["rdate"].ToString();
                        u.Username    = reader["username"].ToString();
                        u.Password    = reader["password"].ToString();
                    }

                    return(u);
                }
                return(null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
            finally
            {
                con.Close();
            }
        }
Exemplo n.º 4
0
        public List <Lecturersc> GetBusinessLecturers()
        {
            List <Lecturersc> lecdetails = new List <Lecturersc>();

            try
            {
                cmd.CommandText = "SELECT id AS 'Explorer',fname AS 'First Name',lname AS 'Last Name',adone AS 'Address One',adtwo AS 'Address Two',city AS 'City',num AS 'Mobile Number',fac AS 'Faculty',modone AS 'Module One',modtwo AS 'Module Two',modthree AS 'Module Three',jdate AS 'Joined Date',rdate AS 'Resigned Date',username AS 'Username',password AS 'Password' FROM lecturers WHERE fac='Business'";
                cmd.CommandType = CommandType.Text;

                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Lecturersc lecgv = new Lecturersc()
                    {
                        Id          = reader[0].ToString(),
                        Fname       = reader[1].ToString(),
                        Lname       = reader[2].ToString(),
                        Adone       = reader[3].ToString(),
                        Adtwo       = reader[4].ToString(),
                        City        = reader[5].ToString(),
                        Number      = reader[6].ToString(),
                        Faculty     = reader[7].ToString(),
                        Moduleone   = reader[8].ToString(),
                        Moduletwo   = reader[9].ToString(),
                        Modulethree = reader[10].ToString(),
                        Jdate       = reader[11].ToString(),
                        Rdate       = reader[12].ToString(),
                        Username    = reader[13].ToString(),
                        Password    = reader[14].ToString()
                    };
                    lecdetails.Add(lecgv);
                }
                return(lecdetails);
            }
            catch (Exception) { throw; }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 5
0
        public Lecturersc SearchLecturers(Lecturersc r)
        {
            Lecturersc ld = new Lecturersc();

            try
            {
                cmd.CommandText = "SELECT * FROM lecturers WHERE username=@u AND fac='Business'";
                cmd.Parameters.AddWithValue("u", r.Username);
                cmd.CommandType = CommandType.Text;

                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ld.Fname       = reader[0].ToString();
                    ld.Lname       = reader[1].ToString();
                    ld.Adone       = reader[2].ToString();
                    ld.Adtwo       = reader[3].ToString();
                    ld.City        = reader[4].ToString();
                    ld.Number      = reader[5].ToString();
                    ld.Faculty     = reader[6].ToString();
                    ld.Moduleone   = reader[7].ToString();
                    ld.Moduletwo   = reader[8].ToString();
                    ld.Modulethree = reader[9].ToString();
                    ld.Jdate       = reader[10].ToString();
                    ld.Rdate       = reader[11].ToString();
                    ld.Username    = reader[12].ToString();
                }
                return(ld);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemplo n.º 6
0
        public int DeleteLecturers(Lecturersc ldel)
        {
            try
            {
                cmd.CommandText = "DELETE lecturers WHERE username=@u";
                cmd.Parameters.AddWithValue("u", ldel.Username);
                cmd.CommandType = CommandType.Text;
                con.Open();

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