debt calc
This commit is contained in:
1 parent
ecfe62cc05
commit
71dd5be182
3 files changed
+11
-10
No files matched your search
@@ -13,6 +13,5 @@ namespace PaymentLogs.Domain
|
||||
public int CourseId { get; set; }
|
||||
public int CoursePrice { get; set; }
|
||||
public int Paid { get; set; }
|
||||
public int Debt { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ namespace PaymentLogs
|
||||
dataGridView1.Columns.Add("course_price", "Цена");
|
||||
dataGridView1.Columns.Add("paid", "Оплачено");
|
||||
dataGridView1.Columns.Add("debt", "Долг");
|
||||
dataGridView1.Columns["debt"].ReadOnly = true;
|
||||
foreach (Payment payment in Program.PaymentRepository.All())
|
||||
{
|
||||
if(payment.CourseId != _course.Id)
|
||||
@@ -40,7 +41,7 @@ namespace PaymentLogs
|
||||
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());
|
||||
payment.CoursePrice.ToString(), payment.Paid.ToString(), (payment.CoursePrice - payment.Paid).ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +59,7 @@ namespace PaymentLogs
|
||||
|
||||
private void toolStripButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.ActiveControl = null;
|
||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||
{
|
||||
try
|
||||
@@ -70,8 +72,7 @@ namespace PaymentLogs
|
||||
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)
|
||||
Paid = Convert.ToInt32(row.Cells["paid"].Value)
|
||||
};
|
||||
Program.PaymentRepository.Update(payment.Id, payment);
|
||||
}
|
||||
@@ -109,7 +110,9 @@ namespace PaymentLogs
|
||||
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() };
|
||||
row.Cells["paid"].Value.ToString(),
|
||||
(Convert.ToInt32(row.Cells["course_price"].Value.ToString()) - (Convert.ToInt32(row.Cells["paid"])))
|
||||
.ToString() };
|
||||
|
||||
filtredList.Add(list);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user