protected void btnGetEmployee_Click(object sender, EventArgs e) { EmployeeService.IEmployeeService client = new EmployeeService.EmployeeServiceClient(); EmployeeService.EmployeeRequest request = new EmployeeService.EmployeeRequest("sqfqsfsqdf", Convert.ToInt32(txtID.Text)); EmployeeService.EmployeeInfo employeeInfo = client.GetEmployeeInfo(request); txtName.Text = employeeInfo.Name; txtGender.Text = employeeInfo.Gender; txtDateOfBirth.Text = employeeInfo.DOB.ToShortDateString(); if (employeeInfo.Type == EmployeeService.EmployeeType.FullTimeEmployee) { txtAnnualSalary.Text = employeeInfo.AnnualSalary.ToString(); trAnnualSalary.Visible = true; trHourlPay.Visible = false; trHoursWorked.Visible = false; } else { txtHourlyPay.Text = employeeInfo.HourlyPay.ToString(); txtHoursWorked.Text = employeeInfo.HoursWorked.ToString(); trAnnualSalary.Visible = false; trHourlPay.Visible = true; trHoursWorked.Visible = true; } ddlEmployeeType.SelectedValue = ((int)employeeInfo.Type).ToString(); lblMessage.Text = "Employee retrieved"; }
protected void btnSave_Click(object sender, EventArgs e) { EmployeeService.IEmployeeService client = new EmployeeService.EmployeeServiceClient(); EmployeeService.EmployeeInfo employee = new EmployeeService.EmployeeInfo(); if (ddlEmployeeType.SelectedValue == "-1") { lblMessage.Text = "Please select Employee Type"; } else { if (((EmployeeService.EmployeeType)Convert.ToInt32(ddlEmployeeType.SelectedValue)) == EmployeeService.EmployeeType.FullTimeEmployee) { employee.Type = EmployeeService.EmployeeType.FullTimeEmployee; employee.AnnualSalary = Convert.ToInt32(txtAnnualSalary.Text); } else { employee.Type = EmployeeService.EmployeeType.PartTimeEmployee; employee.HourlyPay = Convert.ToInt32(txtHourlyPay.Text); employee.HoursWorked = Convert.ToInt32(txtHoursWorked.Text); } employee.Id = Convert.ToInt32(txtID.Text); employee.Name = txtName.Text; employee.Gender = txtGender.Text; employee.DOB = Convert.ToDateTime(txtDateOfBirth.Text); client.SaveEmployee(employee); lblMessage.Text = "Employee saved"; } }