You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
using AppointmentsLib.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace AppointmentsUi.Views
|
|
{
|
|
public partial class ContactsList : Form
|
|
{
|
|
public ContactsList()
|
|
{
|
|
InitializeComponent();
|
|
|
|
var contacts = Contact.GetContacts();
|
|
|
|
for (int i = 0; i < contacts.Count(); i++)
|
|
{
|
|
var contact = contacts.ElementAt(i);
|
|
|
|
var labelId = new Label() { Text = contact.ContactId.ToString(), AutoSize = true, TextAlign = ContentAlignment.MiddleCenter };
|
|
var labelBriefOverview = new Label() { Text = $"{contact.LastName}, {contact.FirstName}", AutoSize = true };
|
|
var buttonEdit = new Button() { Text = "View" };
|
|
|
|
buttonEdit.Click += new EventHandler(delegate (object sender, EventArgs e) {
|
|
openAddContactForm(contact);
|
|
});
|
|
|
|
tableLayoutPanelContacts.Controls.Add(labelId, 0, 1 + i);
|
|
tableLayoutPanelContacts.Controls.Add(labelBriefOverview, 1, 1 + i);
|
|
tableLayoutPanelContacts.Controls.Add(buttonEdit, 2, 1 + i);
|
|
}
|
|
}
|
|
|
|
private void openAddContactForm(Contact? contact)
|
|
{
|
|
new ContactView(contact).ShowDialog();
|
|
}
|
|
|
|
internal void addContact()
|
|
{
|
|
Program.mainForm.EmbedForm<ContactsList>();
|
|
openAddContactForm(null);
|
|
}
|
|
|
|
private void buttonAddNewContact_Click(object sender, EventArgs e)
|
|
{
|
|
openAddContactForm(null);
|
|
}
|
|
}
|
|
}
|