/// <summary> /// 更新一条数据 /// </summary> public bool Update(SchSystem.Model.ServFunc model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ServFunc set "); strSql.Append("FuncName=@FuncName,"); strSql.Append("FuncCode=@FuncCode,"); strSql.Append("TypeCode=@TypeCode,"); strSql.Append("FuncRange=@FuncRange,"); strSql.Append("FuncSet=@FuncSet,"); strSql.Append("FuncNote=@FuncNote,"); strSql.Append("FuncSyss=@FuncSyss,"); strSql.Append("FuncDes=@FuncDes"); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@FuncName", SqlDbType.NVarChar, 50), new SqlParameter("@FuncCode", SqlDbType.VarChar, 10), new SqlParameter("@TypeCode", SqlDbType.VarChar, 10), new SqlParameter("@FuncRange", SqlDbType.NVarChar, 300), new SqlParameter("@FuncSet", SqlDbType.NVarChar, 300), new SqlParameter("@FuncNote", SqlDbType.NVarChar, 300), new SqlParameter("@FuncSyss", SqlDbType.VarChar, 100), new SqlParameter("@FuncDes", SqlDbType.NVarChar, 300), new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = model.FuncName; parameters[1].Value = model.FuncCode; parameters[2].Value = model.TypeCode; parameters[3].Value = model.FuncRange; parameters[4].Value = model.FuncSet; parameters[5].Value = model.FuncNote; parameters[6].Value = model.FuncSyss; parameters[7].Value = model.FuncDes; parameters[8].Value = model.AutoId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.ServFunc DataRowToModel(DataRow row) { SchSystem.Model.ServFunc model = new SchSystem.Model.ServFunc(); if (row != null) { if (row["AutoId"] != null && row["AutoId"].ToString() != "") { model.AutoId = int.Parse(row["AutoId"].ToString()); } if (row["FuncName"] != null) { model.FuncName = row["FuncName"].ToString(); } if (row["FuncCode"] != null) { model.FuncCode = row["FuncCode"].ToString(); } if (row["TypeCode"] != null) { model.TypeCode = row["TypeCode"].ToString(); } if (row["FuncRange"] != null) { model.FuncRange = row["FuncRange"].ToString(); } if (row["FuncSet"] != null) { model.FuncSet = row["FuncSet"].ToString(); } if (row["FuncNote"] != null) { model.FuncNote = row["FuncNote"].ToString(); } if (row["FuncSyss"] != null) { model.FuncSyss = row["FuncSyss"].ToString(); } if (row["FuncDes"] != null) { model.FuncDes = row["FuncDes"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SchSystem.Model.ServFunc model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ServFunc("); strSql.Append("FuncName,FuncCode,TypeCode,FuncRange,FuncSet,FuncNote,FuncSyss,FuncDes)"); strSql.Append(" values ("); strSql.Append("@FuncName,@FuncCode,@TypeCode,@FuncRange,@FuncSet,@FuncNote,@FuncSyss,@FuncDes)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@FuncName", SqlDbType.NVarChar, 50), new SqlParameter("@FuncCode", SqlDbType.VarChar, 10), new SqlParameter("@TypeCode", SqlDbType.VarChar, 10), new SqlParameter("@FuncRange", SqlDbType.NVarChar, 300), new SqlParameter("@FuncSet", SqlDbType.NVarChar, 300), new SqlParameter("@FuncNote", SqlDbType.NVarChar, 300), new SqlParameter("@FuncSyss", SqlDbType.VarChar, 100), new SqlParameter("@FuncDes", SqlDbType.NVarChar, 300) }; parameters[0].Value = model.FuncName; parameters[1].Value = model.FuncCode; parameters[2].Value = model.TypeCode; parameters[3].Value = model.FuncRange; parameters[4].Value = model.FuncSet; parameters[5].Value = model.FuncNote; parameters[6].Value = model.FuncSyss; parameters[7].Value = model.FuncDes; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public SchSystem.Model.ServFunc GetModel(int AutoId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 AutoId,FuncName,FuncCode,TypeCode,FuncRange,FuncSet,FuncNote,FuncSyss,FuncDes from ServFunc "); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Int, 4) }; parameters[0].Value = AutoId; SchSystem.Model.ServFunc model = new SchSystem.Model.ServFunc(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { dotype = Request.Params["dotype"].ToString(); string AutoId = Request.Params["id"].ToString(); funcid = AutoId; schid = Com.Session.schid; SchSystem.BLL.ServFunc sfcBll = new SchSystem.BLL.ServFunc(); SchSystem.Model.ServFunc sfcModel = new SchSystem.Model.ServFunc(); string FuncSyss = ""; if (!string.IsNullOrEmpty(AutoId)) { sfcModel = sfcBll.GetServFuncModel(AutoId); FuncSyss = sfcModel.FuncSyss; servfuncModel = Newtonsoft.Json.JsonConvert.SerializeObject(sfcModel); } //业务类型 SchSystem.BLL.ServType stBll = new SchSystem.BLL.ServType(); DataTable stdt = stBll.GetList("TypeName,TypeCode", "").Tables[0]; businessType = Newtonsoft.Json.JsonConvert.SerializeObject(stdt); //业务平台 SchSystem.BLL.ServSys ssBll = new SchSystem.BLL.ServSys(); DataTable ssdt = ssBll.GetList("'0' pId,SysName name,SysCode id,SysUrl,'false' checked", "").Tables[0]; if (ssdt.Rows.Count > 0) { if (FuncSyss != "") { string[] FuncSyssArr = FuncSyss.Split(','); foreach (string s in FuncSyssArr) { for (int i = 0; i < ssdt.Rows.Count; i++) { if (ssdt.Rows[i]["id"].ToString() == s) { ssdt.Rows[i]["checked"] = "true"; } } } } } businessPlatfrom = Newtonsoft.Json.JsonConvert.SerializeObject(ssdt); //附加設置信息 SchSystem.BLL.ServSysNape ssnBll = new SchSystem.BLL.ServSysNape(); DataTable ssndt = ssnBll.GetList("Stat=1").Tables[0]; editServSysNape = Newtonsoft.Json.JsonConvert.SerializeObject(ssndt); //获取ServFuncExt表中相应FunId的数据记录 SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt(); DataTable dtServFuncExt = sfeBll.GetList("FuncId,NapeCode,NapeCodes,NapeC", "FuncId='" + AutoId + "'").Tables[0]; servfuncextjson = Newtonsoft.Json.JsonConvert.SerializeObject(dtServFuncExt); //附加設置信息之附加信息聯動內容默認下拉列表 SchSystem.BLL.SysPer spBll = new SchSystem.BLL.SysPer(); DataTable dtsp = spBll.GetList("'0' pId,PerName name,PerCode id,'false' checked", "Stat=1 order by convert(int,PerCode)").Tables[0]; if (dtsp.Rows.Count > 0) { for (int i = 0; i < dtsp.Rows.Count; i++) { if (dtServFuncExt.Rows.Count > 0) { if (dtServFuncExt.Rows[0]["NapeCodes"].ToString() != "") { string[] NapeCodesArr = dtServFuncExt.Rows[0]["NapeCodes"].ToString().Split(','); for (int j = 0; j < NapeCodesArr.Length; j++) { if (dtsp.Rows[i]["id"].ToString() == NapeCodesArr[j].ToString()) { dtsp.Rows[i]["checked"] = "true"; } } } } } } selectprdcontent = Newtonsoft.Json.JsonConvert.SerializeObject(dtsp); }
public static Com.DataPack.DataRsp <string> FuncEditSave(List <string> arr) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); string oldFuncCode = ""; if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "你现在登录已过期,请重新登录!"; } else { try { SchSystem.BLL.ServFunc sfcBll = new SchSystem.BLL.ServFunc(); SchSystem.Model.ServFunc sfcModel = new SchSystem.Model.ServFunc(); foreach (string str in arr) { string[] strarr = str.Split('#'); if (strarr[0] == "autoid") { sfcModel.AutoId = int.Parse(strarr[1]); } else if (strarr[0] == "businesstype") { sfcModel.TypeCode = strarr[1].Trim(); } else if (strarr[0] == "businesscode") { sfcModel.FuncCode = strarr[1].Trim(); } else if (strarr[0] == "oldbusinesscode") { oldFuncCode = strarr[1].Trim(); } else if (strarr[0] == "funcname") { sfcModel.FuncName = strarr[1].Trim(); } else if (strarr[0] == "userange") { sfcModel.FuncRange = strarr[1].Trim(); } else if (strarr[0] == "addsetinfo") { sfcModel.FuncSet = strarr[1].Trim(); } else if (strarr[0] == "businessdesc") { sfcModel.FuncDes = strarr[1].Trim(); } else if (strarr[0] == "tagsbusplatfrom") { sfcModel.FuncSyss = strarr[1].Trim(); } else if (strarr[0] == "note") { sfcModel.FuncNote = strarr[1].Trim(); } } if (sfcModel.TypeCode == "" || sfcModel.FuncCode == "" || sfcModel.FuncName == "" || sfcModel.FuncRange == "" || sfcModel.FuncSet == "" || sfcModel.FuncSyss == "") { rsp.code = "error"; rsp.msg = "操作失败!不允许输入空格"; } else { bool resbool = false; if (sfcModel.FuncCode != oldFuncCode) { resbool = sfcBll.Exists(sfcModel.FuncCode); } if (resbool == false) { bool result = sfcBll.Update(sfcModel); if (result) { SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt(); SchSystem.Model.ServFuncExt sfeModel = new SchSystem.Model.ServFuncExt(); sfeBll.Delete(sfcModel.AutoId); string FuncSet = sfcModel.FuncSet; string[] FuncSetRecArr = FuncSet.Split('|');//英文半角“|” for (int i = 0; i < FuncSetRecArr.Length; i++) { string[] FuncSetItemArr = FuncSetRecArr[i].Split('!');//英文半角“!” sfeModel.FuncId = sfcModel.AutoId; sfeModel.NapeCode = FuncSetItemArr[0]; sfeModel.NapeCodes = FuncSetItemArr[1]; sfeModel.NapeC = int.Parse(FuncSetItemArr[2]); sfeBll.Add(sfeModel); } rsp.code = "success"; rsp.msg = "操作成功"; } else { rsp.code = "error"; rsp.msg = "操作失败"; } } else { rsp.code = "codeRepeat"; rsp.msg = "功能代码不允许重复"; } } } catch (Exception ex) { rsp.code = "excepError"; rsp.msg = ex.Message; } } return(rsp); }
public static Com.DataPack.DataRsp <string> FuncAddSave(List <string> arr) { Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>(); if (Com.Session.userid == null) { rsp.code = "expire"; rsp.msg = "你现在登录已过期,请重新登录!"; } else { try { SchSystem.BLL.ServFunc sfcBll = new SchSystem.BLL.ServFunc(); SchSystem.Model.ServFunc sfcModel = new SchSystem.Model.ServFunc(); foreach (string str in arr) { string[] strarr = str.Split('#'); if (strarr[0] == "businesstype") { sfcModel.TypeCode = strarr[1].Trim(); } else if (strarr[0] == "businesscode") { sfcModel.FuncCode = strarr[1].Trim(); } else if (strarr[0] == "funcname") { sfcModel.FuncName = strarr[1].Trim(); } else if (strarr[0] == "userange") { sfcModel.FuncRange = strarr[1].Trim(); } else if (strarr[0] == "addsetinfo") { sfcModel.FuncSet = strarr[1].Trim(); } else if (strarr[0] == "businessdesc") { sfcModel.FuncDes = strarr[1].Trim(); } else if (strarr[0] == "tagsbusplatfrom") { sfcModel.FuncSyss = strarr[1].Trim(); } else if (strarr[0] == "note") { sfcModel.FuncNote = strarr[1].Trim(); } } if (sfcModel.TypeCode == "" || sfcModel.FuncCode == "" || sfcModel.FuncName == "" || sfcModel.FuncRange == "" || sfcModel.FuncSet == "" || sfcModel.FuncSyss == "") { rsp.code = "error"; rsp.msg = "操作失败!不允许输入空格"; } else { bool resbool = sfcBll.Exists(sfcModel.FuncCode); if (!resbool) { int result = sfcBll.Add(sfcModel); if (result > 0) { string FuncSet = sfcModel.FuncSet; string[] FuncSetRecArr = FuncSet.Split('|');//英文半角“|” DataTable dt = new DataTable(); dt.Columns.Add("FuncId"); dt.Columns.Add("NapeCode"); dt.Columns.Add("NapeCodes"); dt.Columns.Add("NapeC"); SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt(); for (int i = 0; i < FuncSetRecArr.Length; i++) { string[] FuncSetItemArr = FuncSetRecArr[i].Split('!');//英文半角“!” //SchSystem.BLL.ServFuncExt sfeBll = new SchSystem.BLL.ServFuncExt(); //SchSystem.Model.ServFuncExt sfeModel = new SchSystem.Model.ServFuncExt(); //sfeModel.FuncId = result; //sfeModel.NapeCode = FuncSetItemArr[0]; //sfeModel.NapeCodes = FuncSetItemArr[1]; //sfeModel.NapeC = int.Parse(FuncSetItemArr[2]); //sfeBll.Add(sfeModel); DataRow dry = dt.NewRow(); dry["FuncId"] = result; dry["NapeCode"] = Com.Public.SqlEncStr(FuncSetItemArr[0]); dry["NapeCodes"] = Com.Public.SqlEncStr(FuncSetItemArr[1]); dry["NapeC"] = int.Parse(Com.Public.SqlEncStr(FuncSetItemArr[2])); dt.Rows.Add(dry); } rsp.code = "success"; rsp.msg = sfeBll.ExecuteSqlBulkCopy(dt, "ServFuncExt"); } else { rsp.code = "error"; rsp.msg = "操作失败"; } } else { rsp.code = "codeRepeat"; rsp.msg = "功能代码不允许重复"; } } } catch (Exception ex) { rsp.code = "excepError"; rsp.msg = ex.Message; } } return(rsp); }