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 Staff_SelectKP : Form
    {
        public Staff_SelectKP()
        {
            InitializeComponent();
        }
        DataDataContext ddc = new DataDataContext();//实例一个LINQ类的对象
        private void Staff_SelectKP_Load(object sender, EventArgs e)
        {
            KP_SelectDgv.DataSource = ddc.V_StaffKP;//填充datagrateview
        }
        //查询
        #region 按类别查询
        private void SureBt_Click(object sender, EventArgs e)
        {
            try
            {
                if (KP_selectTB.Text != "")
                {
                    if (KP_selectNameRB.Checked)
                    {
                        KP_SelectDgv.DataSource = ddc.V_StaffKP.Where(se => se.员工姓名 == KP_selectTB.Text);
                        if (ddc.V_StaffKP.Where(se => se.员工姓名 == KP_selectTB.Text).Count() == 0)
                        {
                            MessageBox.Show("没有检索到相关记录！");
                        }                    
                    }
                    else
                    {
                        KP_SelectDgv.DataSource = ddc.V_StaffKP.Where(se => se.部门 == KP_selectTB.Text);
                        if (ddc.V_StaffKP.Where(se => se.部门 == KP_selectTB.Text).Count() == 0)
                        {
                            MessageBox.Show("没有检索到相关记录！");
                         }
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        } 
        #endregion
    }
}
