Beispiel #1
0
 public int UpdateStudents(Studentsc lu)
 {
     try
     {
         cmd.CommandText = "UPDATE students set fname=@fname, lname=@lname, adone=@ao, adtwo=@at, city=@ct, num=@nm, nic=@nic, jdate=@jd, 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("nic", lu.Nic);
         cmd.Parameters.AddWithValue("Jd", lu.Jdate);
         cmd.Parameters.AddWithValue("p", Encrypt(lu.Password));
         con.Open();
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (con != null)
         {
             con.Close();
         }
     }
 }
Beispiel #2
0
        // Students Section

        public int SaveStudents(Studentsc sd)
        {
            try
            {
                cmd.CommandText = "INSERT INTO students(fname,lname,adone,adtwo,city,num,byear,nic,fac,jdate,username,password) VALUES (@fn,@ln,@ao,@at,@ct,@nm,@by,@n,@fc,@jd,@u,@p)";
                cmd.Parameters.AddWithValue("fn", sd.Fname);
                cmd.Parameters.AddWithValue("ln", sd.Lname);
                cmd.Parameters.AddWithValue("ao", sd.Adone);
                cmd.Parameters.AddWithValue("at", sd.Adtwo);
                cmd.Parameters.AddWithValue("ct", sd.City);
                cmd.Parameters.AddWithValue("nm", sd.Number);
                cmd.Parameters.AddWithValue("by", sd.Byear);
                cmd.Parameters.AddWithValue("n", sd.Nic);
                cmd.Parameters.AddWithValue("fc", sd.Faculty);
                cmd.Parameters.AddWithValue("jd", sd.Jdate);
                cmd.Parameters.AddWithValue("u", sd.Username);
                cmd.Parameters.AddWithValue("p", Encrypt(sd.Password));

                con.Open();
                cmd.CommandType = CommandType.Text;
                return(cmd.ExecuteNonQuery());
            }
            catch (Exception) { throw; }
            finally
            {
                con.Close();
            }
        }
Beispiel #3
0
        public Studentsc SearchStuForm(string Username)
        {
            cmd.CommandText = "SELECT * FROM students WHERE username=@u";
            try
            {
                cmd.Parameters.AddWithValue("u", Username);
                con.Open();

                SqlDataReader reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    Studentsc u = new Studentsc();
                    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.Byear    = reader["byear"].ToString();
                        u.Nic      = reader["nic"].ToString();
                        u.Faculty  = reader["fac"].ToString();
                        u.Jdate    = reader["jdate"].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();
            }
        }
Beispiel #4
0
        public List <Studentsc> GetBusinessStudents()
        {
            List <Studentsc> studetails = new List <Studentsc>();

            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',byear AS 'Birth Year',nic AS 'NIC',fac AS 'Faculty',jdate AS 'Joined Date',username AS 'Username',password AS 'Password' FROM students WHERE fac='Business'";
                cmd.CommandType = CommandType.Text;

                con.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Studentsc lecgv = new Studentsc()
                    {
                        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(),
                        Byear    = reader[7].ToString(),
                        Nic      = reader[8].ToString(),
                        Faculty  = reader[9].ToString(),
                        Jdate    = reader[10].ToString(),
                        Username = reader[11].ToString(),
                        Password = reader[12].ToString()
                    };
                    studetails.Add(lecgv);
                }
                return(studetails);
            }
            catch (Exception) { throw; }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Beispiel #5
0
        public Studentsc SearchStudents(Studentsc p)
        {
            Studentsc ld = new Studentsc();

            try
            {
                cmd.CommandText = "SELECT * FROM students WHERE username=@u AND fac='Business'";
                cmd.Parameters.AddWithValue("u", p.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.Byear    = reader[6].ToString();
                    ld.Nic      = reader[7].ToString();
                    ld.Faculty  = reader[9].ToString();
                    ld.Jdate    = reader[10].ToString();
                    ld.Username = reader[11].ToString();
                }
                return(ld);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
Beispiel #6
0
        public int DeleteStudents(Studentsc sdel)
        {
            try
            {
                cmd.CommandText = "DELETE students WHERE username=@u";
                cmd.Parameters.AddWithValue("u", sdel.Username);
                cmd.CommandType = CommandType.Text;
                con.Open();

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