コード例 #1
0
 protected void btnGetEmployee_Click(object sender, EventArgs e)
 {
     EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient("BasicHttpBinding_IEmployeeService");
     EmployeeService.Employee employee = client.GetEmployee(Convert.ToInt32(txtID.Text));
     if(employee.Type==EmployeeService.EmployeeType.FullTimeEmployee)
     {
         txtAnnualSalary.Text = ((EmployeeService.FullTimeEmployee)employee).AnnualSalary.ToString();
         trAnnualSalary.Visible = true;
         trHourlyPay.Visible = false;
         trHoursWorked.Visible = false;
     }
     else
     {
         txtHourlyPay.Text = ((EmployeeService.PartTimeEmployee)employee).Hourlypay.ToString();
         txtHoursWorked.Text = ((EmployeeService.PartTimeEmployee)employee).HoursWorked.ToString();
         trAnnualSalary.Visible = false;
         trHourlyPay.Visible = true;
         trHoursWorked.Visible = true;
     }
     ddlEmployeeType.SelectedValue = ((int)employee.Type).ToString();
     txtName.Text = employee.Name;
     txtGender.Text = employee.Gender;
     txtDateOfBirth.Text = employee.DateOfBirth.ToShortDateString();
     lblMessage.Text = "Employee retrieved";
 }
コード例 #2
0
    protected void btnGetEmployee_Click(object sender, EventArgs e)
    {
        EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();
        EmployeeService.Employee employee            = client.GetEmployee(Convert.ToInt32(txtID.Text));

        if (employee.Type == EmployeeService.EmployeeType.FullTimeEmployee)
        {
            txtAnnualSalary.Text   = ((EmployeeService.FullTimeEmployee)employee).AnnualSalary.ToString();
            trAnnualSalary.Visible = true;
            trHourlyPay.Visible    = false;
            trHoursWorked.Visible  = false;
        }
        else
        {
            txtHourlyPay.Text      = ((EmployeeService.PartTimeEmployee)employee).HourlyPay.ToString();
            txtHoursWorked.Text    = ((EmployeeService.PartTimeEmployee)employee).HoursWorked.ToString();
            trAnnualSalary.Visible = false;
            trHourlyPay.Visible    = true;
            trHoursWorked.Visible  = true;
        }

        txtName.Text                  = employee.Name;
        txtGender.Text                = employee.Gender;
        txtDateOfBirth.Text           = employee.DateOfBirth.ToShortDateString();
        ddlEmployeeType.SelectedValue = ((int)employee.Type).ToString();
        lblMessage.Text               = "Employee retrieved";
    }
コード例 #3
0
        protected void BtnGet_Click(object sender, EventArgs e)
        {
            int employeeId = Convert.ToInt32(TxtEmployeeID.Text);

            //EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();
            //EmployeeService.Employee employee = client.GetEmployee(employeeId);
            EmployeeService.IEmployeeService client = new EmployeeService.EmployeeServiceClient();
            EmployeeService.EmployeeRequest request = new EmployeeService.EmployeeRequest("QWERTY", Convert.ToInt32(TxtEmployeeID.Text));
            EmployeeService.EmployeeInfo employee = client.GetEmployee(request);

            TxtEmployeeName.Text = employee.Name;
            //TxtEmployeeDateOfBirth.Text = employee.DateOfBirth.ToShortDateString();
            TxtEmployeeDateOfBirth.Text = employee.DOB.ToShortDateString();

            // Show the employee type data
            hideWhenEmployeeType();
            if (employee.Type == EmployeeService.EmployeeType.FullTimeEmployee)
            {
                trAnnualSalary.Visible = true;
                TxtAnnualSalary.Text = employee.AnnualSalary.ToString(); //((EmployeeService.FullTimeEmployee)employee).AnnualSalary.ToString();
            }
            else
            {
                trHourlyPay.Visible = true;
                trHoursWorked.Visible = true;
                TxtHourlyPay.Text = employee.HourlyPay.ToString(); //((EmployeeService.PartTimeEmployee)employee).HourlyPay.ToString();
                TxtHoursWorked.Text = employee.HoursWorked.ToString(); //((EmployeeService.PartTimeEmployee)employee).HoursWorked.ToString();
            }

            CbxEmployeeType.SelectedValue = ((int)employee.Type).ToString();
        }
コード例 #4
0
        public ActionResult Index(IList <EmployeeService.Employee> employees)
        {
            ViewBag.Connection = GetServerName();
            if (employees == null)
            {
                return(RedirectToAction("Index"));
            }
            EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();

            if (ModelState.IsValid)
            {
                client.DeleteEmployee(0);
                foreach (var employee in employees)
                {
                    if (employee.Id == 0)
                    {
                        continue;  //If employee with Id=0 has been entered in the view, ignore he/she, will not be stored in db and will disapear in next page load
                    }
                    if (client.GetEmployee(employee.Id) == null)
                    {
                        client.SaveEmployee(employee);   //employee doesn't exist in Db, Create new
                    }
                    else
                    {
                        client.UpdateEmployee(employee);   //employee do exist in Db, Update
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #5
0
        protected void BtnGet_Click(object sender, EventArgs e)
        {
            int employeeId = Convert.ToInt32(TxtEmployeeID.Text);

            EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();
            EmployeeService.Employee employee = client.GetEmployee(employeeId);

            TxtEmployeeName.Text = employee.Name;
            TxtEmployeeDateOfBirth.Text = employee.DateOfBirth.ToShortDateString();
        }
コード例 #6
0
        private static void testGRPC()
        {
            Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
            var     client  = new EmployeeService.EmployeeServiceClient(channel);
            var     reply   = client.GetEmployee(new EmployeeRequest {
                Id = 1
            });

            Console.WriteLine("Greeting: " + reply.Name);
            ListFeatures().Wait();
        }
コード例 #7
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();
            EmployeeService.Employee employee = client.GetEmployee(Convert.ToInt32(TextBox1.Text));

            TextBox1.Text = employee.Id.ToString();
            TextBox5.Text = employee.Name.ToString();
            TextBox3.Text = employee.Gender.ToString();
            TextBox4.Text = employee.DateOfBirth.ToString("dd-MM-yyyy");

            Label1.Text = "Employee with ID = " + employee.Id.ToString() + " retrived";
        }