Beispiel #1
0
 private void editContact_Click(object sender, EventArgs e)
 {
     if (listView2.SelectedItems.Count == 1)
     {
         ContactItem contact = listView2.SelectedItems[0].Tag as ContactItem;
         Form3 thirdForm = new Form3(contact);
         if (thirdForm.ShowDialog(this) == DialogResult.OK)
         {
             int id = contact.id;
             string name = contact.name;
             string surname = contact.surname;
             string phone = contact.phoneNumber;
             string address = contact.address;
             refreshContact();
             using (SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Roba\Documents\Visual Studio 2013\Projects\Todo+duomb\WindowsFormsApplication6\Database.mdf;Integrated Security=True"))
             {
                 conn.Open();
                 using (var command = new SqlCommand("UPDATE [contact] SET [Name]=@name, [Surname]=@surname, [PhoneNumber]=@phone, [Address]=@address WHERE Id =" + id, conn))
                 {
                     command.Parameters.AddWithValue("@name", name);
                     command.Parameters.AddWithValue("@surname", surname);
                     command.Parameters.AddWithValue("@phone", phone);
                     command.Parameters.AddWithValue("@address", address);
                     command.ExecuteNonQuery();
                     conn.Close();
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("Select only one");
     }
 }
Beispiel #2
0
 private void addContact_Click(object sender, EventArgs e)
 {
     ContactItem contact = new ContactItem(0,"","","","");
         Form3 thirdForm = new Form3(contact);
         if (thirdForm.ShowDialog(this) == DialogResult.OK)
         {
             var item = new ListViewItem();
             item.Tag = contact;
             item.SubItems.Add(contact.name);
             item.SubItems.Add(contact.surname);
             item.SubItems.Add(contact.phoneNumber);
             item.SubItems.Add(contact.address);
             listView2.Items.Add(item);
             list2.AddLast(contact);
         }
         writeContactsToDatabase();
 }
Beispiel #3
0
 private void editContact_Click(object sender, EventArgs e)
 {
     if (listView2.SelectedItems.Count == 1)
     {
         ContactItem contact = listView2.SelectedItems[0].Tag as ContactItem;
         Form3 thirdForm = new Form3(contact);
         if (thirdForm.ShowDialog(this) == DialogResult.OK)
         {
             refreshContactsView();
             writeToFileContacts();
         }
     }
     else
     {
         MessageBox.Show("Select one contact");
     }
 }
Beispiel #4
0
 private void 统计信息ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Form3 form = new Form3();
     form.ShowDialog();
 }
Beispiel #5
0
        private void 统计信息ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 form = new Form3();

            form.ShowDialog();
        }