public ActionResult JSDeleteFund(SubmitHandler handler)//删除响应
        {
            var    s = X.GetCmp <Store>("FundStore");
            string id;

            Dictionary <string, string>[] values = JSON.Deserialize <Dictionary <string, string>[]>(handler.Json.ToString());

            if (values.Length > 0)//js代码已经处理过,此处判断无用,可删
            {
                foreach (Dictionary <string, string> row in values)
                {
                    id = row["ID"];
                    T_HR_Fund de = entities.T_HR_Fund.Find(id);
                    if (de != null)
                    {
                        //entities.T_HR_Fund.Remove(de);
                        de.Valid = false;
                        T_HR_Staff st = entities.T_HR_Staff.Find(de.StaffID);
                        st.FundValid = false;
                        try
                        {
                            entities.SaveChanges();
                            s.Remove(id);
                        }
                        catch (Exception e)
                        {
                            X.Msg.Alert("警告", "数据删除失败!<br /> note:" + e.Message).Show();
                        }
                    }
                }
            }
            else
            {
                X.Msg.Alert("提示", "未选择任何列!").Show();
            }

            return(this.Direct());
        }
        public ActionResult AddOrEditFund(V_HR_Fund re)
        {
            DirectResult r        = new DirectResult();
            T_HR_Fund    reupdate = entities.T_HR_Fund.Find(re.ID);

            if (reupdate == null)//为空为添加
            {
                var ft = (from o in entities.V_HR_Fund
                          where o.StaffID == re.StaffID && o.Valid == true
                          select o).ToList();
                if (!ft.Any())
                {
                    T_HR_Fund readd = new T_HR_Fund();
                    readd.ID        = Guid.NewGuid().ToString();
                    readd.StaffID   = re.StaffID;
                    readd.StartDate = re.StartDate;
                    if (re.EndDate != null)
                    {
                        readd.EndDate = re.EndDate;
                        readd.Months  = GetMonths(Convert.ToDateTime(re.StartDate), Convert.ToDateTime(re.EndDate));
                    }
                    //readd.Months = re.Months;
                    readd.Valid       = true;
                    readd.Remark      = re.Remark;
                    readd.CreaterName = new LoginUser().EmployeeId;
                    readd.CreateTime  = DateTime.Now;

                    T_HR_Staff s = entities.T_HR_Staff.Find(re.StaffID);
                    s.FundValid = true;

                    entities.T_HR_Fund.Add(readd);
                    try
                    {
                        entities.SaveChanges();
                        r.Success = true;
                        X.Msg.Alert("提示", "保存成功!", new JFunction {
                            Fn = "closewindow"
                        }).Show();
                    }
                    catch (Exception e)
                    {
                        X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction {
                            Fn = "closewindow"
                        }).Show();
                        r.Success = false;
                    }
                }
                else
                {
                    X.Msg.Alert("警告", "该员工基金记录已存在,不可重复添加!").Show();
                    return(this.Direct());
                }
            }
            else//否则为修改
            {
                reupdate.StaffID   = re.StaffID;
                reupdate.StartDate = re.StartDate;
                if (re.EndDate != null)
                {
                    reupdate.EndDate = re.EndDate;
                    reupdate.Months  = GetMonths(Convert.ToDateTime(re.StartDate), Convert.ToDateTime(re.EndDate));
                }
                //reupdate.Months = re.Months;
                reupdate.Remark     = re.Remark;
                reupdate.Valid      = true;
                reupdate.EditorName = new LoginUser().EmployeeId;
                reupdate.EditeTime  = DateTime.Now;

                try
                {
                    entities.SaveChanges();
                    r.Success = true;
                    X.Msg.Alert("提示", "保存成功!", new JFunction {
                        Fn = "closewindow"
                    }).Show();
                }
                catch (Exception e)
                {
                    X.Msg.Alert("警告", "数据保存失败!<br /> note:" + e.Message, new JFunction {
                        Fn = "closewindow"
                    }).Show();
                    r.Success = false;
                }
            }
            return(r);
        }