using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HRManagerSystem
{
    public partial class FuLiSearchForm : Form
    {
        public FuLiSearchForm()
        {
            InitializeComponent();
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
          
        }
        DataDataContext ddt = new DataDataContext();
        private void FuLiSearchForm_Load(object sender, EventArgs e)
        {
            //加载时绑定数据源
            combo_name.DataSource = ddt.T_StaffRecords;
            combo_name.DisplayMember = "Staff_name";
            combo_name.ValueMember = "Staff_id";
        }

        private void 根据员工查找ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = ddt.T_FuLi.Where(id => id.Staff_ID == (int?)combo_name.SelectedValue).Join(ddt.T_StaffRecords, id => id.Staff_ID, staid => staid.Staff_ID, (id1, staid1) => new { id1.FL_ID, id1.FL_Cause, id1.FL_Time, id1.FL_Money, staid1.Staff_Name });
            dataGridView1.DataSource = result;
            if (result.Count() == 0)
            {
                MessageBox.Show("你查找的记录不存在！");
            }
        }

        private void 根据日期查找ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var result = ddt.T_FuLi.Where(time => time.FL_Time ==(DateTime?) dtpicker_time.Value).Join(ddt.T_StaffRecords, id => id.Staff_ID, staid => staid.Staff_ID, (id1, staid1) => new { id1.FL_ID, id1.FL_Cause, id1.FL_Time, id1.FL_Money, staid1.Staff_Name });
            dataGridView1.DataSource = result;
            if (result.Count()==0)
            {
                MessageBox.Show("你查找的记录不存在！");
            }
        }
        /// <summary>
        /// 退出操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        
    }
}
