public ActionResult JSDeleteJob(string selectedData)//删除响应 { string id; Dictionary <string, string>[] values = JSON.Deserialize <Dictionary <string, string>[]>(selectedData); if (values.Length > 0)//js代码已经处理过,此处判断无用,可删 { foreach (Dictionary <string, string> row in values) { id = row["JobID"]; T_HR_Job de = entities.T_HR_Job.Find(id); if (de != null) { entities.T_HR_Job.Remove(de); try { entities.SaveChanges(); } catch (Exception e) { X.Msg.Alert("警告", "数据删除失败!<br /> note:" + e.Message).Show(); } } } } else { X.Msg.Alert("提示", "未选择任何列!").Show(); } return(this.Direct()); }
public ActionResult AddOrEditJob(V_HR_JobWithDutyName job)//保存相应 { DirectResult r = new DirectResult(); T_HR_Job jobupdate = entities.T_HR_Job.Find(job.JobID); if (jobupdate == null)//为空为添加 { T_HR_Job jobadd = new T_HR_Job(); jobadd.JobID = job.JobID; jobadd.JobName = job.JobName; jobadd.DutyID = job.DutyID; jobadd.Remark = job.Remark; jobadd.CreaterName = "admin";//后期改为用户名 jobadd.CreateTime = DateTime.Now; entities.T_HR_Job.Add(jobadd); 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//否则为修改 { jobupdate.JobName = job.JobName; jobupdate.DutyID = job.DutyID; jobupdate.Remark = job.Remark; jobupdate.EditorName = "admin";//后期改为用户名 jobupdate.EditorTime = 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); }