3 рабочая!!!

This commit is contained in:
Екатерина Рогашова 2023-11-04 20:53:49 +04:00
parent 468e37445f
commit 80a2db6aaf
4 changed files with 48 additions and 20 deletions

View File

@ -17,7 +17,8 @@ namespace UniversityContracts.ViewModels
public string Сharacteristic { get; set; } = string.Empty;
[DisplayName("Курс")]
public string Course { get; set; } = string.Empty;
[DisplayName("Стипендия")]
public int? Scholarship { get; set; }
[DisplayName("Стипендия")]
public string ScholarshipStr { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UniversityDataModels.Models;
namespace UniversityContracts.ViewModels
{
public class StudentViewModel1 : IStudentModel
{
public int Id { get; set; }
[DisplayName("ФИО")]
public string FIO { get; set; } = string.Empty;
[DisplayName("Краткая характеристика")]
public string Сharacteristic { get; set; } = string.Empty;
[DisplayName("Курс")]
public string Course { get; set; } = string.Empty;
[DisplayName("Стипендия")]
public string ScholarshipStr { get; set; } = string.Empty;
public int? Scholarship { get; set; }
}
}

View File

@ -59,7 +59,8 @@ namespace UniversityDataBaseImplements.Models
Course = Course,
FIO = FIO,
Scholarship = Scholarship,
Сharacteristic = Сharacteristic
Сharacteristic = Сharacteristic,
ScholarshipStr = Scholarship.ToString()
};
}

View File

@ -23,7 +23,7 @@ namespace UniversityForms
_studentLogic = studentLogic;
_courseLogic = courseLogic;
InitializeComponent();
List<string> stringToHierachy = new List<string>() { "Course", "Scholarship", "Id", "FIO" };
List<string> stringToHierachy = new List<string>() { "Course", "ScholarshipStr", "Id", "FIO" };
myTreeView1.addToHierarchy(stringToHierachy);
myTreeView1.ContextMenuStrip = contextMenuStrip1;
}
@ -38,7 +38,7 @@ namespace UniversityForms
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].Scholarship = 0; }
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "Íåò ñòèïåíäèè"; }
}
myTreeView1.LoadTree(list);
}
@ -179,14 +179,14 @@ namespace UniversityForms
var list = _studentLogic.ReadList(null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].Scholarship == null) { list[i].Scholarship = 0; }
if (list[i].Scholarship == null) { list[i].ScholarshipStr = "No"; }
}
var columnConfigs = new List<ColumnConfig>
{
new ColumnConfig { Width = 50f, PropertyName = "Id", ShowName = "Id"},
new ColumnConfig { Width = 300f, PropertyName = "FIO", ShowName = "FIO" },
new ColumnConfig { Width = 100f, PropertyName = "Course", ShowName = "Course" },
new ColumnConfig { Width = 100f, PropertyName = "Scholarship", ShowName = "Scholarship" },
new ColumnConfig { Width = 100f, PropertyName = "ScholarshipStr", ShowName = "Scholarship" },
};
using var dialog = new SaveFileDialog
{
@ -209,20 +209,22 @@ namespace UniversityForms
private void èçìåíèòüToolStripMenuItem_Click(object sender, EventArgs e)
{
//if (MessageBox.Show("Óäàëèòü çàïèñü", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
//{
// var selected = userTreeView1.GetSelectedObject<StudentBindingModels>();
// int id = Convert.ToInt32((selected as StudentBindingModels).Id);
// try
// {
// _studentLogic.Delete(new StudentBindingModels { Id = id });
// }
// catch (Exception ex)
// {
// MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
// LoadData();
//}
if (MessageBox.Show("Óäàëèòü çàïèñü", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var selectedClient = myTreeView1.GetNode(typeof(StudentViewModel));
if (selectedClient != null)
{
int id = Convert.ToInt32((selectedClient as StudentViewModel).Id);
try
{
_studentLogic.Delete(new StudentBindingModels { Id = id });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
}