WinTaskInfo.xaml.cs
5.73 KB
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
using HHECS.Bll;
using HHECS.Controls;
using HHECS.Model;
using HHECS.ViewModel;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace HHECS.View.TaskInfo
{
/// <summary>
/// Frm_TaskInfo.xaml 的交互逻辑
/// </summary>
public partial class WinTaskInfo : Window
{
public PageInfoVM PageInfo { get; set; } = new PageInfoVM();
public WinTaskInfo()
{
InitializeComponent();
InitControl();
}
private void InitControl()
{
endTime.SelectedDate = DateTime.Now.AddDays(1);
beginTime.SelectedDate = DateTime.Now.AddDays(-7);
var temp = AppSession.Bll.GetDictWithDetails("TaskStatus");
if (temp.Success)
{
var dictDetails = temp.Data.DictDetails.ToDictionary(t => t.Value, i => i.Name);
dictDetails.Add("", "全部");
cbx_TaskStatus.ItemsSource = dictDetails;
cbx_TaskStatus.DisplayMemberPath = "Value";
cbx_TaskStatus.SelectedValuePath = "Key";
}
this.DPMain.DataContext = PageInfo;
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
this.Hide();
}
private void btn_Query_Click(object sender, RoutedEventArgs e)
{
//dgv_1.ItemsSource = AppCommon.Bll.GetTasks((String)cbx_TaskStatus.SelectedValue, txt_TaskNo.Text, txt_Pallet.Text, beginTime.SelectedDate, endTime.SelectedDate).Data;
Query();
}
private void Query()
{
string sql = "where 1=1 and zoneCode = 'LK' ";
if (!String.IsNullOrWhiteSpace(txt_Pallet.Text))
{
sql += $" and containerCode like '%{txt_Pallet.Text}%'";
}
if (!String.IsNullOrWhiteSpace(txt_TaskNo.Text))
{
sql += $" and id ={txt_TaskNo.Text}";
}
var status = cbx_TaskStatus.SelectedValue?.ToString();
if (!String.IsNullOrWhiteSpace(status))
{
sql += $" and firstStatus = {status} and lastStatus = {status} ";
}
if (beginTime.SelectedDate != null)
{
sql += $" and created >= '{beginTime.ToString()}'";
}
if (endTime.SelectedDate != null)
{
sql += $" and created <= '{endTime.ToString()}'";
}
BllResult<int> result = AppSession.Bll.GetCommonModelCount<TaskEntity>(sql);
if (result.Success)
{
PageInfo.TotalCount = result.Data;
dgv_1.ItemsSource = AppSession.Bll.GetCommonModeByPageCondition<TaskEntity>(PageInfo.PageIndex, PageInfo.PageSize, sql, "id desc").Data;
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
WinTaskAdd frm_TaskAdd = new WinTaskAdd();
frm_TaskAdd.ShowDialog();
btn_Query_Click(null, null);
}
private void btn_Delete_Click(object sender, RoutedEventArgs e)
{
//MessageBox.Show("删除功能在当前版本下不可用");
//return;
if (dgv_1.SelectedItems == null || dgv_1.SelectedItems.Count == 0)
{
MessageBox.Show("未选中数据");
}
foreach (TaskEntity item in dgv_1.SelectedItems)
{
BllResult a = AppSession.Bll.DeleteTask(item.Id);
if (!a.Success)
{
MessageBox.Show("删除出现问题,操作中止:" + a.Msg);
return;
}
AppSession.Bll.UpdateLocationStatus(item.DestinationLocation, item.WarehouseId, "empty");
}
MessageBox.Show("删除成功");
btn_Query_Click(null, null);
}
private void btn_SendToWCS_Click(object sender, RoutedEventArgs e)
{
if (dgv_1.SelectedItems == null || dgv_1.SelectedItems.Count == 0)
{
MessageBox.Show("未选中数据");
return;
}
foreach (TaskEntity item in dgv_1.SelectedItems)
{
BllResult a = AppSession.Bll.SendTaskToWCS(item.Id);
if (!a.Success)
{
MessageBox.Show("下发出现问题,操作中止:" + a.Msg);
return;
}
}
MessageBox.Show("下发成功");
}
private void btn_modifyStatus_Click(object sender, RoutedEventArgs e)
{
if (dgv_1.SelectedItems == null || dgv_1.SelectedItems.Count != 1)
{
MessageBox.Show("只允许选中一个数据");
}
else
{
List<TaskEntity> temp = new List<TaskEntity>();
foreach (var item in dgv_1.SelectedItems)
{
temp.Add((TaskEntity)item);
}
WinTaskInfoStatusChange frm = new WinTaskInfoStatusChange(temp.First().Id);
frm.ShowDialog();
btn_Query_Click(null, null);
}
}
private void page_PageChanged(object sender, PageChangedEventArgs e)
{
PageInfo.PageIndex = e.CurrentPageIndex;
Query();
}
}
}