Some fixes

This commit is contained in:
redtea committed 2024-05-23 23:36:54 +03:00
1 parent 1f6634add4
commit c2ae11a61b
22 files changed
+47 -2

No files matched your search

+26 -1
View File
@@ -27,12 +27,14 @@ namespace PaymentLogs
dataGridView1.Columns.Add("fcs", "ФИО");
dataGridView1.Columns.Add("course", "Курс");
dataGridView1.Columns.Add("course_price", "Цена");
dataGridView1.Columns.Add("paid", "Оплачено");
dataGridView1.Columns.Add("debt", "Долг");
/* BindingList<Payment> list1 = new BindingList<Payment>();
dataGridView1.DataSource = list1;*/
foreach (Payment payment in Program.PaymentRepository.All())
{
dataGridView1.Rows.Add(payment.Id.ToString(), payment.FCs, Program.CourseRepository.ById(payment.CourseId).Name, payment.CoursePrice.ToString(), payment.Debt.ToString());
dataGridView1.Rows.Add(payment.Id.ToString(), payment.FCs, Program.CourseRepository.Get(payment.CourseId).Name,
payment.CoursePrice.ToString(), payment.Paid.ToString(), payment.Debt.ToString());
}
}
@@ -50,5 +52,28 @@ namespace PaymentLogs
{
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
try
{
Payment payment = new Payment
{
Id = Convert.ToInt32(row.Cells["id"].Value),
FCs = row.Cells["fcs"].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)
{ }
}
Program.PaymentRepository.Save();
}
}
}