Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Check student is new Student or update Student
                bool isNewStudent = true;
                foreach (DataGridViewRow item in grdStudent.Rows)
                {
                    if (item.Cells["StudentID"].Value.ToString() == txtStudentID.Text)
                    {
                        isNewStudent = false;
                        break;
                    }
                }

                WCFDemo.WCFServiceDemoClient client = new WCFDemo.WCFServiceDemoClient();
                Student oStudent = new Student()
                {
                    StudentID = int.Parse(txtStudentID.Text), StudentName = txtStudentName.Text, Class = txtClass.Text, Professional = txtProfessional.Text
                };
                if (isNewStudent ? client.AddStudent(oStudent) : client.UpdateStudent(oStudent))
                {
                    grdStudent.DataSource = client.GetStudents();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 private void toolRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         WCFDemo.WCFServiceDemoClient client = new WCFDemo.WCFServiceDemoClient();
         grdStudent.DataSource = client.GetStudents();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 3
0
 public StudentManagerForm()
 {
     InitializeComponent();
     try
     {
         WCFDemo.WCFServiceDemoClient client = new WCFDemo.WCFServiceDemoClient();
         grdStudent.DataSource = client.GetStudents();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 4
0
 private void toolDelete_Click(object sender, EventArgs e)
 {
     try
     {
         WCFDemo.WCFServiceDemoClient client = new WCFDemo.WCFServiceDemoClient();
         if (MessageBox.Show("Are you sure you want to delete this student?", "Student Manager", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             int deleteStudentID = int.Parse(grdStudent.SelectedRows[0].Cells["StudentID"].Value.ToString());
             if (client.DeleteStudent(deleteStudentID))
             {
                 grdStudent.DataSource = client.GetStudents();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }