frmSetTime.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Windows.Forms;
  3. namespace Core.StlMes.Client.LgCommon
  4. {
  5. public partial class frmSetTime : Form
  6. {
  7. public frmSetTime(object value)
  8. {
  9. InitializeComponent();
  10. DateTime dt = DateTime.Now;
  11. try
  12. {
  13. if (value != null) dt = (DateTime)value;
  14. else dt = DateTime.Now;
  15. }
  16. catch
  17. {
  18. dt = DateTime.Now;
  19. }
  20. this.dateTimePicker1.Value = dt;
  21. this.monthCalendar1.SetDate(dt.Date);
  22. }
  23. public DateTime SelectDate
  24. {
  25. get
  26. {
  27. return this.dateTimePicker1.Value;
  28. }
  29. }
  30. private void BtnOK_Click(object sender, EventArgs e)
  31. {
  32. this.DialogResult = DialogResult.OK;
  33. this.Close();
  34. }
  35. private void BtnCancel_Click(object sender, EventArgs e)
  36. {
  37. this.Close();
  38. }
  39. private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
  40. {
  41. try
  42. {
  43. DateTime time = this.dateTimePicker1.Value;
  44. this.dateTimePicker1.Value = this.monthCalendar1.SelectionEnd.Date.AddHours(time.Hour).AddMinutes(time.Minute).AddSeconds(time.Second);
  45. }
  46. catch { }
  47. }
  48. private void btnNow_Click(object sender, EventArgs e)
  49. {
  50. dateTimePicker1.Value = DateTime.Now;
  51. }
  52. }
  53. }