예제 #1
0
 /// <summary>
 /// This function will update the entries in the SQL table to the inserted vales
 /// </summary>
 /// <param name="std">Student object with updated values</param>
 public void UpdateDL(Student std)
 {
     using (TestDBEntities context = new TestDBEntities())
     {
         context.Entry(std).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #2
0
 /// <summary>
 /// This function will update the entries in the SQL table to the inserted values
 /// </summary>
 /// <param name="emp">Object with updated values of the column in Employee object</param>
 public void UpdateDL(Employee emp)
 {
     using (TestDBEntities context = new TestDBEntities())
     {
         context.Entry(emp).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
예제 #3
0
        /// <summary>
        /// This function will retrieve a list of the student objects in the SQL table
        /// </summary>
        /// <returns>List of student objects</returns>
        public List <Student> GetDL()
        {
            List <Student> list;

            using (TestDBEntities context = new TestDBEntities())
            {
                list = context.Students.ToList();
            }
            return(list);
        }
예제 #4
0
        /// <summary>
        /// This function will get the list of employees from the SQL table
        /// </summary>
        /// <returns>List of student objects</returns>
        public List <Employee> GetDL()
        {
            List <Employee> list;

            using (TestDBEntities context = new TestDBEntities())
            {
                list = context.Employees.ToList();
            }
            return(list);
        }
예제 #5
0
        /// <summary>
        /// This function will add rows in the SQL table
        /// </summary>
        /// <param name="std">Student object which contains data to be added</param>
        /// <returns>primary key of the inserted row</returns>
        public int AddDL(Student std)
        {
            int id;

            using (TestDBEntities context = new TestDBEntities())
            {
                var dto = context.Students.Add(std);
                context.SaveChanges();
                id = dto.StudentID;
            }
            return(id);
        }
예제 #6
0
        /// <summary>
        /// This function will add rows in the SQL table
        /// </summary>
        /// <param name="emp">Object with values of the row to be added</param>
        /// <returns>Primary key of the inserted row</returns>
        public int AddDL(Employee emp)
        {
            int id;

            using (TestDBEntities context = new TestDBEntities())
            {
                var dto = context.Employees.Add(emp);
                context.SaveChanges();
                id = dto.EmployeeID;
            }
            return(id);
        }