Setup and forms
This commit is contained in:
1 parent
aed55f44f9
commit
eee7548fc8
47 files changed
+2837
-8138
No files matched your search
@@ -0,0 +1,127 @@
|
||||
using PaymentLogs.Domain;
|
||||
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 PaymentLogs.Forms
|
||||
{
|
||||
public partial class StudentsForm : Form
|
||||
{
|
||||
private Course _course;
|
||||
public StudentsForm(string courseName)
|
||||
{
|
||||
InitializeComponent();
|
||||
_course = Program.CourseRepository.ByName(courseName);
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
dataGridView1.Columns.Add("id", "Номер");
|
||||
dataGridView1.Columns.Add("fcs", "ФИО");
|
||||
dataGridView1.Columns.Add("dateOfBirth", "Дата рождения");
|
||||
dataGridView1.Columns.Add("address", "Адрес проживания");
|
||||
dataGridView1.Columns.Add("course", "Дисциплина");
|
||||
dataGridView1.Columns.Add("paid", "Оплачено");
|
||||
|
||||
foreach(Student student in Program.StudentRepository.All())
|
||||
{
|
||||
if (student.CourseId != _course.Id) continue;
|
||||
//yyyy-MM-dd
|
||||
dataGridView1.Rows.Add(student.Id.ToString(), student.FCs.ToString(), String.Format("{0:dd-MM-yyyy}", student.dateOfBirth),
|
||||
student.Address.ToString(), Program.CourseRepository.Get(student.CourseId).Name.ToString(), student.Paid.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void toolStripButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (row.Cells.Count > 1 && row.Cells["id"].Value != null)
|
||||
{
|
||||
Student student = new Student
|
||||
{
|
||||
Id = Convert.ToInt32(row.Cells["id"].Value),
|
||||
FCs = row.Cells["fcs"].Value.ToString(),
|
||||
dateOfBirth = DateTime.ParseExact(row.Cells["dateOfBirth"].Value.ToString(), "dd-MM-yyyy", null),
|
||||
Address = row.Cells["address"].Value.ToString(),
|
||||
CourseId = Program.CourseRepository.ByName(row.Cells["course"].Value.ToString()).Id,
|
||||
Paid = Convert.ToInt32(row.Cells["paid"].Value.ToString())
|
||||
};
|
||||
Program.StudentRepository.Update(student.Id, student);
|
||||
}
|
||||
|
||||
}
|
||||
catch (NullReferenceException ignored) { }
|
||||
catch (Exception ignored) { }
|
||||
}
|
||||
Program.StudentRepository.Save();
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
string FCsText = textBox1.Text;
|
||||
List<List<string>> filtredList = new List<List<string>>();
|
||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (row.Cells["fcs"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string FCs = row.Cells["fcs"].Value.ToString();
|
||||
string course = row.Cells["course"].Value.ToString();
|
||||
if (((FCs.Equals(FCsText))))
|
||||
{
|
||||
List<string> list = new List<string>
|
||||
{ row.Cells["id"].Value.ToString(), row.Cells["fcs"].Value.ToString(),
|
||||
row.Cells["dateOfBirth"].Value.ToString(), row.Cells["address"].Value.ToString(),
|
||||
row.Cells["course"].Value.ToString(), row.Cells["paid"].Value.ToString() };
|
||||
|
||||
filtredList.Add(list);
|
||||
}
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
dataGridView1.Rows.Clear();
|
||||
foreach (List<String> args in filtredList)
|
||||
{
|
||||
dataGridView1.Rows.Add(args[0], args[1], args[2], args[3], args[4], args[5]);
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Hide();
|
||||
(new StudentsForm(_course.Name)).Show();
|
||||
}
|
||||
|
||||
private void toolStripButton3_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Hide();
|
||||
(new MainForm()).Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user