70 lines
2.4 KiB
C#
70 lines
2.4 KiB
C#
using Controls;
|
|
using Controls.Exceptions;
|
|
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 Forms
|
|
{
|
|
public partial class FormMain : Form
|
|
{
|
|
public FormMain()
|
|
{
|
|
InitializeComponent();
|
|
customComboBox.ComboBoxItems.Add("Chel1");
|
|
customComboBox.ComboBoxItems.Add("Chel2");
|
|
customComboBox.SelectedItem = "Chel1";
|
|
|
|
customTextBoxNumber.NumPattern = @"^\+7\d{10}$";
|
|
|
|
customListBox.SetTemplateString("Имя: {Name}, Код: {Code}, Номер: {Number}", "{", "}");
|
|
Department dep1 = new Department { Name = "Отдел продаж", Code = "705", Number = "+79677156215" };
|
|
Department dep2 = new Department { Name = "Отдел маркетинга", Code = "706", Number = "+79278146171" };
|
|
customListBox.FillProperty(dep1, 0, "Name");
|
|
customListBox.FillProperty(dep1, 0, "Code");
|
|
customListBox.FillProperty(dep1, 0, "Number");
|
|
|
|
customListBox.FillProperty(dep2, 1, "Name");
|
|
customListBox.FillProperty(dep2, 1, "Code");
|
|
customListBox.FillProperty(dep2, 1, "Number");
|
|
}
|
|
private void buttonValidate_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string phoneNumber = customTextBoxNumber.TextBoxNumber;
|
|
MessageBox.Show($"Введенный номер: {phoneNumber}");
|
|
}
|
|
catch (CustomNumberException ex)
|
|
{
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void buttonGetObject_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
Department selectedPerson = customListBox.GetObjectFromStr<Department>();
|
|
MessageBox.Show($"Отдел. Имя: {selectedPerson.Name}, Код: {selectedPerson.Code}, Номер: {selectedPerson.Number}");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Ошибка: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
customComboBox.ComboBoxItems.Add("ChelNew");
|
|
}
|
|
|
|
}
|
|
}
|