Ejemplo n.º 1
0
        protected void btnSaveEmployee_Click(object sender, EventArgs e)
        {
            try
            {
                IBiduleService client = new BiduleServiceClient();
                //IEmployeeService client = new EmployeeServiceClient();
                Employee employee = new Employee();

                if ((EmployeeType)Convert.ToInt32(ddlEmployeeType.SelectedValue) == EmployeeType.FullTimeEmployee)
                {
                    employee = new FullTimeEmployee
                    {
                        Id = Convert.ToInt32(txtID.Text),
                        Name = txtName.Text,
                        Gender = txtGender.Text,
                        Dateofb = Convert.ToDateTime(txtDateofb.Text),
                        Type = EmployeeType.FullTimeEmployee,
                        AnnualSalary = Convert.ToInt32(txtAnnualSalary.Text)
                    };

                    client.SaveEmployee(employee);
                    LblMessage.Text = "Full time employee saved";
                }
                else if ((EmployeeType)Convert.ToInt32(ddlEmployeeType.SelectedValue) == EmployeeType.PartTimeEmployee)
                {
                    employee = new PartTimeEmployee
                    {
                        Id = Convert.ToInt32(txtID.Text),
                        Name = txtName.Text,
                        Gender = txtGender.Text,
                        Dateofb = Convert.ToDateTime(txtDateofb.Text),
                        Type = EmployeeType.PartTimeEmployee,
                        HourlyPay = Convert.ToInt32(txtHourlyPay.Text),
                        HoursWorked = Convert.ToInt32(txtHoursworked.Text)
                    };

                    client.SaveEmployee(employee);
                    LblMessage.Text = "Part time employee saved";
                }
                else
                {
                    LblMessage.Text = "Please select Employee type";
                }


            }
            catch (FaultException faultException)
            {
                LblMessage.Text = faultException.Message;
            }
        }