laba4
.pdf11
Рисунок 2.16 – Запрос баллов по убыванию
Создадим вкладку для подзапросов. Результаты подзапросов представлены на рисунках 2.17-2.18.
Рисунок 2.17 – Работа подзапроса
12
Рисунок 2.18 – Работа подзапроса Создадим страницу «Запросы изменения данных» (рисунок 2.19).
Рисунок 2.19 – Страница «Запросы изменения данных»
13
Заключение
В ходе выполнения данной лабораторной работы были изучены основные особенности формирования запросов в приложении Microsoft Visual Studio для своей предметной области.
14
Приложение А
Листинг Form1
using System;
using System.Windows.Forms;
namespace BAZA
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
private void выходToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void оПрограммеToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("(C)ТУСУР,КИБЭВС,Подойницын Кирилл Вадимович,гр. 730- 2,2022", "О программе",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
Close();
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
MessageBox.Show("(C)ТУСУР,КИБЭВС,Подойницын Кирилл Вадимович,гр. 730- 2,2022", "О программе",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void абитуриентToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAbiturient fa = new FormAbiturient(); fa.Show();
}
private void вУЗToolStripMenuItem_Click(object sender, EventArgs e)
{
FormVUZ1 fv = new FormVUZ1(); fv.Show();
}
private void конкурсныйСписокToolStripMenuItem_Click(object sender, EventArgs e)
{
FormSpisok fs = new FormSpisok(); fs.Show();
}
private void сотрудникКомиссииToolStripMenuItem_Click(object sender, EventArgs e)
{
FormSotrudnik fs1 = new FormSotrudnik(); fs1.Show();
}
15
private void специальностиToolStripMenuItem_Click(object sender, EventArgs e)
{
FormSpecialnosti fs2 = new FormSpecialnosti(); fs2.Show();
}
private void абитуриентToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormAbiturient fa = new FormAbiturient(); fa.Show();
}
private void вУЗToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormVUZ1 fv = new FormVUZ1(); fv.Show();
}
private void конкурсныйСписокToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormSpisok fs = new FormSpisok(); fs.Show();
}
private void сотрудникКомиссииToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormSotrudnik fs1 = new FormSotrudnik(); fs1.Show();
}
private void специальностиToolStripMenuItem1_Click(object sender, EventArgs e)
{
FormSpecialnosti fs2 = new FormSpecialnosti(); fs2.Show();
}
private void конкурсныйСписокToolStripMenuItem2_Click(object sender, EventArgs e)
{
KonkursniySpisok ks = new KonkursniySpisok(); ks.Show();
}
private void запросыToolStripMenuItem_Click(object sender, EventArgs e)
{
FormSQL fsp = new FormSQL(); fsp.Show();
}
}
}
16
Приложение Б
Листинг FormAbiturient
using System;
using System.Windows.Forms;
namespace BAZA
{
public partial class FormAbiturient : Form
{
public FormAbiturient()
{
InitializeComponent();
}
private void абитуриентBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate(); this.абитуриентBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void абитуриентBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
{
this.Validate(); this.абитуриентBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void абитуриентBindingNavigatorSaveItem_Click_2(object sender, EventArgs e)
{
this.Validate(); this.абитуриентBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void FormAbiturient_Load(object sender, EventArgs e)
{
this.абитуриентTableAdapter.Fill(this.vUZDataSet.абитуриент);
}
}
}
17
Приложение В
Листинг FormSotrudnik
using System;
using System.Windows.Forms;
namespace BAZA
{
public partial class FormSotrudnik : Form
{
public FormSotrudnik()
{
InitializeComponent();
}
private void сотрудник_комиссииBindingNavigatorSaveItem_Click(object sender, EventArgs
e)
{
this.Validate(); this.сотрудник_комиссииBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void FormSotrudnik_Load(object sender, EventArgs e)
{
this.сотрудник_комиссииTableAdapter.Fill(this.vUZDataSet.Сотрудник_комиссии);
}
}
}
18
Приложение Г
Листинг FormSpecialnosti
using System;
using System.Windows.Forms;
namespace BAZA
{
public partial class FormSpecialnosti : Form
{
public FormSpecialnosti()
{
InitializeComponent();
}
private void специальностиBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate(); this.специальностиBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void FormSpecialnosti_Load(object sender, EventArgs e)
{
this.специальностиTableAdapter.Fill(this.vUZDataSet.Специальности);
}
string GetSelectedFieldName()
{
return
специальностиDataGridView.Columns[специальностиDataGridView.CurrentCell.ColumnIndex ].DataPropertyName;
}
private void toolStripButtonFind_Click(object sender, EventArgs e)
{
if (toolStripTextBoxFind.Text == "")
{
MessageBox.Show("Вы ничего не задали", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
}
int indexPos; try
{
indexPos = специальностиBindingSource.Find(GetSelectedFieldName(), toolStripTextBoxFind.Text);
}
catch (Exception err)
{
MessageBox.Show("Ошибка поиска \n" + err.Message); return;
}
if (indexPos > -1) специальностиBindingSource.Position = indexPos;
19
else
{
MessageBox.Show("Таких данных нет", "Внимание",
MessageBoxButtons.OK, MessageBoxIcon.Information); специальностиBindingSource.Position = 0;
}
}
private void checkBoxFind_CheckedChanged(object sender, EventArgs e)
{
if (checkBoxFind.Checked)
{
if (toolStripTextBoxFind.Text == "")
MessageBox.Show("Вы ничего не задали", "Внимание",
MessageBoxButtons.OK, MessageBoxIcon.Information); else
try
{
специальностиBindingSource.Filter =
GetSelectedFieldName() + "='" + toolStripTextBoxFind.Text + "'";
}
catch (Exception err)
{
MessageBox.Show("Ошибка фильтрации \n" + err.Message);
}
}
else
специальностиBindingSource.Filter = ""; if (специальностиBindingSource.Count == 0)
{
MessageBox.Show("Нет таких данных"); специальностиBindingSource.Filter = ""; checkBoxFind.Checked = false;
}
}
}
}
20
Приложение Д
Листинг FormSpisok
using System;
using System.Windows.Forms;
namespace BAZA
{
public partial class FormSpisok : Form
{
public FormSpisok()
{
InitializeComponent();
}
private void конкурсный_списокBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate(); this.конкурсный_списокBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.vUZDataSet);
}
private void FormSpisok_Load(object sender, EventArgs e)
{
this.конкурсный_списокTableAdapter.Fill(this.vUZDataSet.Конкурсный_список);
}
}
}