tangxu
2024-02-28 f9acbc64359c08113ee6781adfe7cc683d0b5186
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
 
using DevExpress.Utils.Svg;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.CalcErQu
{
    public partial class CalcPrjHistoryContainter : DocumentPage
    {
        public CalcPrjHistoryContainter()
        {
            InitializeComponent();
 
            this.PageTitle.Caption = "历史方案";
            this.SurfaceGuid = new SurfaceGuid()
            {
                Modular = eModular.PrjHistory,
                Function = this.PageTitle.Caption
            };
        }
 
        private void CalcPrjHistoryContainter_Load(object sender, EventArgs e)
        {
            spinEditYear.Text = DateTime.Today.Year.ToString();
            comboBoxMonth.Text = DateTime.Today.Month.ToString();
            RefreshList();
            listBoxDay.SelectedIndex = DateTime.Today.Day - 1;
        }
        public override void InitialDataSource()
        {
            base.InitialDataSource();
 
 
        }
        private void spinEditYear_EditValueChanged(object sender, EventArgs e)
        {
            RefreshList();
        }
        private void RefreshList()
        {
            int year = Convert.ToInt32(spinEditYear.Text);
            int month = Convert.ToInt32(comboBoxMonth.Text);
 
            int day_count = DateTime.DaysInMonth(year, month);
            listBoxDay.Items.Clear();
            for(int i=1;i<=day_count; i++)
            {
                listBoxDay.Items.Add(i.ToString());
            }
 
            dict = BLL.AnaPrj.GetExistStatus( year, month );
        }
        Dictionary<int, bool> dict = null;
 
 
        private void comboBoxMonth_SelectedIndexChanged(object sender, EventArgs e)
        {
            RefreshList();
        }
 
        private void listBoxDay_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxDay.SelectedIndex < 0)
                return;
            if (listBoxDay.Items.Count == 0)
                return;
 
            int year = Convert.ToInt32(spinEditYear.Text);
            int month = Convert.ToInt32(comboBoxMonth.Text);
            int day = listBoxDay.SelectedIndex + 1;
            var yester1_day_anaPrj = IStation.BLL.AnaPrj.GetPrj(new DateTime(year,month,day));
            if (yester1_day_anaPrj != null)
                anaResultInfoManuCtrl1.SetBindingData(yester1_day_anaPrj);
            else
                anaResultInfoManuCtrl1.ClearContent();
        }
 
        private void listBoxDay_CustomItemDisplayText(object sender, DevExpress.XtraEditors.CustomItemDisplayTextEventArgs e)
        {
            if (dict == null)
                return;
            if (e.Item == null)
                return;
            if (!dict[e.Index + 1])
            {
                e.DisplayText = string.Format("{0} (无)",e.Value);
                   
            }
        }
 
        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("请问是否 删除", "询问",
System.Windows.Forms.MessageBoxButtons.YesNo,
System.Windows.Forms.MessageBoxIcon.Warning);
            if (result != DialogResult.Yes)
            { 
                return;
            }
 
            var day = listBoxDay.SelectedIndex + 1;
            dict[day] = false;
            int year = Convert.ToInt32(spinEditYear.Text);
            int month = Convert.ToInt32(comboBoxMonth.Text);
           // HistoryAnaPrjFileHelper.Delete(new DateTime(year, month, day));
 
        }
 
 
    }
}