/// <summary> /// This function is used to update a particular entry in the database /// </summary> public void update(Student studentobj) { var context = new TestDBEntities1(); context.Entry(studentobj).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
/// <summary> /// This function is used to delete a row from the database /// </summary> /// <param name="eid"> The id of the Employee who's data we wish to delete from the database</param> public void delete(Student modelobj) { var context = new TestDBEntities1(); context.Entry(modelobj).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); }
/// <summary> /// This function is uesd to add the values from the entries to the database /// </summary> public void add(Student studentobj) { var context = new TestDBEntities1(); context.Students.Add(studentobj); context.SaveChanges(); }
/// <summary> /// This function is used to update a particular entry in the database /// </summary> public void update(Employee modelobj) { var context = new TestDBEntities1(); context.Entry(modelobj).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); }
/// <summary> /// This function is uesd to add the values from the entries to the database /// </summary> public void add(Employee dtoobj) { var v = new TestDBEntities1(); v.Employees.Add(dtoobj); v.SaveChanges(); }
/// <summary> /// update method to update the records of the student datatable /// </summary> public void UpdateStudentVal(Student emp) { using (TestDBEntities1 context = new TestDBEntities1()) { context.Entry(emp).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
/// <summary> /// method to delete data from employee table /// </summary> /// <param name="em"></param> public void DeleteEmployee(Employee em) { using (var context = new TestDBEntities1()) { var bay = (from d in context.Employees where d.empid == em.empid select d).Single(); context.Employees.Remove(bay); context.SaveChanges(); } }
/// <summary> /// delete method to delete data from the student datatable /// </summary> /// <param name="user"></param> public void DeleteStudentVal(Student user) { using (var context = new TestDBEntities1()) { var bay = (from d in context.Students where d.StudentId == user.StudentId select d).Single(); context.Students.Remove(bay); context.SaveChanges(); } }
/// <summary> /// method to add data into the database /// </summary> /// <param name="em"></param> public void AddEmployee(Employee em) { //create DBContext object using (var dbCtx = new TestDBEntities1()) { //Add Student object into Students DBset dbCtx.Employees.Add(em); // call SaveChanges method to save student into database dbCtx.SaveChanges(); } }
/// <summary> /// method to add data to student table /// </summary> /// <param name="cs"></param> public void AddStudentVal(Student cs) { using (var dbCtx = new TestDBEntities1()) { //Add Student object into Students DBset dbCtx.Students.Add(cs); //id = ob.StudentId; // call SaveChanges method to save student into database dbCtx.SaveChanges(); } }
/// <summary> /// method to update employee /// </summary> /// <param name="emp"></param> public void UpdateEmployee(Employee emp) { using (TestDBEntities1 context = new TestDBEntities1()) { var employee = (from d in context.Employees where d.empid == emp.empid select d).Single(); employee.firstname = emp.firstname; employee.lastname = emp.lastname; employee.mobileno = emp.mobileno; employee.gender = emp.gender; employee.state = emp.state; employee.city = emp.city; context.SaveChanges(); } }