Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            StudentService.StudentServiceClient client = new StudentService.StudentServiceClient("NetTcpBinding_IStudentService");

            try
            {
                int id = Convert.ToInt32(textBox1.Text);

                StudentService.Student std = client.GetStudent(id);

                if (std != null)
                {
                    textBox2.Text = std.Name;
                    textBox3.Text = std.DateOfBirth.ToString();
                    textBox4.Text = std.Gpa.ToString();
                    lblShow.Text  = "Get Data Student Succes.";
                }
                else
                {
                    textBox2.Text = "";
                    textBox3.Text = "";
                    textBox4.Text = "";
                    lblShow.Text  = "Data Student Not Found.";
                }
            }
            catch (Exception er)
            {
                clearText();
                lblShow.Text = "Error : " + er.ToString();
            }
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            StudentService.StudentServiceClient client = new StudentService.StudentServiceClient("NetTcpBinding_IStudentService");

            try
            {
                int id = Convert.ToInt32(textBox1.Text);
                StudentService.Student std = client.GetStudent(id);
                if (std != null)
                {
                    std.Name        = textBox2.Text;
                    std.DateOfBirth = Convert.ToDateTime(textBox3.Text);
                    std.Gpa         = Convert.ToDouble(textBox4.Text);

                    if (client.UpdateStudent(std))
                    {
                        lblShow.Text = "Update Student Success.";
                    }
                    else
                    {
                        lblShow.Text = "Update Student Fail.";
                    }
                }
                else
                {
                    lblShow.Text = "Data Student Not Found.";
                }
            }
            catch (Exception er)
            {
                clearText();
                lblShow.Text = "Error : " + er.ToString();
            }
        }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            StudentService.StudentServiceClient client = new StudentService.StudentServiceClient("NetTcpBinding_IStudentService");

            try
            {
                int id = Convert.ToInt32(textBox1.Text);
                StudentService.Student std = client.GetStudent(id);
                if (std != null)
                {
                    if (client.DeleteStudent(std))
                    {
                        clearText();
                        lblShow.Text = "Delete Student Success.";
                    }
                    else
                    {
                        lblShow.Text = "Delete Student Fail.";
                    }
                }
                else
                {
                    clearText();
                    lblShow.Text = "Data Student Not Found.";
                }
            }
            catch (Exception er)
            {
                clearText();
                lblShow.Text = "Error : " + er.ToString();
            }
        }