コード例 #1
0
ファイル: Form1.cs プロジェクト: justahf/WCF-test-application
        private void button6_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            Form2 form2 = new Form2(2);
            form2.ShowDialog();
            ContactData data = form2.ReturnData();
            TestServiceClient client = new TestServiceClient();
            try
            {
                client.Open();
                int[] phones = client.SearchPhone(data.name);
                client.Close();

                int count = phones.Count();
                if (count != 0)
                    for (int i = 0; i < count; i++)
                        dataGridView1.Rows.Add(data.name, phones[i].ToString());
                else
                {
                    foreach (Control c in Controls)
                        c.Enabled = false;
                    button1.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }