using HandyControl.Tools.Extension;
using Masuit.Tools.Logging;
using Microsoft.Extensions.Hosting;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Khd.Core.Wpf.Form
{
    /// <summary>
    /// CheShenChangDuGuanLi.xaml 的交互逻辑
    /// </summary>
    public partial class CheShenChangDuGuanLi : Window
    {
        private readonly IHost _host;
        public CheShenChangDuGuanLi(IHost host)
        {
            InitializeComponent();
            this._host = host;
        }
        /// <summary>
        /// 页面加载方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                LogManager.Info($"窗体加载事件报错 >>> {ex.Message}");
            }
        }
        /// <summary>
        /// 显示序号事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
        { e.Row.Header = e.Row.GetIndex() + 1; }

        private void DataGrid_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Enter)
                {
                    // Move focus away from the DataGrid to exit edit mode
                    Keyboard.ClearFocus();
                    dgData_LoadingRow(null, null);
                    Window_Loaded(null, null);
                }
            }
            catch (Exception)
            {
            }

        }

        private void cloce_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 保存按钮保存数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void inster_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!marterCode.Text.IsNullOrEmpty() && !marterName.Text.IsNullOrEmpty() && marterType.SelectedIndex != -1)
                {

                }
                else
                {
                    MessageBox.Show("请输入完整数据!!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"数据添加报错 >>> {ex.Message}", "操作失败提示!");
            }
        }
    }
}
