Frm_TaskInfo.xaml.cs 3.18 KB
using HHWCS.Bll;
using HHWCS.Model;
using MySql.Data.MySqlClient;
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 HHWCSHost.View
{
    /// <summary>
    /// Frm_TaskInfo.xaml 的交互逻辑
    /// </summary>
    public partial class Frm_TaskInfo : Window
    {
        public Frm_TaskInfo()
        {
            InitializeComponent();
            InitControl();
        }

        private void InitControl()
        {
            endTime.SelectedDate = DateTime.Now.AddDays(1);
            beginTime.SelectedDate = DateTime.Now.AddDays(-7);
            cbx_TaskStatus.ItemsSource = AppCommon.GetTaskStatus();
            cbx_TaskStatus.DisplayMemberPath = "Value";
            cbx_TaskStatus.SelectedValuePath = "Key";
        }

        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;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Frm_TaskAdd frm_TaskAdd = new Frm_TaskAdd();
            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)
            {
                var a = AppCommon.Bll.DeleteTask(item.Id);
                AppCommon.Bll.UpdateLocationStatus(item.DestinationLocation, item.WarehouseId, "empty", AppCommon.ConnectionString);
                if (!a.Success)
                {
                    MessageBox.Show("删除出现问题,操作中止:" + a.Msg);
                    return;
                }
            }
            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("未选中数据");
            }
            foreach (TaskEntity item in dgv_1.SelectedItems)
            {
                var a = AppCommon.Bll.SendTaskToWCS(item.Id);
                if (!a.Success)
                {
                    MessageBox.Show("下发出现问题,操作中止:" + a.Msg);
                    return;
                }
            }
            MessageBox.Show("下发成功");
        }
    }
}