public int calculatePenalty(String userID) { int mID = Convert.ToInt32(userID); penaltyDB3 penalty = db.penaltyDB3.FirstOrDefault(x => x.memID == mID); DateTime oldDate = (DateTime)penalty.date; DateTime now = DateTime.Now; TimeSpan ts = now - oldDate; return((ts.Days) * 3); }
public void controlPenalty() { var query = db.loan_DB2.ToList(); foreach (loan_DB2 x in query) { if (DateTime.Now > x.duedate) { penaltyDB3 penalty = new penaltyDB3(); penalty.matID = x.matID; penalty.memID = x.memID; penalty.date = x.duedate; } } }
protected void LinkButtonTake_Click(object sender, EventArgs e) { String memID = Session["usN"].ToString(); int id = Convert.ToInt32(memID); penaltyDB3 penalty = db.penaltyDB3.FirstOrDefault(x => x.memID == id); db.penaltyDB3.Remove(penalty); db.SaveChanges(); int matID = (int)penalty.matID; loan_DB2 loanDB2 = db.loan_DB2.FirstOrDefault(x => x.matID == matID); db.loan_DB2.Remove(loanDB2); db.SaveChanges(); dl.setAvaibleZero(matID); db.SaveChanges(); }