WinHistory.xaml.cs 2.43 KB
using System.Windows;
using System.Windows.Input;

namespace RCS.WinClient.Views.Pages
{
    /// <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;
            }

        }

        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}