| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 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.LgResMgt
- {
- public partial class SetTime : Form
- {
- public SetTime(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 SetTime_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;
- }
- }
- }
- }
|