private void Form2_Load(object sender, EventArgs e)
 {
     foreach (var contact in PhoneBook.GetContact())
     {
         comboBox1.Items.Add(contact.Key);
     }
 }
예제 #2
0
 private void FindNumbersToolStripMenuItem_Click_1(object sender, EventArgs e)
 {
     foreach (KeyValuePair <string, string> contact in PhoneBook.GetContact())
     {
         if (contact.Key != null && contact.Value != null)
         {
             Form2 form2 = new Form2();
             form2.ShowDialog();
         }
     }
 }
        private void Button1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Silməyə əminsinizmi ?", "Təsdiq", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                PhoneBook.RemoveContact(comboBox1.SelectedItem.ToString());
                comboBox1.Items.Clear();
                foreach (var contact in PhoneBook.GetContact())
                {
                    comboBox1.Items.Add(contact.Key);
                }
                MessageBox.Show("Silindi");
            }
        }
예제 #4
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            //---Class way---

            if (txtName.Text.Trim() != "" && txtNumber.Text.Replace(" ", "") != "")
            {
                if (CheckContactName(txtName.Text.Trim()) && CheckContactNumber(txtNumber.Text.Trim()))
                {
                    PhoneBook.AddContact(txtName.Text, txtNumber.Text);
                }
                else
                {
                    MessageBox.Show("Zəhmət olmasa, düzgün ad və nömrə daxil edin.", "Səhv", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Zəhmət olmasa, boşluqları doldurun.", "Xəbərdarlıq", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }


            foreach (KeyValuePair <string, string> contact in PhoneBook.GetContact())
            {
                if (contact.Key == txtName.Text && contact.Value == txtNumber.Text)
                {
                    lstContacts.Items.Add(contact.Key + " :     " + cmbBox1.SelectedItem.ToString() + " " + cmbBox2.SelectedItem.ToString() + " " + contact.Value);
                    txtName.Text = txtNumber.Text = "";

                    //    //---DataSource(ERROR)---
                    //    //lstContacts.DataSource = null;
                    //    //lstContacts.DataSource = PhoneBook.GetContact();
                    //    //lstContacts.DisplayMember = "key";
                    //    //}
                    //    //}
                    //}
                }
            }
        }