private void ExtrapolateTimes() { if (DTEnd == null && DTStart != null && Duration != default(TimeSpan)) { DTEnd = DTStart.Add(Duration); } else if (Duration == default(TimeSpan) && DTStart != null && DTEnd != null) { Duration = DTEnd.Subtract(DTStart); } else if (DTStart == null && Duration != default(TimeSpan) && DTEnd != null) { DTStart = DTEnd.Subtract(Duration); } }
}//end checkOut private double billingCapCalc(string eventID, string guardianID, string transactionDate, double eventFee) { string familyID = guardianID.Remove(guardianID.Length - 1); double cap = 100; int billingStart = 20; int billingEnd = 19; DateTime DTStart; DateTime DTEnd; if (DateTime.Now.Day > billingEnd) { DTStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, billingStart); int endMonth = DTStart.Month + 1; if (endMonth == 13) { int endYear = DTStart.Year + 1; DTEnd = new DateTime(endYear, 1, billingEnd); } else { DTEnd = new DateTime(DateTime.Now.Year, endMonth, billingEnd); } } else { DTEnd = new DateTime(DateTime.Now.Year, DateTime.Now.Month, billingEnd); int startMonth = DTEnd.Month - 1; if (startMonth == 0) { int startYear = DTEnd.Year - 1; DTStart = new DateTime(startYear, 12, billingStart); } else { DTStart = new DateTime(DateTime.Now.Year, startMonth, billingStart); } } string start = DTStart.ToString("yyyy-MM-dd"); string end = DTEnd.ToString("yyyy-MM-dd"); if (eventID.CompareTo("000002") == 0 || eventID.CompareTo("000003") == 0) { string sql = "select sum(TransactionTotal) " + "from AllowedConnections natural join ChildcareTransaction " + "where Family_ID = @familyID and Event_ID IN ('000002', '000003') and TransactionDate between '" + start + "' and '" + end + "'"; SQLiteCommand command = new SQLiteCommand(sql, conn); command.Parameters.Add(new SQLiteParameter("@familyID", familyID)); object recordFound = null; try{ conn.Open(); recordFound = command.ExecuteScalar(); conn.Close(); } catch (Exception) { conn.Close(); MessageBox.Show("Database connection error: Unable to check if charge exceeds monthly maximum for normal care."); } double sum; if (recordFound == DBNull.Value || recordFound == null) { return(0); } else { sum = Convert.ToDouble(recordFound); } double total = sum + eventFee; double capdiff = total - cap; if (capdiff > 0 && capdiff < eventFee) { return(capdiff); } else if (capdiff >= eventFee) { return(eventFee); } } return(0.0); }//end billingCapReached