wip
This commit is contained in:
@@ -25,14 +25,27 @@ namespace AppointmentsLib.Models
|
||||
{
|
||||
var reader = Database.Execute("SELECT appointmentId, contactId, time, description FROM Appointment;").ExecuteReader();
|
||||
|
||||
List<AppointmentData> data = new();
|
||||
List<Appointment> appointments = new();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
appointments.Add(new Appointment(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3)));
|
||||
data.Add(new AppointmentData()
|
||||
{
|
||||
AppointmentId = reader.GetInt32(0),
|
||||
ContactId = reader.GetInt32(1),
|
||||
Time = reader.GetString(2),
|
||||
Description = reader.GetString(3)
|
||||
});
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
|
||||
foreach (AppointmentData ad in data)
|
||||
{
|
||||
appointments.Add(ad.Finalize());
|
||||
}
|
||||
|
||||
return appointments;
|
||||
}
|
||||
|
||||
@@ -91,4 +104,17 @@ namespace AppointmentsLib.Models
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
internal class AppointmentData
|
||||
{
|
||||
public int AppointmentId;
|
||||
public int ContactId;
|
||||
public string Time;
|
||||
public string Description;
|
||||
|
||||
public Appointment Finalize()
|
||||
{
|
||||
return new Appointment(AppointmentId, ContactId, Time.ToString(), Description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,34 @@ namespace AppointmentsLib.Models
|
||||
{
|
||||
var reader = Database.Execute($"SELECT {primaryKey}, {string.Join(", ", fields.ToArray())} FROM Contact;").ExecuteReader();
|
||||
|
||||
List<ContactData> data = new();
|
||||
List<Contact> contacts = new();
|
||||
|
||||
while(reader.Read())
|
||||
{
|
||||
contacts.Add(new Contact(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(4), reader.GetString(5), reader.GetInt32(6), reader.GetString(7), reader.GetInt32(8), reader.GetString(9)));
|
||||
data.Add(new ContactData()
|
||||
{
|
||||
ContactId = reader.GetInt32(0),
|
||||
SalutationId = reader.GetInt32(1),
|
||||
FirstName = reader.GetString(2),
|
||||
LastName = reader.GetString(3),
|
||||
Street = reader.GetString(4),
|
||||
PostalId = reader.GetInt32(5),
|
||||
Phone = reader.GetString(6),
|
||||
PhoneTypeId = reader.GetInt32(7),
|
||||
Mobil = reader.GetString(8),
|
||||
CompanyId = reader.GetInt32(9),
|
||||
Department = reader.GetString(10)
|
||||
});
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
|
||||
foreach (ContactData cd in data)
|
||||
{
|
||||
contacts.Add(cd.Finalize());
|
||||
}
|
||||
|
||||
return contacts;
|
||||
}
|
||||
|
||||
@@ -73,9 +93,24 @@ namespace AppointmentsLib.Models
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
var contact = new Contact(reader.GetInt32(0), reader.GetInt32(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetInt32(4), reader.GetString(5), reader.GetInt32(6), reader.GetString(7), reader.GetInt32(8), reader.GetString(9));
|
||||
var data = new ContactData()
|
||||
{
|
||||
ContactId = reader.GetInt32(0),
|
||||
SalutationId = reader.GetInt32(1),
|
||||
FirstName = reader.GetString(2),
|
||||
LastName = reader.GetString(3),
|
||||
Street = reader.GetString(4),
|
||||
PostalId = reader.GetInt32(5),
|
||||
Phone = reader.GetString(6),
|
||||
PhoneTypeId = reader.GetInt32(7),
|
||||
Mobil = reader.GetString(8),
|
||||
CompanyId = reader.GetInt32(9),
|
||||
Department = reader.GetString(10)
|
||||
};
|
||||
|
||||
reader.Close();
|
||||
return contact;
|
||||
|
||||
return data.Finalize();
|
||||
}
|
||||
|
||||
throw new Exception("contact does not exist");
|
||||
@@ -131,4 +166,24 @@ namespace AppointmentsLib.Models
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
internal class ContactData
|
||||
{
|
||||
public int ContactId;
|
||||
public int SalutationId;
|
||||
public string FirstName;
|
||||
public string LastName;
|
||||
public string Street;
|
||||
public int PostalId;
|
||||
public string Phone;
|
||||
public int PhoneTypeId;
|
||||
public string Mobil;
|
||||
public int CompanyId;
|
||||
public string Department;
|
||||
|
||||
public Contact Finalize()
|
||||
{
|
||||
return new Contact(ContactId, SalutationId, FirstName, LastName, Street, PostalId, Phone, PhoneTypeId, Mobil, CompanyId, Department);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace AppointmentsUi
|
||||
|
||||
private void toolstripContactsButton_ButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("contacts button click");
|
||||
EmbedForm<Views.ContactsList>();
|
||||
}
|
||||
|
||||
private void toolstripContactsAddNewButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("contacts add button click");
|
||||
EmbedForm<Views.ContactsList>().addContact();
|
||||
}
|
||||
|
||||
private void toolstripCompaniesButton_ButtonClick(object sender, EventArgs e)
|
||||
|
||||
299
AppointmentsManager/AppointmentsUi/Views/ContactView.Designer.cs
generated
Normal file
299
AppointmentsManager/AppointmentsUi/Views/ContactView.Designer.cs
generated
Normal file
@@ -0,0 +1,299 @@
|
||||
namespace AppointmentsUi.Views
|
||||
{
|
||||
partial class ContactView
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonApplyCreate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.labelFirstName = new System.Windows.Forms.Label();
|
||||
this.textBoxFirstName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxLastName = new System.Windows.Forms.TextBox();
|
||||
this.labelLastName = new System.Windows.Forms.Label();
|
||||
this.textBoxStreet = new System.Windows.Forms.TextBox();
|
||||
this.labelStreet = new System.Windows.Forms.Label();
|
||||
this.textBoxDepartment = new System.Windows.Forms.TextBox();
|
||||
this.labelDepartment = new System.Windows.Forms.Label();
|
||||
this.textBoxMobil = new System.Windows.Forms.TextBox();
|
||||
this.labelMobil = new System.Windows.Forms.Label();
|
||||
this.textBoxPhone = new System.Windows.Forms.TextBox();
|
||||
this.labelPhone = new System.Windows.Forms.Label();
|
||||
this.labelSalutation = new System.Windows.Forms.Label();
|
||||
this.comboBoxSalutation = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxPostal = new System.Windows.Forms.ComboBox();
|
||||
this.labelPostal = new System.Windows.Forms.Label();
|
||||
this.comboBoxPhoneType = new System.Windows.Forms.ComboBox();
|
||||
this.labelPhoneType = new System.Windows.Forms.Label();
|
||||
this.comboBoxCompany = new System.Windows.Forms.ComboBox();
|
||||
this.labelCompany = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonApplyCreate
|
||||
//
|
||||
this.buttonApplyCreate.Location = new System.Drawing.Point(12, 314);
|
||||
this.buttonApplyCreate.Name = "buttonApplyCreate";
|
||||
this.buttonApplyCreate.Size = new System.Drawing.Size(164, 23);
|
||||
this.buttonApplyCreate.TabIndex = 0;
|
||||
this.buttonApplyCreate.Text = "Apply";
|
||||
this.buttonApplyCreate.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(190, 314);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(164, 23);
|
||||
this.buttonDelete.TabIndex = 1;
|
||||
this.buttonDelete.Text = "Delete";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelFirstName
|
||||
//
|
||||
this.labelFirstName.AutoSize = true;
|
||||
this.labelFirstName.Location = new System.Drawing.Point(12, 44);
|
||||
this.labelFirstName.Name = "labelFirstName";
|
||||
this.labelFirstName.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelFirstName.TabIndex = 2;
|
||||
this.labelFirstName.Text = "First name";
|
||||
//
|
||||
// textBoxFirstName
|
||||
//
|
||||
this.textBoxFirstName.Location = new System.Drawing.Point(142, 41);
|
||||
this.textBoxFirstName.Name = "textBoxFirstName";
|
||||
this.textBoxFirstName.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxFirstName.TabIndex = 3;
|
||||
//
|
||||
// textBoxLastName
|
||||
//
|
||||
this.textBoxLastName.Location = new System.Drawing.Point(142, 70);
|
||||
this.textBoxLastName.Name = "textBoxLastName";
|
||||
this.textBoxLastName.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxLastName.TabIndex = 5;
|
||||
//
|
||||
// labelLastName
|
||||
//
|
||||
this.labelLastName.AutoSize = true;
|
||||
this.labelLastName.Location = new System.Drawing.Point(12, 73);
|
||||
this.labelLastName.Name = "labelLastName";
|
||||
this.labelLastName.Size = new System.Drawing.Size(61, 15);
|
||||
this.labelLastName.TabIndex = 4;
|
||||
this.labelLastName.Text = "Last name";
|
||||
//
|
||||
// textBoxStreet
|
||||
//
|
||||
this.textBoxStreet.Location = new System.Drawing.Point(142, 99);
|
||||
this.textBoxStreet.Name = "textBoxStreet";
|
||||
this.textBoxStreet.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxStreet.TabIndex = 7;
|
||||
//
|
||||
// labelStreet
|
||||
//
|
||||
this.labelStreet.AutoSize = true;
|
||||
this.labelStreet.Location = new System.Drawing.Point(12, 102);
|
||||
this.labelStreet.Name = "labelStreet";
|
||||
this.labelStreet.Size = new System.Drawing.Size(37, 15);
|
||||
this.labelStreet.TabIndex = 6;
|
||||
this.labelStreet.Text = "Street";
|
||||
//
|
||||
// textBoxDepartment
|
||||
//
|
||||
this.textBoxDepartment.Location = new System.Drawing.Point(142, 244);
|
||||
this.textBoxDepartment.Name = "textBoxDepartment";
|
||||
this.textBoxDepartment.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxDepartment.TabIndex = 13;
|
||||
//
|
||||
// labelDepartment
|
||||
//
|
||||
this.labelDepartment.AutoSize = true;
|
||||
this.labelDepartment.Location = new System.Drawing.Point(12, 247);
|
||||
this.labelDepartment.Name = "labelDepartment";
|
||||
this.labelDepartment.Size = new System.Drawing.Size(70, 15);
|
||||
this.labelDepartment.TabIndex = 12;
|
||||
this.labelDepartment.Text = "Department";
|
||||
//
|
||||
// textBoxMobil
|
||||
//
|
||||
this.textBoxMobil.Location = new System.Drawing.Point(142, 215);
|
||||
this.textBoxMobil.Name = "textBoxMobil";
|
||||
this.textBoxMobil.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxMobil.TabIndex = 11;
|
||||
//
|
||||
// labelMobil
|
||||
//
|
||||
this.labelMobil.AutoSize = true;
|
||||
this.labelMobil.Location = new System.Drawing.Point(12, 218);
|
||||
this.labelMobil.Name = "labelMobil";
|
||||
this.labelMobil.Size = new System.Drawing.Size(38, 15);
|
||||
this.labelMobil.TabIndex = 10;
|
||||
this.labelMobil.Text = "Mobil";
|
||||
//
|
||||
// textBoxPhone
|
||||
//
|
||||
this.textBoxPhone.Location = new System.Drawing.Point(142, 157);
|
||||
this.textBoxPhone.Name = "textBoxPhone";
|
||||
this.textBoxPhone.Size = new System.Drawing.Size(212, 23);
|
||||
this.textBoxPhone.TabIndex = 9;
|
||||
//
|
||||
// labelPhone
|
||||
//
|
||||
this.labelPhone.AutoSize = true;
|
||||
this.labelPhone.Location = new System.Drawing.Point(12, 160);
|
||||
this.labelPhone.Name = "labelPhone";
|
||||
this.labelPhone.Size = new System.Drawing.Size(41, 15);
|
||||
this.labelPhone.TabIndex = 8;
|
||||
this.labelPhone.Text = "Phone";
|
||||
//
|
||||
// labelSalutation
|
||||
//
|
||||
this.labelSalutation.AutoSize = true;
|
||||
this.labelSalutation.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelSalutation.Name = "labelSalutation";
|
||||
this.labelSalutation.Size = new System.Drawing.Size(60, 15);
|
||||
this.labelSalutation.TabIndex = 14;
|
||||
this.labelSalutation.Text = "Salutation";
|
||||
//
|
||||
// comboBoxSalutation
|
||||
//
|
||||
this.comboBoxSalutation.FormattingEnabled = true;
|
||||
this.comboBoxSalutation.Location = new System.Drawing.Point(142, 12);
|
||||
this.comboBoxSalutation.Name = "comboBoxSalutation";
|
||||
this.comboBoxSalutation.Size = new System.Drawing.Size(212, 23);
|
||||
this.comboBoxSalutation.TabIndex = 15;
|
||||
//
|
||||
// comboBoxPostal
|
||||
//
|
||||
this.comboBoxPostal.FormattingEnabled = true;
|
||||
this.comboBoxPostal.Location = new System.Drawing.Point(142, 128);
|
||||
this.comboBoxPostal.Name = "comboBoxPostal";
|
||||
this.comboBoxPostal.Size = new System.Drawing.Size(212, 23);
|
||||
this.comboBoxPostal.TabIndex = 17;
|
||||
//
|
||||
// labelPostal
|
||||
//
|
||||
this.labelPostal.AutoSize = true;
|
||||
this.labelPostal.Location = new System.Drawing.Point(12, 131);
|
||||
this.labelPostal.Name = "labelPostal";
|
||||
this.labelPostal.Size = new System.Drawing.Size(39, 15);
|
||||
this.labelPostal.TabIndex = 16;
|
||||
this.labelPostal.Text = "Postal";
|
||||
//
|
||||
// comboBoxPhoneType
|
||||
//
|
||||
this.comboBoxPhoneType.FormattingEnabled = true;
|
||||
this.comboBoxPhoneType.Location = new System.Drawing.Point(142, 186);
|
||||
this.comboBoxPhoneType.Name = "comboBoxPhoneType";
|
||||
this.comboBoxPhoneType.Size = new System.Drawing.Size(212, 23);
|
||||
this.comboBoxPhoneType.TabIndex = 19;
|
||||
//
|
||||
// labelPhoneType
|
||||
//
|
||||
this.labelPhoneType.AutoSize = true;
|
||||
this.labelPhoneType.Location = new System.Drawing.Point(12, 189);
|
||||
this.labelPhoneType.Name = "labelPhoneType";
|
||||
this.labelPhoneType.Size = new System.Drawing.Size(65, 15);
|
||||
this.labelPhoneType.TabIndex = 18;
|
||||
this.labelPhoneType.Text = "PhoneType";
|
||||
//
|
||||
// comboBoxCompany
|
||||
//
|
||||
this.comboBoxCompany.FormattingEnabled = true;
|
||||
this.comboBoxCompany.Location = new System.Drawing.Point(142, 273);
|
||||
this.comboBoxCompany.Name = "comboBoxCompany";
|
||||
this.comboBoxCompany.Size = new System.Drawing.Size(212, 23);
|
||||
this.comboBoxCompany.TabIndex = 21;
|
||||
//
|
||||
// labelCompany
|
||||
//
|
||||
this.labelCompany.AutoSize = true;
|
||||
this.labelCompany.Location = new System.Drawing.Point(12, 276);
|
||||
this.labelCompany.Name = "labelCompany";
|
||||
this.labelCompany.Size = new System.Drawing.Size(59, 15);
|
||||
this.labelCompany.TabIndex = 20;
|
||||
this.labelCompany.Text = "Company";
|
||||
//
|
||||
// ContactView
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(366, 349);
|
||||
this.Controls.Add(this.comboBoxCompany);
|
||||
this.Controls.Add(this.labelCompany);
|
||||
this.Controls.Add(this.comboBoxPhoneType);
|
||||
this.Controls.Add(this.labelPhoneType);
|
||||
this.Controls.Add(this.comboBoxPostal);
|
||||
this.Controls.Add(this.labelPostal);
|
||||
this.Controls.Add(this.comboBoxSalutation);
|
||||
this.Controls.Add(this.labelSalutation);
|
||||
this.Controls.Add(this.textBoxDepartment);
|
||||
this.Controls.Add(this.labelDepartment);
|
||||
this.Controls.Add(this.textBoxMobil);
|
||||
this.Controls.Add(this.labelMobil);
|
||||
this.Controls.Add(this.textBoxPhone);
|
||||
this.Controls.Add(this.labelPhone);
|
||||
this.Controls.Add(this.textBoxStreet);
|
||||
this.Controls.Add(this.labelStreet);
|
||||
this.Controls.Add(this.textBoxLastName);
|
||||
this.Controls.Add(this.labelLastName);
|
||||
this.Controls.Add(this.textBoxFirstName);
|
||||
this.Controls.Add(this.labelFirstName);
|
||||
this.Controls.Add(this.buttonDelete);
|
||||
this.Controls.Add(this.buttonApplyCreate);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ContactView";
|
||||
this.Text = "ContactView";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonApplyCreate;
|
||||
private System.Windows.Forms.Button buttonDelete;
|
||||
private System.Windows.Forms.Label labelFirstName;
|
||||
private System.Windows.Forms.TextBox textBoxFirstName;
|
||||
private System.Windows.Forms.TextBox textBoxLastName;
|
||||
private System.Windows.Forms.Label labelLastName;
|
||||
private System.Windows.Forms.TextBox textBoxStreet;
|
||||
private System.Windows.Forms.Label labelStreet;
|
||||
private System.Windows.Forms.TextBox textBoxDepartment;
|
||||
private System.Windows.Forms.Label labelDepartment;
|
||||
private System.Windows.Forms.TextBox textBoxMobil;
|
||||
private System.Windows.Forms.Label labelMobil;
|
||||
private System.Windows.Forms.TextBox textBoxPhone;
|
||||
private System.Windows.Forms.Label labelPhone;
|
||||
private System.Windows.Forms.Label labelSalutation;
|
||||
private System.Windows.Forms.ComboBox comboBoxSalutation;
|
||||
private System.Windows.Forms.ComboBox comboBoxPostal;
|
||||
private System.Windows.Forms.Label labelPostal;
|
||||
private System.Windows.Forms.ComboBox comboBoxPhoneType;
|
||||
private System.Windows.Forms.Label labelPhoneType;
|
||||
private System.Windows.Forms.ComboBox comboBoxCompany;
|
||||
private System.Windows.Forms.Label labelCompany;
|
||||
}
|
||||
}
|
||||
96
AppointmentsManager/AppointmentsUi/Views/ContactView.cs
Normal file
96
AppointmentsManager/AppointmentsUi/Views/ContactView.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
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 ContactView : Form
|
||||
{
|
||||
Contact? contact;
|
||||
|
||||
IEnumerable<Salutation> salutations;
|
||||
IEnumerable<Postal> postals;
|
||||
IEnumerable<PhoneType> phoneTypes;
|
||||
IEnumerable<Company> companies;
|
||||
|
||||
public ContactView(Contact? contact)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.contact = contact;
|
||||
|
||||
salutations = Salutation.GetSalutations();
|
||||
postals = Postal.GetPostals();
|
||||
phoneTypes = PhoneType.GetPhoneTypes();
|
||||
companies = Company.GetCompanies();
|
||||
|
||||
comboBoxSalutation.Items.AddRange(salutations.Select(sal => $"{sal.SalutationId}: {sal.Label}").ToArray());
|
||||
comboBoxPostal.Items.AddRange(postals.Select(sal => $"{sal.PostalId}: {sal.Label}").ToArray());
|
||||
comboBoxPhoneType.Items.AddRange(phoneTypes.Select(sal => $"{sal.PhoneTypeId}: {sal.Label}").ToArray());
|
||||
comboBoxCompany.Items.AddRange(companies.Select(sal => $"{sal.CompanyId}: {sal.Label}").ToArray());
|
||||
|
||||
if (contact == null)
|
||||
{
|
||||
// create new contact
|
||||
buttonApplyCreate.Text = "Create";
|
||||
|
||||
buttonApplyCreate.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
var salutationId = Int32.Parse(comboBoxSalutation.SelectedItem.ToString().Split(":").First());
|
||||
var postalId = Int32.Parse(comboBoxPostal.SelectedItem.ToString().Split(":").First());
|
||||
var phoneTypeId = Int32.Parse(comboBoxPhoneType.SelectedItem.ToString().Split(":").First());
|
||||
var companyId = Int32.Parse(comboBoxCompany.SelectedItem.ToString().Split(":").First());
|
||||
|
||||
Contact.Create(salutationId, textBoxFirstName.Text, textBoxLastName.Text, textBoxStreet.Text, postalId, textBoxPhone.Text, phoneTypeId, textBoxMobil.Text, companyId, textBoxDepartment.Text);
|
||||
this.Close();
|
||||
});
|
||||
|
||||
buttonDelete.Enabled = false;
|
||||
} else
|
||||
{
|
||||
textBoxFirstName.Text = contact.FirstName;
|
||||
textBoxLastName.Text = contact.LastName;
|
||||
textBoxStreet.Text = contact.Street;
|
||||
textBoxDepartment.Text = contact.Department;
|
||||
textBoxPhone.Text = contact.Phone;
|
||||
textBoxMobil.Text = contact.Mobil;
|
||||
|
||||
buttonApplyCreate.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
var salutationId = Int32.Parse(comboBoxSalutation.SelectedItem.ToString().Split(":").First());
|
||||
var postalId = Int32.Parse(comboBoxPostal.SelectedItem.ToString().Split(":").First());
|
||||
var phoneTypeId = Int32.Parse(comboBoxPhoneType.SelectedItem.ToString().Split(":").First());
|
||||
var companyId = Int32.Parse(comboBoxCompany.SelectedItem.ToString().Split(":").First());
|
||||
|
||||
contact.FirstName = textBoxFirstName.Text;
|
||||
contact.LastName = textBoxLastName.Text;
|
||||
contact.Street = textBoxStreet.Text;
|
||||
contact.Phone = textBoxPhone.Text;
|
||||
contact.Mobil = textBoxMobil.Text;
|
||||
contact.Department = textBoxDepartment.Text;
|
||||
|
||||
contact.Salutation = Salutation.GetSalutationById(salutationId);
|
||||
contact.Postal = Postal.GetPostalById(postalId);
|
||||
contact.PhoneType = PhoneType.GetPhoneTypeById(phoneTypeId);
|
||||
contact.Company = Company.GetCompanyById(companyId);
|
||||
|
||||
contact.Save();
|
||||
|
||||
this.Close();
|
||||
});
|
||||
|
||||
comboBoxSalutation.SelectedItem = $"{contact.Salutation.SalutationId}: {contact.Salutation.Label}";
|
||||
comboBoxPostal.SelectedItem = $"{contact.Postal.PostalId}: {contact.Postal.Label}";
|
||||
comboBoxPhoneType.SelectedItem = $"{contact.PhoneType.PhoneTypeId}: {contact.PhoneType.Label}";
|
||||
comboBoxCompany.SelectedItem = $"{contact.Company.CompanyId}: {contact.Company.Label}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AppointmentsManager/AppointmentsUi/Views/ContactView.resx
Normal file
60
AppointmentsManager/AppointmentsUi/Views/ContactView.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
95
AppointmentsManager/AppointmentsUi/Views/ContactsList.Designer.cs
generated
Normal file
95
AppointmentsManager/AppointmentsUi/Views/ContactsList.Designer.cs
generated
Normal file
@@ -0,0 +1,95 @@
|
||||
namespace AppointmentsUi.Views
|
||||
{
|
||||
partial class ContactsList
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonAddNewContact = new System.Windows.Forms.Button();
|
||||
this.labelContactsHeader = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanelContacts = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonAddNewContact
|
||||
//
|
||||
this.buttonAddNewContact.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonAddNewContact.Location = new System.Drawing.Point(725, -1);
|
||||
this.buttonAddNewContact.Name = "buttonAddNewContact";
|
||||
this.buttonAddNewContact.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonAddNewContact.TabIndex = 11;
|
||||
this.buttonAddNewContact.Text = "Add new";
|
||||
this.buttonAddNewContact.UseVisualStyleBackColor = true;
|
||||
this.buttonAddNewContact.Click += new System.EventHandler(this.buttonAddNewContact_Click);
|
||||
//
|
||||
// labelContactsHeader
|
||||
//
|
||||
this.labelContactsHeader.AutoSize = true;
|
||||
this.labelContactsHeader.Location = new System.Drawing.Point(-1, 3);
|
||||
this.labelContactsHeader.Name = "labelContactsHeader";
|
||||
this.labelContactsHeader.Size = new System.Drawing.Size(54, 15);
|
||||
this.labelContactsHeader.TabIndex = 10;
|
||||
this.labelContactsHeader.Text = "Contacts";
|
||||
//
|
||||
// tableLayoutPanelContacts
|
||||
//
|
||||
this.tableLayoutPanelContacts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tableLayoutPanelContacts.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.tableLayoutPanelContacts.ColumnCount = 4;
|
||||
this.tableLayoutPanelContacts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanelContacts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanelContacts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanelContacts.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanelContacts.Location = new System.Drawing.Point(-1, 28);
|
||||
this.tableLayoutPanelContacts.Name = "tableLayoutPanelContacts";
|
||||
this.tableLayoutPanelContacts.RowCount = 1;
|
||||
this.tableLayoutPanelContacts.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanelContacts.Size = new System.Drawing.Size(802, 423);
|
||||
this.tableLayoutPanelContacts.TabIndex = 9;
|
||||
//
|
||||
// ContactsList
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonAddNewContact);
|
||||
this.Controls.Add(this.labelContactsHeader);
|
||||
this.Controls.Add(this.tableLayoutPanelContacts);
|
||||
this.Name = "ContactsList";
|
||||
this.Text = "ContactsList";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonAddNewContact;
|
||||
private System.Windows.Forms.Label labelContactsHeader;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanelContacts;
|
||||
}
|
||||
}
|
||||
56
AppointmentsManager/AppointmentsUi/Views/ContactsList.cs
Normal file
56
AppointmentsManager/AppointmentsUi/Views/ContactsList.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
AppointmentsManager/AppointmentsUi/Views/ContactsList.resx
Normal file
60
AppointmentsManager/AppointmentsUi/Views/ContactsList.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user