WinMoveTruss.xaml.cs 2.54 KB
using HHECS.BLL.Services;
using HHECS.Model.Entities;
using System;
using System.Windows;

namespace HHECS.WinCommon.Controls
{
    /// <summary>
    /// WinMoveTruss.xaml 的交互逻辑
    /// </summary>
    public partial class WinMoveTruss : Window
    {
        private readonly Equipment DeviceEntity;

        private readonly BaseWorkStationService baseWorkStationService = new BaseWorkStationService();

        public string stationId = string.Empty;

        public WinMoveTruss(Equipment equipment)
        {
            InitializeComponent();
            DeviceEntity = equipment;
            InitControl();
        }

        private void InitControl()
        {
            cbx_StationId.ItemsSource = baseWorkStationService.GetAll();
            cbx_StationId.DisplayMemberPath = "WorkStationName";
            cbx_StationId.SelectedValuePath = "Id";
        }

        private void Btn_Issue_Click(object sender, RoutedEventArgs e)
        {
            string code = DeviceEntity.Code;
            if (cbx_StationId.SelectedValue?.ToString() == null)
            {
                MessageBox.Show("请选择需要到达目的站台", "注意", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            else
            {
                stationId = cbx_StationId.SelectedValue.ToString();
                this.DialogResult = true;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //var temp = AppSession.BllService.GetDictWithDetailsAndTrussCode(DeviceEntity.Code);
            //var stations = AppSession.Dal.GetCommonModelByCondition<Station>($"where trussPutStationId <> 0 and  transportNormal = '{DeviceEntity.Code}'");
            //if (stations.Success)
            //{
            //    //stations.Data.Distinct(t => t.)
            //    //var dictDetails = stations.Data.ToDictionary(t => t.TrussPutStationId, i => i.Name);
            //    var dictDetails = stations.Data;
            //    cbx_StationId.ItemsSource = dictDetails;
            //    cbx_StationId.DisplayMemberPath = "Name";
            //    cbx_StationId.SelectedValuePath = "TrussPutStationId";
            //}
            //else
            //{
            //    MessageBox.Show($"错误{stations.Msg}");
            //    return;
            //}
        }

        private void Btn_Cancel_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}