/// <summary> /// 删除一条数据 /// </summary> public ReturnResult DeleteRole(string F_ROLECODE) { ReturnResult result = new ReturnResult(); StringBuilder strSql = new StringBuilder(); DbAPI dbHelper = new DbAPI(); try { dbHelper.OpenConn(""); dbHelper.OpenTrans(); strSql.Append("delete from ROLEINFO "); strSql.Append(" where F_ROLECODE=:F_ROLECODE "); OracleParameter[] parameters = { new OracleParameter(":F_ROLECODE", dbHelper.CheckDBNull(F_ROLECODE)) }; int rows = dbHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { strSql.Clear(); strSql.Append("delete from ROLEFUNCTION "); strSql.Append(" where F_ROLECODE=:F_ROLECODE "); OracleParameter[] parameters1 = { new OracleParameter(":F_ROLECODE", dbHelper.CheckDBNull(F_ROLECODE)) }; int rows1 = dbHelper.ExecuteNonQuery(strSql.ToString(), parameters1); if (rows1 <= 0) { goto Over; } result.success = true; result.Message = "操作成功"; dbHelper.CommitTrans(); dbHelper.CloseConn(); return(result); } else { goto Over; } } catch (Exception ex) { LogBN.WriteLog(typeof(ROLEINFO_BN), "DeleteRole 程序段的异常" + ex); goto Over; } Over: result.success = false; result.Message = "操作失败"; dbHelper.RollBack(); dbHelper.CloseConn(); return(result); }
/// <summary> /// 增加一条数据 /// </summary> public ReturnResult AddRole(ROLEINFO model, string[] rolefunlist) { ReturnResult result = new ReturnResult(); StringBuilder strSql = new StringBuilder(); DbAPI dbHelper = new DbAPI(); try { dbHelper.OpenConn(""); dbHelper.OpenTrans(); model.F_ROLECODE = dbHelper.GUID(); strSql.Append("insert into ROLEINFO("); strSql.Append("F_ROLECODE,F_NAME,F_DESCRIPTION"); strSql.Append(") values ("); strSql.Append(":F_ROLECODE,:F_NAME,:F_DESCRIPTION"); strSql.Append(") "); OracleParameter[] parameters = { new OracleParameter(":F_ROLECODE", dbHelper.CheckDBNull(model.F_ROLECODE)), new OracleParameter(":F_NAME", dbHelper.CheckDBNull(model.F_NAME)), new OracleParameter(":F_DESCRIPTION", dbHelper.CheckDBNull(model.F_DESCRIPTION)) }; int rows = dbHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { for (int i = 0; i < rolefunlist.Length; i++) { strSql.Clear(); strSql.Append("insert into ROLEFUNCTION("); strSql.Append("F_ID,F_ROLECODE,F_FUNCTIONCODE"); strSql.Append(") values ("); strSql.Append(":F_ID,:F_ROLECODE,:F_FUNCTIONCODE"); strSql.Append(") "); OracleParameter[] parameters1 = { new OracleParameter(":F_ID", dbHelper.CheckDBNull(dbHelper.GUID())), new OracleParameter(":F_ROLECODE", dbHelper.CheckDBNull(model.F_ROLECODE)), new OracleParameter(":F_FUNCTIONCODE", dbHelper.CheckDBNull(rolefunlist[i])) }; int rows1 = dbHelper.ExecuteNonQuery(strSql.ToString(), parameters1); if (rows1 <= 0) { goto Over; } } result.success = true; result.Message = "操作成功"; dbHelper.CommitTrans(); dbHelper.CloseConn(); return(result); } else { goto Over; } } catch (Exception ex) { LogBN.WriteLog(typeof(ROLEINFO_BN), "SaveRole 程序段的异常" + ex); goto Over; } Over: result.success = false; result.Message = "操作失败"; dbHelper.RollBack(); dbHelper.CloseConn(); return(result); }