schangxiang@126.com
2025-09-29 682eba0aaf922e69dfafe05fb6c1bbdbf3a0e04a
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
using FineUIPro;
using FineUIPro.iWareWms;
using iWareCommon.Common.Entity;
using iWareDataCore.TASK.EnumType;
using iWareDataCore.TASK.Service;
using iWareExcel.EXCEL.Service;
using iWareWms.Code.Excel.Service;
using System;
using System.Collections.Generic;
using iWareWms;
 
namespace iWareWms.View.Task
{
    public partial class MainTaskView : PageBase
    {
        protected override Grid GetGrid()
        {
            return MainTaskGrid;
        }
 
 
        protected override DropDownList GetPageSizeDropDownList()
        {
            return ddlPageSize;
        }
 
        protected override List<object> GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage)
        {
 
 
            var tasks = MainTaskViewService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "MaterialCode", tbMaterial.Text } },
                Filter = new Dictionary<string, object> { { "TaskType", ddlTasktype.SelectedValue }, { "Status", ddlStatus.SelectedValue } },
                Geqd = new Dictionary<string, object> { { "SendTime", dpSendTime.SelectedDate } },
                Ltd = new Dictionary<string, object> { { "DecompositionTime", ((DateTime)dpDecompositionTime.SelectedDate).AddDays(1) } },
                PageIndex = pageIndex,
                PageSize = pageSize
            }, out msg, out totalNum, out currentPage);
 
            var res = new List<object>();
 
            tasks.ForEach(x => res.Add(x));
 
            return res;
        }
 
 
        // <summary>
        /// 改变分解状态的显示信息
        /// </summary>
        /// <param name="workLabel"></param>
        /// <returns></returns>
        protected string GetStatus(object Status)
        {
 
            if (Status == null)
            {
                Status = 0;
            }
            return ((EMainTaskStatus)Status).ToString();
        }
 
        /// <summary>
        /// 改变TaskType显示信息
        /// </summary>
        /// <param name="workLabel"></param>
        /// <returns></returns>
        protected string GetTaskType(object taskType)
        {
            return ((EMainTaskType)taskType).ToString();
        }
 
        /// <summary>
        /// 改变优先级显示信息
        /// </summary>
        /// <param name="priority"></param>
        /// <returns></returns>
        protected string GetPriority(object priority)
        {
            return ((EMainTaskPriority)priority).ToString();
        }
 
        
 
        //批量修改优先级
        protected override void ChangePriority(List<int> ids, int enable, out string msg)
        {
            MainTaskService.GetInstance().ChangePriority(ids, enable, out msg);
            WriteLog("主任务优先级更改" + msg, "任务查看");
        }
 
        //批量撤销
        protected override void Delete(List<int> ids, out string msg)
        {
 
            MainTaskService.GetInstance().ChnageMainTaskStatus(ids, out msg);
            WriteLog("主任务优先级撤销" + msg, "任务查看");
 
           
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string name = GetIdentityName();
                if (name == "admin")
                {
                    btnClar.Hidden = false;
                }
                else
                {
                    btnClar.Hidden = true;
                }
                //判断设置优先级是否选择了至少一项纪录
                ResolveEnablePriorityButtonForGrid(MenuButton1, MainTaskGrid, 0);
                ResolveEnablePriorityButtonForGrid(MenuButton2, MainTaskGrid, 1);
                ResolveEnablePriorityButtonForGrid(MenuButton3, MainTaskGrid, 2);
 
                //判断删除复选框是否选择了至少一项纪录
                ResolveDeleteButtonForGrid(Button3, MainTaskGrid);
 
                var today = DateTime.Today;
                dpSendTime.SelectedDate = today.AddDays(-6);
                dpDecompositionTime.SelectedDate = today;
 
                btnCreateTast.OnClientClick = Window1.GetShowReference("~/View/TASK/MainTaskView/NewMainTask.aspx", "新建任务");
 
                Query(1);
            }
        }
 
        protected override Window GetWindow()
        {
            return Window2;
        }
 
        protected override void GetPath(object userName)
        {
            string msg;
            var tasks = MainTaskViewService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "MaterialCode", tbMaterial.Text } },
                Filter = new Dictionary<string, object> { { "TaskType", ddlTasktype.SelectedValue }, { "Status", ddlStatus.SelectedValue } },
                Geqd = new Dictionary<string, object> { { "SendTime", dpSendTime.SelectedDate } },
                Ltd = new Dictionary<string, object> { { "DecompositionTime", ((DateTime)dpDecompositionTime.SelectedDate).AddDays(1) } },
            }, out msg);
 
 
            var datas = new List<object>();
            tasks.ForEach(x => datas.Add(x));
            var workBooks = WorkBookService.GetInstance().QueryByParam(new QueryParam { Filter = new Dictionary<string, object> { { "Name", "主任务查看" } } }, out msg);
            var path = ExcelService.GetInstance().ToExcelByEPPlus(workBooks[0], new Dictionary<string, List<object>> { { "主任务查看", datas } }, out msg);
            Session["ExcelPath"] = path;
 
        }
 
        protected override FineUIPro.Timer GetTimer()
        {
            return timer1;
        }
 
        /// <summary>
        /// 清除删除任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnClar_Click(object sender, EventArgs e)
        {
            string msg = "";
            List<int> ids = GetSelectedDataKeyIDs(MainTaskGrid);
            MainTaskService.GetInstance().Delete(ids, out msg);
            if (string.IsNullOrEmpty(msg))
            {
                msg = "清除成功!";
 
            }
            WriteLog("主任务清除" + msg, "任务查看");
            Alert.Show(msg);
            Query(1);
        }
 
 
  
 
    }
}