예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            PermanentEmployee permanantEmployee = new PermanentEmployee
            {
                FirstName    = "Sunny",
                LastName     = "Patel",
                Gender       = "Male",
                AnnualSalary = 70000
            };

            EmployeeDBContext employeeDBContext = new EmployeeDBContext();

            employeeDBContext.Employees.Add(permanantEmployee);
            employeeDBContext.SaveChanges();
        }
예제 #2
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            ContractEmployee contractEmployee = new ContractEmployee
            {
                FirstName   = "Chaya",
                LastName    = "Patel",
                Gender      = "Female",
                HourlyPay   = 50,
                HoursWorked = 120
            };

            EmployeeDBContext employeeDBContext = new EmployeeDBContext();

            employeeDBContext.Employees.Add(contractEmployee);
            employeeDBContext.SaveChanges();
        }
        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            EmployeeDBContext employeeDBContext = new EmployeeDBContext();
            switch (RadioButtonList1.SelectedValue)
            {
                case "Permanent":
                    GridView1.DataSource = employeeDBContext.Employees.OfType<PermanentEmployee>().ToList();
                    GridView1.DataBind();
                    break;

                case "Contract":
                    GridView1.DataSource = employeeDBContext.Employees.OfType<ContractEmployee>().ToList();
                    GridView1.DataBind();
                    break;

                default:
                    //Using ConvertEmployeesForDisplay method to diplay all employee details
                    GridView1.DataSource = ConvertEmployeesForDisplay(employeeDBContext.Employees.ToList());
                    GridView1.DataBind();
                    break;
            }
        }
예제 #4
0
        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            EmployeeDBContext employeeDBContext = new EmployeeDBContext();

            switch (RadioButtonList1.SelectedValue)
            {
            case "Permanent":
                GridView1.DataSource = employeeDBContext.Employees.OfType <PermanentEmployee>().ToList();
                GridView1.DataBind();
                break;

            case "Contract":
                GridView1.DataSource = employeeDBContext.Employees.OfType <ContractEmployee>().ToList();
                GridView1.DataBind();
                break;

            default:
                //Using ConvertEmployeesForDisplay method to diplay all employee details
                GridView1.DataSource = ConvertEmployeesForDisplay(employeeDBContext.Employees.ToList());
                GridView1.DataBind();
                break;
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            ContractEmployee contractEmployee = new ContractEmployee
            {
                FirstName = "Chaya",
                LastName = "Patel",
                Gender = "Female",
                HourlyPay = 50,
                HoursWorked = 120
            };

            EmployeeDBContext employeeDBContext = new EmployeeDBContext();
            employeeDBContext.Employees.Add(contractEmployee);
            employeeDBContext.SaveChanges();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            PermanentEmployee permanantEmployee = new PermanentEmployee
            {
                FirstName = "Sunny",
                LastName = "Patel",
                Gender = "Male",
                AnnualSalary = 70000
            };

            EmployeeDBContext employeeDBContext = new EmployeeDBContext();
            employeeDBContext.Employees.Add(permanantEmployee);
            employeeDBContext.SaveChanges();
        }