public static Com.DataPack.DataRsp <string> save(string Name, string stat, string AutoId) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { SchSystem.BLL.SysPer SysPer_bll = new SchSystem.BLL.SysPer(); SchSystem.Model.SysPer SysPer_model = new SchSystem.Model.SysPer(); SysPer_model.PerName = Com.Public.SqlEncStr(Name).ToString(); SysPer_model.Stat = Convert.ToInt32(Com.Public.SqlEncStr(stat)); if (AutoId != "") { SysPer_model.AutoId = int.Parse(AutoId); if (SysPer_bll.Update(SysPer_model)) { rsp.code = "success"; rsp.msg = "修改成功"; } } else { DataTable dt = SysPer_bll.GetList(" top 1 PerCode", " 1=1 order by convert(int,PerCode) desc").Tables[0]; if (dt != null && dt.Rows.Count > 0) { string Code = dt.Rows[0]["PerCode"].ToString(); SysPer_model.PerCode = (int.Parse(Code) + 1).ToString("0"); } else { SysPer_model.PerCode = "1"; } if (SysPer_bll.Add(SysPer_model) != 0) { rsp.code = "success"; rsp.msg = "添加成功"; } } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }
public static Com.DataPack.DataRsp <string> save(string Name, string GradeNames, string Year, string Code, string stat, string AutoId) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "页面已经过期,请重新登录"; } else { try { SchSystem.BLL.SysPer SysPer_bll = new SchSystem.BLL.SysPer(); SchSystem.Model.SysPer SysPer_model = new SchSystem.Model.SysPer(); SysPer_model.PerName = Com.Public.SqlEncStr(Name).ToString(); SysPer_model.Stat = Convert.ToInt32(Com.Public.SqlEncStr(stat)); SysPer_model.PerYear = int.Parse(Year); SchSystem.BLL.SysGrade bll = new SchSystem.BLL.SysGrade(); SchSystem.Model.SysGrade model = new SchSystem.Model.SysGrade(); if (AutoId != "") { SysPer_model.AutoId = int.Parse(AutoId); if (SysPer_bll.Update(SysPer_model)) { //删除对应年级,再重新建 bll.DeleteList(Com.Public.SqlEncStr(Code)); //修改年级 string[] grades = GradeNames.Split('|'); if (grades.Length > 0) { for (int i = 0; i < grades.Length; i++) { model.GradeName = Com.Public.SqlEncStr(grades[i]).ToString(); model.GradeType = int.Parse(Code); model.GradeCode = Code + (i + 1).ToString("000"); bll.Add(model); } } rsp.code = "success"; rsp.msg = "修改成功"; } } else { DataTable dt = SysPer_bll.GetList(" top 1 PerCode", " 1=1 order by convert(int,PerCode) desc").Tables[0]; if (dt != null && dt.Rows.Count > 0) { string iCode = dt.Rows[0]["PerCode"].ToString(); SysPer_model.PerCode = (int.Parse(iCode) + 1).ToString("0"); } else { SysPer_model.PerCode = "1"; } int perid = SysPer_bll.Add(SysPer_model); if (perid > 0) { //添加年级 string[] grades = GradeNames.Split('|'); if (grades.Length > 0) { for (int i = 0; i < grades.Length; i++) { model.GradeName = Com.Public.SqlEncStr(grades[i]).ToString(); model.GradeType = int.Parse(SysPer_model.PerCode); model.GradeCode = SysPer_model.PerCode + (i + 1).ToString("000"); bll.Add(model); } } rsp.code = "success"; rsp.msg = "添加成功"; } } } catch (Exception ex) { rsp.code = "error"; rsp.msg = ex.Message; } } return(rsp); }