Exemplo n.º 1
0
 public void updateEmployeeInfo()
 {
     using (var db = new ConnectContext()) {
         var employee = (from d in db.Employees Where d.FirstMidName == "Ali" select d).Single();
         employee.LastName = "Aslam";
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
        public void storeEmployeeInfo()
        {
            Console.Write("Input the employee's first Name: ");
            FirstName = Console.ReadLine();
            Console.WriteLine();

            Console.Write("Input the employee's Last Name: ");
            LastName = Console.ReadLine();
            Console.WriteLine();

            Console.Write("Input the employee's Gender: ");
            Gender = Console.ReadLine();
            Console.WriteLine();

            Console.Write("Input the employee's Email Address: ");
            EmailAddress = Console.ReadLine();
            Console.WriteLine();

            Console.Write("Input the employee's Department: ");
            Department = Console.ReadLine();
            Console.WriteLine();

            Console.Write("Input the employee's gross salary: ");
            GrossSalary = double.Parse(Console.ReadLine());
            Console.WriteLine();

            Console.Write("Input the employee's total working hours: ");
            TotalWorkingHours = int.Parse(Console.ReadLine());
            Console.WriteLine();


            calculateBonuses();
            calculateNetSalary();

            using (var db = new ConnectContext())
            {
                var employee = new Employee {
                    FirstName         = FirstName,
                    LastName          = LastName,
                    Gender            = Gender,
                    Department        = Department,
                    EmailAddress      = EmailAddress,
                    GrossSalary       = GrossSalary,
                    NetSalary         = NetSalary,
                    Tax               = Tax,
                    Bonuses           = Bonuses,
                    Pension           = Pension,
                    TotalWorkingHours = TotalWorkingHours
                };
                db.Employees.Add(employee);
                db.SaveChanges();
            }
            Console.Write("Data Recorded Successfully \n");
        }