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 UpdateFuLiForm : Form
    {
        public UpdateFuLiForm()
        {
            InitializeComponent();
        }
        T_FuLi fuli1 = new T_FuLi();
        T_StaffRecords staff1 = new T_StaffRecords();
        DataDataContext ddt = new DataDataContext();
        
        public UpdateFuLiForm(T_FuLi fuli, T_StaffRecords staff)
        {
            InitializeComponent();
            this.fuli1 = fuli;
            this.staff1 = staff;
          
           
            
        }
        
        private void UpdateFuLiForm_Load(object sender, EventArgs e)
        {
          
            txt_cause.Text = fuli1.FL_Cause;
            txt_money.Text = fuli1.FL_Money.ToString();
            combo_name.Text=staff1.Staff_Name;
            dtpicker_time.Value = (DateTime)fuli1.FL_Time;
            combo_name.Enabled = false;
            //绑定数据源
            var result = ddt.T_FuLi.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;
            
        }
       
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            
            //重新修改数据
           
                if (DialogResult.OK == MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK))
                {
                     try
                 {
               
                   fuli1.FL_Cause=txt_cause.Text;
                   fuli1.FL_Money = Convert.ToDecimal(txt_money.Text);
                   fuli1.FL_Time = dtpicker_time.Value;
                 }
                     catch
                     {
                         MessageBox.Show("字符串转化不正确！");
                     }
                }
                 
            
            
            
            ////ddtc.SubmitChanges();//修改数据
            //////绑定数据源
            ////var result = ddtc.T_FuLi.Join(ddtc.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;
            
           
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //清空文本框中数据
            txt_money.Clear();
            txt_cause.Clear();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            //退出
            this.Close();
        }
    }
}
