debt calc

This commit is contained in:
redtea committed 2024-06-07 12:06:02 +03:00
1 parent ecfe62cc05
commit 71dd5be182
3 files changed
+11 -10

No files matched your search

+4 -5
View File
@@ -29,8 +29,7 @@ namespace PaymentLogs.Repositories
FCs = reader.GetString("fcs"),
CourseId = reader.GetInt32("course_id"),
CoursePrice = reader.GetInt32("course_price"),
Paid = reader.GetInt32("paid"),
Debt = reader.GetInt32("debt")
Paid = reader.GetInt32("paid")
};
_data[payment.Id] = payment;
@@ -45,10 +44,10 @@ namespace PaymentLogs.Repositories
db.openConnection();
foreach(Payment payment in _data.Values)
{
string sql = $" INSERT INTO `payments` (`id`, `fcs`, `course_id`, `course_price`, `paid`, `debt`) " +
$"VALUES ('{payment.Id}','{payment.FCs}', '{payment.CourseId}', '{payment.CoursePrice}', '{payment.Paid}', '{payment.Debt}') " +
string sql = $" INSERT INTO `payments` (`id`, `fcs`, `course_id`, `course_price`, `paid`) " +
$"VALUES ('{payment.Id}','{payment.FCs}', '{payment.CourseId}', '{payment.CoursePrice}', '{payment.Paid}') " +
$"ON DUPLICATE KEY UPDATE `fcs`='{payment.FCs}', `course_id`='{payment.CourseId}', `course_price` = '{payment.CoursePrice}', " +
$"`paid` = '{payment.Paid}', `debt`='{payment.Debt}'";
$"`paid` = '{payment.Paid}'";
MySqlCommand cmd = new MySqlCommand(sql, db.getConnection());
cmd.ExecuteNonQuery();