WebMonthCalendar.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using FastReport.Dialog;
  2. using System;
  3. using System.Globalization;
  4. using System.Text;
  5. using static FastReport.Web.Constants;
  6. namespace FastReport.Web
  7. {
  8. public partial class Dialog
  9. {
  10. private void MonthCalendarChange(MonthCalendarControl dp, string value)
  11. {
  12. dp.SelectionStart = DateTime.ParseExact(value, "d", CultureInfo.InvariantCulture);
  13. }
  14. private string GetMonthCalendarHtml(MonthCalendarControl control)
  15. {
  16. control.FillData();
  17. ControlFilterRefresh(control);
  18. string id = GetControlID(control);
  19. StringBuilder html = new StringBuilder();
  20. string selectedDate = control.SelectionStart.Month.ToString() + "/" + control.SelectionStart.Day.ToString() + "/" + control.SelectionStart.Year.ToString();
  21. string ev = GetEvent(ONCHANGE, control, DIALOG, $"document.getElementById('{id}').value");
  22. html.AppendFormat("<div class=\"{0}\" style=\"{1}\" onchange=\"{2}\" id=\"{3}\"></div>",
  23. "",
  24. GetMonthCalendarStyle(control),
  25. ev,
  26. id
  27. );
  28. html.Append("<script>$(function() {$( \"#").Append(id).AppendLine("\" ).datepicker();");
  29. html.Append("$( \"#").Append(id).Append("\" ).datepicker( \"option\", \"dateFormat\", \"").
  30. Append(DEFAULT_DATE_PICKER_FORMAT).AppendLine("\" );");
  31. html.Append("$( \"#").Append(id).AppendFormat("\" ).datepicker( \"setDate\", \"{0}\", \"", selectedDate).
  32. Append(DEFAULT_DATE_PICKER_FORMAT).AppendLine("\" );");
  33. html.Append("});</script>");
  34. //control.FilterData();
  35. return html.ToString();
  36. }
  37. private string GetMonthCalendarStyle(MonthCalendarControl control)
  38. {
  39. return GetStandardStyle(control);
  40. }
  41. }
  42. }