
Заключение
В результате выполнения курсовой работы был разработан программный продукт на языке С#. Интерфейс представляет собой экранные форму с меню и диалоговыми окнами.
Плюсами спроектированной программы являются:
удобный, интуитивно понятный интерфейс;
защита от неправильного ввода;
Таким образом, в данной курсовой работе решена поставленная задача.
СПИСОК ИСПОЛЬЗОВАННЫХ ИСТОЧНИКОВ
Леоненков А.В. Самоучитель UML.-СПб.: БХВ-Петербург,2001.-304с.
Павловская Т.А. C#. Программирование на языке высокого уровня. Учебник для вузов.-СПб.: Питер, 2007.-432с.
Эндрю Троелсен. Язык программирования C# 2010 и платформа .NET 4.0— 5-е изд. — М.: Вильямс, 2010. — 1392 с.
Герберт Шилдт C# 4.0: полное руководство. - М.: «Вильямс», 2010. — 1056 с.
Кристиан Нейгел, Карли Уотсон и др. Visual C# 2010: полный курс. - М.: Диалектика, 2010.
Трей Нэш C# 2010: ускоренный курс для профессионалов.- М.: Вильямс, 2010. — 592 с.
Приложение a
Содержание файла Insert.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace makler { public partial class Insert : Form { public Insert() { InitializeComponent(); } void Button1Click(object sender, EventArgs e) {//обработик нажатия кнопки ввод try {//обработичк неправильного ввода double S = Convert.ToDouble(textBox1.Text); int floor = Convert.ToInt32(textBox2.Text); int count_room = Convert.ToInt32(textBox3.Text); string area = textBox4.Text; double S1 = Convert.ToDouble(textBox5.Text); int floor1 = Convert.ToInt32(textBox6.Text); int count_room1 = Convert.ToInt32(textBox7.Text); string area1 = textBox8.Text; MessageBox.Show("Запись успешно добавлена"); file.insert(S,S1,floor,floor1,count_room,count_room1,area,area1); } catch (System.FormatException) { MessageBox.Show("Неправильный ввод"); } } } }
Содержание файла MainForm.cs
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace makler
{
public class apartment
{//Класс описывающий квартиру
public double S; //площадь
public int floor; //этаж
public int count_room; //количество комнат
public string area; //район
public apartment()
{
}
public apartment(double a, int b, int c, string d)
{//Конструктор с параметрами
S = a;
floor = b;
count_room = c;
area = d;
}
}
public class request
{//заявка
public apartment demand;//Запрашиваемая квартира
public apartment available;//имеющаяся квартира
public request()
{
demand = new apartment();
available = new apartment();
}
public request(apartment a, apartment b)
{//Конструктор
demand = a;
available = b;
}
}
public static class file
{//картотека
//Класс статический. Не требует объявления объектов
public static List<request> lib;//сам List содержащий заявки о квартирах.
static file()
{//конструктор по умолчанию
lib = new List<request>();
}
public static void insert(
double S,
double S1,
int floor,
int floor1,
int count_room,
int count_room1,
string area,
string area1)
{//Вставка заявки в картотеку
apartment temp1 = new apartment(S, floor,count_room,area);
apartment temp2 = new apartment(S1, floor1, count_room1, area1);
request temp3 = new request(temp1,temp2);
lib.Add( temp3 );
}
}
public partial class MainForm : Form
{
//public file LIBRARY = new file();
public MainForm()
{
InitializeComponent();
}
Insert form_insert;
Search form_search;
View form_view;
void InputToolStripMenuItemClick(object sender, EventArgs e)
{//Ввод данных в картотеку
form_insert = new Insert();
form_insert.Show();
}
void ViewToolStripMenuItemClick(object sender, EventArgs e)
{//Вывод картотеки на экран
form_view = new View();
form_view.Show();
string []temp = new string[8];
foreach (var element in file.lib) {
temp[0] = element.available.S.ToString();
temp[1] = element.available.count_room.ToString();
temp[2] = element.available.floor.ToString();
temp[3] = element.available.area;
temp[4] = element.demand.S.ToString();
temp[5] = element.demand.count_room.ToString();
temp[6] = element.demand.floor.ToString();
temp[7] = element.demand.area;
form_view.dataGridView1.Rows.Add(temp);
}
}
void SearchToolStripMenuItemClick(object sender, EventArgs e)
{
form_search = new Search();
form_search.Show();
}
}
}
Содержание файла View.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace makler
{
public partial class View : Form
{
public View()
{
InitializeComponent();
}
}
}
Содержание файла Search.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace makler
{
public partial class Search : Form
{
public Search()
{
InitializeComponent();
}
private bool search(request a)
{
double S = Convert.ToDouble(textBox1.Text);
int floor = Convert.ToInt32(textBox3.Text);
int count_room = Convert.ToInt32(textBox2.Text);
string area = textBox4.Text;
double S1 = Convert.ToDouble(textBox5.Text);
int floor1 = Convert.ToInt32(textBox7.Text);
int count_room1 = Convert.ToInt32(textBox6.Text);
string area1 = textBox8.Text;
if (
(
((a.available.S - a.available.S * 0.1) < S)
||((a.available.S + a.available.S * 0.1) > S)
)
&&(a.available.count_room == count_room)
&&(a.available.floor == floor)
&&(a.available.area == area)
&&(
((a.available.S - a.available.S * 0.1) < S1)
||((a.available.S + a.available.S * 0.1) > S1)
)
&&(a.demand.count_room == count_room1)
&&(a.demand.floor == floor1)
&&(a.demand.area == area1)
)
return true;
else
return false;
}
void Button1Click(object sender, EventArgs e)
{//поиск
request element = new request();
try {
//foreach (var el in file.lib) {
// if(search(el)) {element = el; break;}
//}
element = file.lib.Find(search);
string []temp = new string[8];
temp[0] = element.available.S.ToString();
temp[1] = element.available.count_room.ToString();
temp[2] = element.available.floor.ToString();
temp[3] = element.available.area;
temp[4] = element.demand.S.ToString();
temp[5] = element.demand.count_room.ToString();
temp[6] = element.demand.floor.ToString();
temp[7] = element.demand.area;
dataGridView1.Rows.Add(temp);
file.lib.Remove(element);
} catch (Exception) {
double S = Convert.ToDouble(textBox1.Text);
int floor = Convert.ToInt32(textBox3.Text);
int count_room = Convert.ToInt32(textBox2.Text);
string area = textBox4.Text;
double S1 = Convert.ToDouble(textBox5.Text);
int floor1 = Convert.ToInt32(textBox7.Text);
int count_room1 = Convert.ToInt32(textBox6.Text);
string area1 = textBox8.Text;
file.insert(S,S1,floor,floor1,count_room,count_room1,area,area1);
MessageBox.Show("Данные по запросу не найдены и были добавлены в картотеку");
}
}
void SearchLoad(object sender, EventArgs e)
{
}
}
}