Главная страница

курсовая дерево принятия решений. курсач123ДПР. Первая. Анализ прикладной области. Требования к системе 4 Глава вторая. Постановка задачи


Скачать 0.95 Mb.
НазваниеПервая. Анализ прикладной области. Требования к системе 4 Глава вторая. Постановка задачи
Анкоркурсовая дерево принятия решений
Дата01.06.2022
Размер0.95 Mb.
Формат файлаdocx
Имя файлакурсач123ДПР.docx
ТипТехническое задание
#563012
страница6 из 6
1   2   3   4   5   6

{

try

{

foreach (var marks in markParametrs)

{

_serviceMP.CreateElement(marks);

LoadData();

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}

}

using PK_Analysis_Services.BindingModels;

using PK_Analysis_Services.Interfaces;

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using Unity;
namespace PK_Analysis_Forms

{

public partial class Form_Marks : Form

{

[Dependency]

public new IUnityContainer Container { get; set; }
private readonly IParametrService _serviceP;

public Form_Marks(IParametrService serviceP)

{

_serviceP = serviceP;

InitializeComponent();

}
private void Form_Marks_Load(object sender, EventArgs e)

{

List
list = _serviceP.GetList();

dataGridView_Params.DataSource = list;

}
private void button_Add_Click(object sender, EventArgs e)

{

if (dataGridView_Params.SelectedRows.Count == 1)

{

int id = Convert.ToInt32(dataGridView_Params.SelectedRows[0].Cells[0].Value);

try

{

var form = Container.Resolve();

form.paramId = id;

form.Show();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
}

}

}

using PK_Analysis;

using PK_Analysis_Services.BindingModels;

using PK_Analysis_Services.Interfaces;

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using Unity;
namespace PK_Analysis_Forms

{

public partial class Form_Analize : Form

{

[Dependency]

public new IUnityContainer Container { get; set; }
private readonly IPKService _serviceT;

private readonly IParametrService _serviceP;

private readonly IMarkParamService _serviceMP;
public int Id { set { id = value; } }

private int? id;
private List TrebParams;
public Form_Analize(IPKService serviceT, IParametrService serviceP, IMarkParamService serviceMP)

{

_serviceT = serviceT;

_serviceP = serviceP;

_serviceMP = serviceMP;

InitializeComponent();

TrebParams = new List();

}
private void button_Add_Click(object sender, EventArgs e)

{

var form = Container.Resolve();

if (form.ShowDialog() == DialogResult.OK)

{

if (form.model != null)

{

if (id.HasValue)

{

form.model.Id = id.Value;

}

TrebParams.Add(form.model);

}

LoadData();

}

}
private void LoadData()

{

try

{

if (TrebParams != null)

{

dataGridView_Treb.DataSource = null;

dataGridView_Treb.DataSource = TrebParams;

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
private void button_Del_Click(object sender, EventArgs e)

{

if (dataGridView_Treb.SelectedRows.Count == 1)

{

if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

{

try

{

TrebParams.RemoveAt(dataGridView_Treb.SelectedRows[0].Cells[0].RowIndex);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

LoadData();

}

}

}
private void button_Ok_Click(object sender, EventArgs e)

{

List
tels = _serviceT.GetList();

foreach(var treb in TrebParams)

{

for(int i=0;i< tels.Count; i++ )

{

foreach(var par in tels[i].PKParams)

{

ParametrBM param = _serviceP.GetElement(par.ParametrId);

if(par.ParametrId==treb.ParametrId)

{

if (GetMarky(param, par.Value) != treb.Mark)

{

tels.Remove(tels[i]);

i--;

}

}

}

}

}

var form = Container.Resolve();

form.list = tels;

form.Show();

}
public Marks GetMarky(ParametrBM parametr, int chislo)

{

Marks m = Marks.Средняя;

double prin = -100;
List markParametrs = _serviceMP.GetList(parametr);
foreach (MarkParametrBM mp in markParametrs)

{

double down = mp.Down;

double av = mp.Average;

double up = mp.Up;

double p = -100;

if (chislo < av)

{

if (down == 0)

{

p = 0;

}

else

{

p = (chislo - down) / down;

}

}

else if (chislo == av)

{

p = 1;

}

else

{

p = 2 - (chislo / av);

}

if (p > prin)

{

prin = p;

m = mp.Mark;

}
}

return m;

}

}

}

using PK_Analysis;

using PK_Analysis_Services.BindingModels;

using PK_Analysis_Services.Interfaces;

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using Unity;
namespace PK_Analysis_Forms

{

public partial class Form_AddPKParam : Form

{

[Dependency]

public new IUnityContainer Container { get; set; }
private readonly IParametrService _serviceP;
public PKParam model { set; get; }

public Form_AddPKParam(IParametrService serviceP)

{

_serviceP = serviceP;

InitializeComponent();

}
private void button_Ok_Click(object sender, EventArgs e)

{

if (string.IsNullOrEmpty(textBox_Value.Text))

{

MessageBox.Show("Заполните поле значение", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

try

{

Convert.ToInt32(textBox_Value.Text);

}

catch

{

MessageBox.Show("значение должно быть целым числом", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (textBox_Value.Text.Length > 10)

{

MessageBox.Show("Слишком большое число", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}
if (comboBox_Param.SelectedValue == null)

{

MessageBox.Show("Выберите параметр", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

try

{

model = new PKParam

{

ParametrId = Convert.ToInt32(comboBox_Param.SelectedValue),

Value = Convert.ToInt32(textBox_Value.Text)

};
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

DialogResult = DialogResult.OK;

Close();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
private void Form_AddPKParam_Load(object sender, EventArgs e)

{

try

{

List
list = _serviceP.GetList();

if (list != null)

{

comboBox_Param.DisplayMember = "Name";

comboBox_Param.ValueMember = "Id";

comboBox_Param.DataSource = list;

comboBox_Param.SelectedItem = null;

}
}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}

}

using PK_Analysis;

using PK_Analysis_Services.BindingModels;

using PK_Analysis_Services.Interfaces;

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using Unity;
namespace PK_Analysis_Forms

{

public partial class Form_AddPK : Form

{

[Dependency]

public new IUnityContainer Container { get; set; }
private readonly IPKService _serviceT;

private readonly IParametrService _serviceP;
public int Id { set { id = value; } }

private int? id;
private List
PKParams;
public Form_AddPK(IPKService serviceT, IParametrService serviceP)

{

_serviceT = serviceT;

_serviceP = serviceP;

InitializeComponent();

}
private void button_Add_Click(object sender, EventArgs e)

{

var form = Container.Resolve();

if (form.ShowDialog() == DialogResult.OK)

{

if (form.model != null)

{

if (id.HasValue)

{

form.model.Id = id.Value;

}

PKParams.Add(form.model);

}

LoadData();

}

}
private void LoadData()

{

try

{

if (PKParams != null)

{

dataGridView_Params.DataSource = null;

dataGridView_Params.DataSource = PKParams;

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}
}
private void button_Del_Click(object sender, EventArgs e)

{

if (dataGridView_Params.SelectedRows.Count == 1)

{

if (MessageBox.Show("Удалить запись", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

{

try

{

PKParams.RemoveAt(dataGridView_Params.SelectedRows[0].Cells[0].RowIndex);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

LoadData();

}

}

}
private void button_Ok_Click(object sender, EventArgs e)

{

try

{

List
PKParamBMs = new List
();

for (int i = 0; i < PKParams.Count; ++i)

{

PKParamBMs.Add(new PKParam

{

Id = PKParams[i].Id,

ParametrId = PKParams[i].ParametrId,

PKId = PKParams[i].PKId,

Value = PKParams[i].Value

});

}

if (PKParamBMs.Count == 0)

{

MessageBox.Show("Список пуст", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (id.HasValue)

{

_serviceT.UpdElement(new PKBM

{

Date = dateTimePicker_Date.Value,

Name = textBox_Name.Text,

PKParams = PKParamBMs

});

}

else

{

_serviceT.CreateElement(new PKBM

{

Date = dateTimePicker_Date.Value,

Name=textBox_Name.Text,

PKParams = PKParamBMs

});

}

LoadData();

MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

DialogResult = DialogResult.OK;

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
private void Form_AddPK_Load(object sender, EventArgs e)

{
if (id.HasValue)

{

try

{

PKBM view = _serviceT.GetElement(id.Value);

if (view != null)

{

dateTimePicker_Date.Value = view.Date;

textBox_Name.Text = view.Name;

PKParams = view.PKParams;

LoadData();

}

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

button_Ok.Enabled = false;

button_Del.Enabled = false;

button_Add.Enabled = false;

}

else

{

PKParams = new List
();

}

LoadData();

}

}

}

using PK_Analysis;

using PK_Analysis_Services.BindingModels;

using PK_Analysis_Services.Interfaces;

using System;

using System.Collections.Generic;

using System.Windows.Forms;

using Unity;
namespace PK_Analysis_Forms

{

public partial class Form_AddParam : Form

{

[Dependency]

public new IUnityContainer Container { get; set; }
private readonly IMarkParamService _serviceMP;

private readonly IParametrService _serviceP;

List markParametrs;
public int Id { set { id = value; } }

private int? id;
public Form_AddParam(IParametrService serviceP, IMarkParamService serviceMP)

{

_serviceP = serviceP;

_serviceMP = serviceMP;

InitializeComponent();

}
private void button_OK_Click(object sender, EventArgs e)

{

try

{

List markParametrsBMs = new List();

for (int i = 0; i < markParametrs.Count; ++i)

{

markParametrsBMs.Add(new MarkParametr

{

Id = markParametrs[i].Id,

Average= markParametrs[i].Average,

Down= markParametrs[i].Down,

Up= markParametrs[i].Up,

Mark= markParametrs[i].Mark,

});

}

if (markParametrsBMs.Count == 0)

{

MessageBox.Show("Список продуктов пуст", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

return;

}

if (id.HasValue)

{

_serviceP.UpdElement(new ParametrBM

{

Id=(int)id,

Name = textBox_Name.Text,

MarkParametrs = markParametrsBMs

});

}

else

{

_serviceP.CreateElement(new ParametrBM

{

Name = textBox_Name.Text,

MarkParametrs = markParametrsBMs

});

}

MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

DialogResult = DialogResult.OK;

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
private void Form_AddParam_Load(object sender, EventArgs e)

{

if (id.HasValue)

{

try

{

ParametrBM view = _serviceP.GetElement(id.Value);

if (view != null)

{

textBox_Name.Text = view.Name;

LoadData();

}

markParametrs = _serviceMP.GetList(view);
}
catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

else

{

markParametrs = new List();

}

LoadData();
}
private void LoadData()

{

}

private void button_Del_Click(object sender, EventArgs e)

{

}
private void button1_Click(object sender, EventArgs e)

{

try

{

_serviceP.CreateElement(new ParametrBM

{

Name = textBox_Name.Text

});

MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

DialogResult = DialogResult.OK;

Close();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}

}

using PK_Analysis;

using PK_Analysis_Services.BindingModels;

using System;

using System.Windows.Forms;
namespace PK_Analysis_Forms

{

public partial class Form_AddMarkParam : Form

{

public int userId { get; set; }

public int paramId { get; set; }

public MarkParametrBM model { set; get; }

public Form_AddMarkParam()

{

InitializeComponent();

}
private void button_OK_Click(object sender, EventArgs e)

{

try

{

model = new MarkParametrBM

{

Mark = (Marks)comboBox_Mark.SelectedValue,

Down=(int)numericUpDown_MalDown.Value,

Average=(int)numericUpDown_MalAr.Value,

Up=(int)numericUpDown_MalUp.Value,

ParametrId=paramId

};

MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);

DialogResult = DialogResult.OK;

Close();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}
private void Form_AddMarkParam_Load(object sender, EventArgs e)

{

comboBox_Mark.DataSource = Enum.GetValues(typeof(Marks));

}

}

}
1   2   3   4   5   6


написать администратору сайта