WinHistory.xaml.cs
3.69 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
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 XingYe_ACS.UI
{
/// <summary>
/// WinHistory.xaml 的交互逻辑
/// </summary>
public partial class WinHistory : Window
{
public WinHistory()
{
InitializeComponent();
}
private void BtnQuery_Click(object sender, RoutedEventArgs e)
{
Grid_History.ItemsSource = null;
string CmSt =
"SELECT strTaskNo as '任务号'" +
", taskType as '任务类型'" +
",strTaskAgv as '小车号'" +
",StartCharge as '小车开始电量'" +
",strStartTime as '任务开始时间'" +
",EndCharge as '小车结束电量'" +
",strEndTime as '任务结束时间'" +
"FROM T_Charge_Record";
string DataFilter = "";
string CmString = CmSt;
if (tBoxAgvNo.Text != "")
{
DataFilter += string.Format(" and strTaskAgv='{0}'", tBoxAgvNo.Text);
}
if (cBoxTaskType.Text != "")
{
DataFilter += string.Format(" and taskType='{0}'", cBoxTaskType.Text);
}
if (CalendarStart.ToString() != "" && CalendarEnd.ToString() == "")
{
DataFilter += string.Format(" and strStartTime>='{0}'", CalendarStart.ToString());
}
else if (CalendarStart.ToString() == "" && CalendarEnd.ToString() != "")
{
DataFilter += string.Format(" and strStartTime<='{0}'", CalendarEnd.ToString());
}
else if (CalendarStart.ToString() != "" && CalendarEnd.ToString() != "")
{
DataFilter += string.Format(" and strStartTime>='{0}' and strEndTime<='{1}'",
CalendarStart.ToString(), CalendarEnd.ToString());
}
if (DataFilter.IndexOf(" and") == 0)
{
DataFilter = DataFilter.Remove(0, 4);
}
if (DataFilter != "")
{
DataFilter = " where " + DataFilter;
CmString += DataFilter;
}
DataSet ds = Common.DbHelperSQL.Query(CmString);
if (ds != null)
{
Grid_History.ItemsSource = ds.Tables[0].DefaultView;
//DataTable dataTable = ds.Tables[0];
//int rowNumber = dataTable.Rows.Count;
//int columnNumber = dataTable.Columns.Count;
////建立Excel对象
//Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
//excel.Application.Workbooks.Add(true);
//excel.Visible = true;//是否打开该Excel文件
////填充数据
//for (int c = 0; c < rowNumber; c++)
//{
// for (int j = 0; j < columnNumber; j++)
// {
// excel.Cells[c + 1, j + 1] = dataTable.Rows[c].ItemArray[j];
// }
//}
}
}
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
}
}