using MaterialTraceability.Entity.DTO;
using MaterialTraceabilityUI.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
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.Navigation;
using System.Windows.Shapes;

namespace MaterialTraceabilityUI
{
    /// <summary>
    /// secondPage.xaml 的交互逻辑
    /// </summary>
    public partial class secondPage : UserControl, INotifyPropertyChanged
    {
        private UpMaterialRecord upMaterialRecordControl = new UpMaterialRecord();

        private LogRecordControl logControl = new LogRecordControl();

        private ReadRecordControl readRecordControl = new ReadRecordControl();

        private MesRequestControl RequestControl = new MesRequestControl();

        private DownMaterialRecord downMaterialRecord = new DownMaterialRecord();

        private ShaftInfoControl shaftInfoControl = new ShaftInfoControl();

        private SplitSfc splitSfc = new SplitSfc();
        public secondPage()
        {
            InitializeComponent();
            DataContext = this;
            AppConfigDto appConfig = AppConfigDto.Instance;
            if (appConfig.processId != "TB")
            {
                splitButton.Visibility = Visibility.Visible;
            }
        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("生产报表");
        }

        /// <summary>
        /// 上料记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpMaterialRecord_Click(object sender, RoutedEventArgs e)
        {
            UserControl = upMaterialRecordControl;
        }

        /// <summary>
        /// 异常记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AlarmRecord_Click(object sender, RoutedEventArgs e)
        {
            UserControl = logControl;
        }

        public UserControl _content;
        public UserControl UserControl
        {
            get { return _content; }

            set
            {
                _content = value;
                OnPropertyChanged("UserControl");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            UserControl = shaftInfoControl;
        }

        private void ReadRecord_Click(object sender, RoutedEventArgs e)
        {
            UserControl = readRecordControl;
        }

        private void MesRecord_Click(object sender, RoutedEventArgs e)
        {
            UserControl = RequestControl;
        }

        private void DownMaterialRecord_Click(object sender, RoutedEventArgs e)
        {
            UserControl = downMaterialRecord;
        }


        private void ShaftInfo_Click(object sender, RoutedEventArgs e)
        {
            UserControl = shaftInfoControl;
        }

        private void Split_Click(object sender, RoutedEventArgs e)
        {
            if (!"1".Equals(ConfigHelper.GetConfig("roleId")) && !"2".Equals(ConfigHelper.GetConfig("roleId")))
            {
                System.Windows.MessageBox.Show("请登录系统管理账号进行操作");
            }
            else
            {
                UserControl = splitSfc;
            }
        }
    }
}