123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using DevExpress.XtraEditors;
- using ExtensionsDev;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.Entity;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Documents;
- using System.Windows.Forms;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App.EditForms
- {
- public partial class TaskHistoryTimeEditor : DevExpress.XtraEditors.XtraForm
- {
- Dictionary<int, (DateTime, DateTime)> cache = new Dictionary<int, (DateTime, DateTime)>();
- public DateTime start;
- public DateTime end;
- TaskInfo tsk;
- public TaskHistoryTimeEditor()
- {
- InitializeComponent();
- this.layoutControl1.UseDefault();
- this.txtStartTime.UseDefault().UseDoubleClickToSelectAll();
- this.txtEndTime.UseDefault().UseDoubleClickToSelectAll();
- this.StartPosition = FormStartPosition.CenterParent;
- }
- public TaskHistoryTimeEditor(TaskInfo tsk)
- : this()
- {
- this.tsk = tsk;
- }
- private void SatEditor_Load(object sender, EventArgs e)
- {
- if (cache.ContainsKey(tsk.ID))
- {
- txtStartTime.DateTime = cache[tsk.ID].Item1;
- txtEndTime.DateTime = cache[tsk.ID].Item2;
- }
- else
- {
- txtStartTime.DateTime = DateTime.Now;
- txtEndTime.DateTime = DateTime.Today.AddDays(7);
- }
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = DialogResult.Cancel;
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- start = txtStartTime.DateTime;
- end = txtEndTime.DateTime;
- if (cache.Count >= 50)
- cache.Remove(cache.First().Key);
- cache.Add(tsk.ID, (start, end));
- this.DialogResult = DialogResult.OK;
- }
- }
- }
|