Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
        /// <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();
        }
Esempio n. 3
0
        /// <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();
        }
Esempio n. 4
0
        /// <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();
        }
Esempio n. 5
0
        /// <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();
        }
Esempio n. 6
0
        /// <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();
            }
        }
Esempio n. 7
0
        /// <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();
            }
        }
Esempio n. 8
0
        /// <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();
            }
        }
Esempio n. 9
0
        /// <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();
            }
        }
Esempio n. 10
0
        /// <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();
            }
        }
Esempio n. 11
0
        /// <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();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// // method to display data into the datagrid
        /// </summary>
        /// <returns></returns>

        public DataTable GetDataVal()
        {
            var       entities = new TestDBEntities1();
            DataTable table    = AddCol();
            var       dt       = (from d in entities.Employees select d);

            foreach (var obj in dt)
            {
                DataRow dr = table.NewRow();
                dr["EmpId"]     = obj.empid;
                dr["FirstName"] = obj.firstname;
                dr["LastName"]  = obj.lastname;
                dr["MobileNo"]  = obj.mobileno;
                dr["Gender"]    = obj.gender;
                dr["State"]     = obj.state;
                dr["City"]      = obj.city;
                table.Rows.Add(dr);
            }
            return(table);
        }
Esempio n. 13
0
        /// <summary>
        /// getdata method for displaying the data from database
        /// </summary>
        /// <returns></returns>

        public DataTable GetDataVal()
        {
            var       entities = new TestDBEntities1();
            DataTable table    = AddCol();
            var       dt       = (from d in entities.Students select d);

            foreach (var obj in dt)
            {
                DataRow dr = table.NewRow();
                dr["StudentId"] = obj.StudentId;
                dr["FirstName"] = obj.FirstName;
                dr["LastName"]  = obj.LastName;
                dr["MobileNo"]  = obj.MobileNo;
                dr["Gender"]    = obj.Gender;
                dr["State"]     = obj.State;
                dr["City"]      = obj.City;
                table.Rows.Add(dr);
            }
            return(table);
        }
Esempio n. 14
0
        /// <summary>
        ///  This function returns a datatable that contains the databse
        /// </summary>
        public DataTable get()
        {
            var       entityobj = new TestDBEntities1();
            DataTable t         = new DataTable();

            t = addcolm();
            var row = (from d in entityobj.Employees select d);

            foreach (var rowobj in row)
            {
                DataRow datarow = t.NewRow();
                datarow["Employeeid"]  = rowobj.Employeeid;
                datarow["Firstname"]   = rowobj.Firstname;
                datarow["Lastname"]    = rowobj.Lastname;
                datarow["Phonenumber"] = rowobj.Phonenumber;
                datarow["Gender"]      = rowobj.Gender;
                datarow["City"]        = rowobj.City;
                datarow["State"]       = rowobj.State;
                t.Rows.Add(datarow);
            }
            return(t);
        }