예제 #1
0
        /// <summary>
        /// This method will add Student data into database...
        /// </summary>

        public void AddStudentData(Student stentity)
        {
            using (var context = new TestDbEntities1())
            {
                context.Students.Add(stentity);
                context.SaveChanges();
            }
        }
예제 #2
0
 /// <summary>
 /// This method will add Employee data into database...
 /// </summary>
 public void AddEmployeeData(Employee emp)
 {
     using (var context = new TestDbEntities1())
     {
         context.Employees.Add(emp);
         context.SaveChanges();
     }
 }
예제 #3
0
        /// <summary>
        /// This method will delete Student data into database...
        /// </summary>
        /// <param name="Id"></param>
        public void deleteStudent(int Id)
        {
            stentity.Studentid = Id;
            TestDbEntities1 context = new TestDbEntities1();
            var             dto     = (from d in context.Students where d.Studentid == Id select d).Single();

            context.Students.Remove(dto);
            context.SaveChanges();
        }
예제 #4
0
        /// <summary>
        /// This method will delete Employee data into database...
        /// </summary>
        /// <param name="Id"></param>
        public void deleteEmployee(int Id)
        {
            emp.Employeid = Id;
            TestDbEntities1 context = new TestDbEntities1();
            var             dto     = (from d in context.Employees where d.Employeid == Id select d).Single();

            context.Employees.Remove(dto);
            context.SaveChanges();
        }
예제 #5
0
        /// <summary>
        /// This method will update Student data into database...
        /// </summary>
        /// <param name="Id"></param>
        public void UpdateStudent(Student stentity, int Id)
        {
            stentity.Studentid = Id;
            TestDbEntities1 context = new TestDbEntities1();
            var             student = (from d in context.Students where d.Studentid == Id select d).Single();

            student.State   = stentity.State;
            student.Country = stentity.Country;
            context.SaveChanges();
        }
예제 #6
0
        /// <summary>
        /// This method will update Employee data into database...
        /// </summary>
        /// <param name="Id"></param>
        public void UpdateEmployee(Employee emp, int Id)
        {
            emp.Employeid = Id;
            TestDbEntities1 context = new TestDbEntities1();
            var             student = (from d in context.Employees where d.Employeid == emp.Employeid select d).Single();

            student.State   = emp.State;
            student.Country = emp.Country;

            context.SaveChanges();
        }
예제 #7
0
        /// <summary>
        /// This method will get Student data into datatable...
        /// </summary>
        /// <returns></returns>
        public DataTable getData()
        {
            TestDbEntities1 context = new TestDbEntities1();
            DataTable       dt      = addcolm();
            var             dto     = (from d in context.Students select d);

            // This loop will add Values into the rows of datagrid..
            foreach (var rowobject in dto)
            {
                DataRow dr = dt.NewRow();
                dr["Studentid"] = rowobject.Studentid;
                dr["Firstname"] = rowobject.First_name;
                dr["Lastname"]  = rowobject.Last_name;
                dr["Phoneno"]   = rowobject.Phone_no;
                dr["Gender"]    = rowobject.Gender;
                dr["State"]     = rowobject.State;
                dr["Country"]   = rowobject.Country;
                dt.Rows.Add(dr);
            }
            return(dt);
        }