예제 #1
0
        protected void btnGetEmployee_Click(object sender, EventArgs e)
        {
            var empRequest = new EmployeeServiceReference.EmployeeRequest("AXG120ABC", Convert.ToInt32(txtId.Text));

            EmployeeServiceReference.EmployeeInfo empinfo = null;

            var client = new EmployeeServiceReference.EmployeeServiceClient();

            try
            {
                empinfo = client.GetEmployee(empRequest);
            }
            catch (FaultException fultException)
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = fultException.Message;
                return;
            }



            if (empinfo != null)
            {
                txtName.Text   = empinfo.Name;
                txtGender.Text = empinfo.Gender;
                txtDoB.Text    = empinfo.DOB.ToShortDateString();


                ddlEmpType.SelectedValue = ((int)empinfo.Type).ToString();

                SetFieldsVisible(empinfo.Type);

                txtAnualSal.Text    = string.Empty;
                txtHourlyPay.Text   = string.Empty;
                txtHoursWorked.Text = string.Empty;

                if (empinfo.Type == EmployeeServiceReference.EmployeeType.EmployeeFullTime)
                {
                    txtAnualSal.Text = empinfo.AnnualSalary.ToString();
                }
                else
                {
                    txtHourlyPay.Text   = empinfo.HourlyPay.ToString();
                    txtHoursWorked.Text = empinfo.HoursWorked.ToString();
                }

                lblmsg.ForeColor = Color.Green;
                lblmsg.Text      = "Employee retrieved";
            }
            else
            {
                lblmsg.ForeColor = Color.Red;
                lblmsg.Text      = "Employee Not Found";
            }
        }