コード例 #1
0
        public static void update()
        {
            EmployeeContent con = new EmployeeContent();

            Console.WriteLine("enter a emolyoee to update");
            int id = int.Parse(Console.ReadLine());

            Console.WriteLine("enter a emolyoee salaree");

            double sal  = double.Parse(Console.ReadLine());
            var    emp  = con.Employees;
            var    emp1 = from e in emp
                          where e.eid == id
                          select e;

            foreach (var e in emp1)
            {
                e.salary = sal;
            }

            foreach (var res in emp1)
            {
                Console.WriteLine(" updated data is/n {0} {1} {2} {3}", res.eid, res.ename, res.designation, res.salary);
            }
            con.SaveChanges();
        }
コード例 #2
0
        public static void  show()
        {
            EmployeeContent ee        = new EmployeeContent();
            var             employees = ee.Employees;

            foreach (var emp in employees)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}", emp.eid, emp.ename, emp.designation, emp.salary);
            }
        }
コード例 #3
0
        public static void  GetEmployee()
        {
            EmployeeContent e = new EmployeeContent();

            Console.WriteLine("enter the employee name:");
            string name = Console.ReadLine();

            Console.WriteLine("enter the employee designation:");
            string desg = Console.ReadLine();

            Console.WriteLine("enter the salary");
            double sal = double.Parse(Console.ReadLine());

            e.Employees.Add(new Employee {
                ename = name, designation = desg, salary = sal
            });

            e.SaveChanges();
        }
コード例 #4
0
        public static void delete()
        {
            EmployeeContent con = new EmployeeContent();

            Console.WriteLine("enter a emolyoee to delete");
            int id = int.Parse(Console.ReadLine());


            var emp1 = from e in con.Employees
                       where e.eid == id
                       select e;

            con.Employees.RemoveRange(emp1);

            foreach (var res in emp1)
            {
                Console.WriteLine(" deleted data is/n {0} {1} {2} {3}", res.eid, res.ename, res.designation, res.salary);
            }
            con.SaveChanges();
        }
コード例 #5
0
        public static void search()
        {
            EmployeeContent con   = new EmployeeContent();
            var             name1 = Console.ReadLine();

            var details = con.Employees.Where(s => s.ename == name1);

            foreach (var d in details)
            {
                Console.WriteLine("{0}\t{1}\t{2}\t{3}", d.eid, d.ename, d.designation, d.salary);
            }

            /* Console.WriteLine("enter a emolpoee to search");
             * int id = int.Parse(Console.ReadLine());
             *
             * var emp1 = from e in con.Employees
             *         where e.eid == id
             *         select e;
             * foreach(var res in emp1)
             * {
             *   Console.WriteLine("{0} {1} {2} {3}",res.eid,res.ename,res.designation,res.salary);
             * }*/
            con.SaveChanges();
        }