158 lines
5.1 KiB
C#
158 lines
5.1 KiB
C#
using MySqlX.XDevAPI.Relational;
|
|
using PaymentLogs.Domain;
|
|
using PaymentLogs.Forms;
|
|
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
|
|
{
|
|
public partial class DataForm : Form
|
|
{
|
|
private Course _course;
|
|
public DataForm(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("course", "Курс");
|
|
dataGridView1.Columns.Add("course_price", "Цена");
|
|
dataGridView1.Columns.Add("paid", "Оплачено");
|
|
dataGridView1.Columns.Add("debt", "Долг");
|
|
foreach (Payment payment in Program.PaymentRepository.All())
|
|
{
|
|
if(payment.CourseId != _course.Id)
|
|
{
|
|
continue;
|
|
}
|
|
dataGridView1.Rows.Add(payment.Id.ToString(), payment.FCs.ToString(), Program.CourseRepository.Get(payment.CourseId).Name,
|
|
payment.CoursePrice.ToString(), payment.Paid.ToString(), payment.Debt.ToString());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void toolStripSplitButton1_ButtonClick(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
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)
|
|
{
|
|
Payment payment = new Payment
|
|
{
|
|
Id = Convert.ToInt32(row.Cells["id"].Value),
|
|
FCs = row.Cells["fcs"].Value.ToString(),
|
|
CourseId = Program.CourseRepository.ByName(row.Cells["course"].Value.ToString()).Id,
|
|
CoursePrice = Convert.ToInt32(row.Cells["course_price"].Value),
|
|
Paid = Convert.ToInt32(row.Cells["paid"].Value),
|
|
Debt = Convert.ToInt32(row.Cells["debt"].Value)
|
|
};
|
|
Program.PaymentRepository.Update(payment.Id, payment);
|
|
}
|
|
|
|
|
|
} catch(NullReferenceException ignored)
|
|
{
|
|
Console.WriteLine(ignored.Message);
|
|
} catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
|
|
}
|
|
Program.PaymentRepository.Save();
|
|
}
|
|
|
|
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["course"].Value.ToString(), row.Cells["course_price"].Value.ToString(),
|
|
row.Cells["paid"].Value.ToString(), row.Cells["debt"].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 textBox1_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void toolStripButton1_Click(object sender, EventArgs e)
|
|
{
|
|
dataGridView1.Rows.Clear();
|
|
Form1_Load(null, null);
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void toolStripButton3_Click(object sender, EventArgs e)
|
|
{
|
|
this.Hide();
|
|
new MainForm().Show();
|
|
}
|
|
}
|
|
}
|