Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. @{
  2. ViewBag.Title = "Home Page";
  3.  
  4. var times = new List<string>()
  5. {
  6. "07:30",
  7. "08:00",
  8. "08:30",
  9. "09:00",
  10. "09:30",
  11. "10:00",
  12. "10:30",
  13. "11:00",
  14. "11:30",
  15. "12:00",
  16. "12:30"
  17.  
  18. };
  19. }
  20.  
  21. <script type="text/javascript">
  22. $( "#button" ).click(function() {
  23. $( "#item" ).toggle();
  24. });
  25. </script>
  26.  
  27. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css …" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
  28.  
  29. <h2>KalendarTool</h2>
  30. <table class="table table-bordered table-striped" id="reservationCalendar" align="center" frame="border" style="width:100%">
  31. <tr>
  32. @{
  33.  
  34. int currentMonth = DateTime.Now.Month;
  35. <td style="width:14%"></td>
  36.  
  37. for (int month = 0; month < 12; month++)
  38. {
  39. int currentYear = DateTime.Now.Year;
  40. DateTime firstDay = new DateTime(DateTime.Now.Year, currentMonth, 1);
  41. int daysInCurrentMonth = DateTime.DaysInMonth(firstDay.Year, firstDay.Month);
  42. DateTime lastDay = new DateTime(currentYear, currentMonth, daysInCurrentMonth);
  43. // Sunday casted to int gives 0 but that will not work for us, we need 7 to be able to calculate number of empty cells correctly
  44. int dayOfWeekFirst = ((int)firstDay.DayOfWeek > 0) ? (int)firstDay.DayOfWeek : 7;
  45. int dayOfWeekLast = ((int)lastDay.DayOfWeek > 0) ? (int)lastDay.DayOfWeek : 7;
  46.  
  47. for (int i = 1; i <= daysInCurrentMonth; i++)
  48. {
  49. DateTime renderedDay = new DateTime(firstDay.Year, firstDay.Month, i);
  50. String DayDate = renderedDay.ToString("dd.MM.yyyy");
  51.  
  52. if (renderedDay < DateTime.Now )
  53. {
  54. <td class="alert alert-danger" style="width: 14%">
  55. @renderedDay.DayOfWeek, @DayDate <a id="button" href="#">&#9660;</a>
  56. <table id="item" style="background: white; width: 100%; padding: 0px; margin: 0px;">
  57. @foreach (string timeOfDay in times)
  58. {
  59. <tr>
  60. <td>
  61. <span>@timeOfDay<input type="button" value="BOOK" style="margin-left: 15px"><input/></span>
  62. </td>
  63. </tr>
  64. }
  65. </table>
  66. </td>
  67. }
  68. else
  69. {
  70. <td class="alert alert-success" style="width:14%">
  71. @renderedDay.DayOfWeek, @DayDate
  72. <table id="item" style="background: white; width: 100%; padding: 0px; margin: 0px;">
  73. @foreach (string timeOfDay in times)
  74. {
  75. <tr>
  76. <td>
  77. <span>@timeOfDay<input type="button" value="BOOK" style="margin-left: 15px"><input /></span>
  78. </td>
  79. </tr>
  80. }
  81. </table>
  82. </td>
  83.  
  84. }
  85.  
  86. if (renderedDay.DayOfWeek == DayOfWeek.Sunday)
  87. {
  88. @:</tr>
  89. @:</table>
  90. @:<table class="table table-bordered table-striped" id="reservationCalendar" align="center" frame="border" style="width:100%">
  91. @:<tr>
  92. }
  93. }
  94. currentMonth = currentMonth + 1;
  95. }
  96. }
  97. </tr>
  98. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement