using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Core.LgMes.Client.LgJobMgt { public partial class frmSetTime : Form { public frmSetTime(object obj) { InitializeComponent(); try { if (obj.ToString().Substring(0, 1) == "0") _currDateTime = DateTime.Now; else _currDateTime = Convert.ToDateTime(obj); } catch { _currDateTime = DateTime.Now; } } #region " Valiable " DateTime _currDateTime = new DateTime(2000, 1, 1, 0, 0, 0, 0); public DateTime _returnTime = new DateTime(2000, 1, 1, 0, 0, 0, 0); private DateTime _tempDt = new DateTime(2000, 1, 1, 0, 0, 0, 0); private DateTime _tempClickTime = new DateTime(2000, 1, 1, 0, 0, 0, 0); private TimeSpan _timeSpan = new TimeSpan(5); #endregion private void frmSetTime_Load(object sender, EventArgs e) { this.monthCalendar1.SetDate(_currDateTime); this.ultraDateTimeEditor1.Value = _currDateTime; } private void button1_Click(object sender, EventArgs e) { try { this.ultraDateTimeEditor1.Update(); _returnTime = (DateTime)this.ultraDateTimeEditor1.Value; this.Close(); } catch { MessageBox.Show("日期格式输入错误,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e) { int hour = ((DateTime)this.ultraDateTimeEditor1.Value).Hour; int minute = ((DateTime)this.ultraDateTimeEditor1.Value).Minute; _currDateTime = e.Start.AddHours(hour); _currDateTime = _currDateTime.AddMinutes(minute); if (_currDateTime != _tempDt) { this.ultraDateTimeEditor1.Value = _currDateTime; _tempDt = _currDateTime; } else { TimeSpan span = DateTime.Now - _tempClickTime; if (span.Milliseconds < 200) { _returnTime = _currDateTime; this.Close(); } } _tempClickTime = DateTime.Now; } private void ultraDateTimeEditor1_ValueChanged(object sender, EventArgs e) { try { this.ultraDateTimeEditor1.Update(); DateTime dt = (DateTime)this.ultraDateTimeEditor1.Value; this.monthCalendar1.SetDate(dt); } catch { } } private void ultraDateTimeEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { if (e.Button.Key == "now") { this.ultraDateTimeEditor1.Value = System.DateTime.Now; } } } }