public string SaveRptStyle(ReportStyle rpt) { //要加入时间类型判断 var rptId = rpt.RptID; var rptName = rpt.RptName; var rptStyle = rpt.RptStyle; var orgId = rpt.OrgId; var treeId = rpt.TreeId; var styleType = rpt.styleType; string errMsg = string.Empty; switch (dbTypeValue) { case "SQL": { var sqlInsert = "INSERT INTO T_INFO_SISREPORT(REPORTTYPE,REPORTID,REPORTNAME,REPORTSTYLE,ORGID,TREEID) VALUES(@p1,@p2,@p3,@p4,@p5,@p6)"; var sqlDelete = "DELETE FROM T_INFO_SISREPORT WHERE REPORTID=@p1 AND ORGID=@p2 AND TREEID=@p3"; using (var conn = new SqlConnection(DBsql.GetConnectionstr())) { conn.Open(); SqlTransaction transaction = conn.BeginTransaction(); var pDel = new[] { new SqlParameter("@p1", rptId), new SqlParameter("@p2", orgId), new SqlParameter("@p3", treeId) }; var pIns = new[] { new SqlParameter("@p1", styleType), new SqlParameter("@p2", rptId), new SqlParameter("@p3", rptName), new SqlParameter("@p4", rptStyle), new SqlParameter("@p5", orgId), new SqlParameter("@p6", treeId) }; try { DBsql.ExecuteNonQuery(transaction, CommandType.Text, sqlDelete, pDel); DBsql.ExecuteNonQuery(transaction, CommandType.Text, sqlInsert, pIns); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); errMsg = ex.Message; } } } break; case "ORACLE": { //修改Oracle后按照SqlServer对照一次,否则出错 var sqlInsert = "INSERT INTO T_INFO_SISREPORT(REPORTID,REPORTNAME,REPORTSTYLE,ORGID,TREEID,REPORTTYPE) VALUES(:p1,:p2,:p3,:p4,:p5,:p6)"; var sqlDelete = "DELETE FROM T_INFO_SISREPORT WHERE REPORTNAME=:p1 AND ORGID=:p2 AND TREEID=:p3"; var pDel = new[] { new OracleParameter(":p1", rptName), new OracleParameter(":p2", orgId), new OracleParameter(":p3", treeId) }; var pIns = new[] { new OracleParameter(":p1", rptId), new OracleParameter(":p2", rptName), new OracleParameter(":p3", rptStyle), new OracleParameter(":p4", orgId), new OracleParameter(":p5", treeId), new OracleParameter(":p6", styleType) }; using (var conn = new OracleConnection(OracleHelper.retStr())) { conn.Open(); var transaction = conn.BeginTransaction(); try { SAC.DBOperations.OracleHelper.ExecuteNonQuery(transaction, CommandType.Text, sqlDelete, pDel); SAC.DBOperations.OracleHelper.ExecuteNonQuery(transaction, CommandType.Text, sqlInsert, pIns); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); errMsg = ex.Message; } } } break; default: //db2 { var sqlInsert = "INSERT INTO T_INFO_SISREPORT(REPORTID,REPORTNAME,REPORTSTYLE,ORGID,TREEID) VALUES(?,?,?,?,?)"; var sqlDelete = "DELETE FROM T_INFO_SISREPORT WHERE REPORTNAME=? AND ORGID=? AND TREEID=?"; var pDel = new[] { new OleDbParameter("?", rptName), new OleDbParameter("?", orgId), new OleDbParameter("?", treeId) }; var pIns = new[] { new OleDbParameter("?", rptId), new OleDbParameter("?", rptName), new OleDbParameter("?", rptStyle), new OleDbParameter("?", orgId), new OleDbParameter("?", treeId) }; using (var conn = DBdb2.GetConn()) { conn.Open(); var transaction = conn.BeginTransaction(); try { DBdb2.ExecuteNonQuery(transaction, CommandType.Text, sqlDelete, pDel); DBdb2.ExecuteNonQuery(transaction, CommandType.Text, sqlInsert, pIns); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); errMsg = ex.Message; } } } break; } return(errMsg); }