public ActionResult JSDeleteEducationFund(SubmitHandler handler)//删除响应 { var s = X.GetCmp<Store>("EducationFundStore"); 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_EducationFund de = entities.T_HR_EducationFund.Find(id); if (de != null) { //entities.T_HR_EducationFund.Remove(de); de.Valid = 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 AddOrEditEducationFund(V_HR_EducationFundWithName educationFund)//AddEducationFund保存相应 { DirectResult r = new DirectResult(); T_HR_EducationFund educationFundupdate = entities.T_HR_EducationFund.Find(educationFund.ID); if (educationFundupdate == null)//为空为添加 { T_HR_EducationFund educationFundadd = new T_HR_EducationFund(); educationFundadd.ID = Tool.ProduceSed64(); educationFundadd.StaffID = educationFund.StaffID; educationFundadd.Style = educationFund.Style; educationFundadd.Money = educationFund.Money; educationFundadd.StartTime = educationFund.StartTime; educationFundadd.EndTime = educationFund.EndTime; educationFundadd.Valid = true; educationFundadd.Remark = educationFund.Remark; educationFundadd.CreaterName = new LoginUser().EmployeeId;//后期改为用户名 educationFundadd.CreateTime = DateTime.Now; entities.T_HR_EducationFund.Add(educationFundadd); 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//否则为修改 { educationFundupdate.StaffID = educationFund.StaffID; educationFundupdate.Style = educationFund.Style; educationFundupdate.Money = educationFund.Money; educationFundupdate.StartTime = educationFund.StartTime; educationFundupdate.EndTime = educationFund.EndTime; educationFundupdate.Valid = true; educationFundupdate.Remark = educationFund.Remark; educationFundupdate.EditorName = new LoginUser().EmployeeId;//后期改为用户名 educationFundupdate.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; }