SVN r999
SVN-Revision: r999
This commit is contained in:
@@ -163,6 +163,7 @@ namespace Lskj.Business.Impl
|
||||
return msg.Value + "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 说明:返回审批结果(Return 值用于逻辑判断;@msg 用于提示展示)
|
||||
/// 创建人:龚宇超
|
||||
@@ -294,6 +295,11 @@ namespace Lskj.Business.Impl
|
||||
? "0"
|
||||
: Convert.ToInt32(pReturn.Value).ToString();
|
||||
|
||||
if (retCode.Equals("-1")&& ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
SqlStoredProcedurepPrompt.GenerateAuditExecutionScript(sysModel, stepCode, billDocumentId, storedName, accractFlag, remindSelect, remarkText, remindOpers, confirmOpers, ret, returnd, selectConfirmFlag, IsStepOver);
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
@@ -1132,23 +1138,4 @@ namespace Lskj.Business.Impl
|
||||
/// <para>创建人:</para>
|
||||
/// <para>创建日期:2023-05-12</para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="typeCode">模块编号.</param>
|
||||
/// <returns>DataRow.</returns>
|
||||
public static DataRow GetAgencyAuthority(string typeCode)
|
||||
{
|
||||
DataTable dtTable = new DataTable();
|
||||
if (SqlHelper.ExecuteDataTable("select object_id('p_systemPrivilegeAgentTab')").Rows.Count > 0 && int.Parse(SqlHelper.ExecuteScalar("select count(*) from sysobjects where id = object_id('p_systemPrivilegeAgentTab')") + "") > 0)
|
||||
{
|
||||
string sqlValue = string.Format("select sourceuser from p_systemPrivilegeAgentTab where modid='{0}' and targetuser='{1}' and starttime<=getdate() and endtime>=getdate() and ban=1", typeCode, ERPInfo.Instance.UserName);
|
||||
dtTable = SqlHelper.ExecuteDataTable(sqlValue);
|
||||
}
|
||||
return dtTable.Rows.Count > 0 ? dtTable.Rows[0] : null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <para
|
||||
@@ -428,7 +428,7 @@ namespace Lskj.Business.Impl
|
||||
|
||||
if (result==-1&& ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
|
||||
SqlStoredProcedurepPrompt.GenerateBaseSaveProcedureScript(model, storedProcedureValue);
|
||||
}
|
||||
|
||||
model.Success = result == 1;
|
||||
@@ -502,7 +502,10 @@ namespace Lskj.Business.Impl
|
||||
|
||||
int result = Convert.ToInt32(returnValue.Value + "");
|
||||
|
||||
|
||||
if (result == -1 && ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
SqlStoredProcedurepPrompt.GenerateSaveBasePanelScript(model);
|
||||
}
|
||||
|
||||
retuenMsg = result + "";
|
||||
model.Success = result == 1;
|
||||
@@ -548,6 +551,13 @@ namespace Lskj.Business.Impl
|
||||
param[5].Value = "";
|
||||
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_baseApply", "baseApply", param);
|
||||
tipMsg = pMsg.Value + "";
|
||||
|
||||
|
||||
if (Convert.ToInt32(returnValue.Value.ToString()) == -1 && ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
SqlStoredProcedurepPrompt.GenerateBaseApplyScript( menuCode, parmaryKey, comfirmType);
|
||||
}
|
||||
|
||||
return Convert.ToInt32(returnValue.Value.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -86,6 +86,12 @@ namespace Lskj.Business.Impl
|
||||
|
||||
tipMsg = pMsg.Value.ToString();
|
||||
if (newVer == 1 && billWay == 1) billNo = tipMsg;
|
||||
|
||||
if (Convert.ToInt32(returnValue.Value + "") == -1 && ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
SqlStoredProcedurepPrompt.GenerateBillSaveScript( masterSql, detailSql, detailTable, billNo, detailGuid, billSeq, billWay, comfirm,auditFlag ,newVer);
|
||||
}
|
||||
|
||||
return Convert.ToInt32(returnValue.Value + "");
|
||||
}
|
||||
}
|
||||
@@ -158,6 +164,10 @@ namespace Lskj.Business.Impl
|
||||
DataSet dataSet = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_billApply", "billApply", param);
|
||||
|
||||
tipMsg = pMsg.Value.ToString();
|
||||
if (Convert.ToInt32(returnValue.Value + "") == -1 && ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
SqlStoredProcedurepPrompt.GenerateBillApplyExecutionScript( typeCode, billNo, hintMsg, comfirm, comfirmFlag);
|
||||
}
|
||||
return Convert.ToInt32(returnValue.Value + "");
|
||||
}
|
||||
/// <summary>
|
||||
@@ -426,6 +436,8 @@ namespace Lskj.Business.Impl
|
||||
sumCond += ",a.PrivilegeOper ";
|
||||
if (HasExistsColumn("p_systembillDetail", "ProhibitPaste"))
|
||||
sumCond += ",a.ProhibitPaste ";
|
||||
if (HasExistsColumn("p_systembillDetail", "FormatEditBox"))
|
||||
sumCond += ",a.FormatEditBox ";
|
||||
|
||||
string columsSql = string.Format(@"SELECT DISTINCT
|
||||
isnull(CASE WHEN ISNULL(b.userList,'')='' AND ISNULL(a.PrivilegeView,'')<>'' OR isnull(isVisible,0)=1 THEN 0 ELSE width END,0) width,
|
||||
@@ -511,6 +523,8 @@ namespace Lskj.Business.Impl
|
||||
sumCond += ",a.PrivilegeOper ";
|
||||
if (HasExistsColumn("p_systembillDetail", "ProhibitPaste"))
|
||||
sumCond += ",a.ProhibitPaste ";
|
||||
if (HasExistsColumn("p_systembillDetail", "FormatEditBox"))
|
||||
sumCond += ",a.FormatEditBox ";
|
||||
|
||||
string columsSql = string.Format(@"SELECT DISTINCT
|
||||
isnull(CASE WHEN ISNULL(b.userList,'')='' AND ISNULL(a.PrivilegeView,'')<>'' OR isnull(isVisible,0)=1 THEN 0 ELSE width END,0) width,
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
/*
|
||||
* 存储过程提示类
|
||||
* 执行存储过程报错(return -1 时)
|
||||
* 把对应执行的存储过程(exec xxx )记录到剪切板中
|
||||
*/
|
||||
using Lskj.Model;
|
||||
using Lskj.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Business.Impl
|
||||
{
|
||||
public sealed class SqlStoredProcedurepPrompt
|
||||
{
|
||||
|
||||
|
||||
//基础模块(ModuleGridEx)保存
|
||||
public static void GenerateSaveBasePanelScript(BaseSaveModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 根据版本选择存储过程名称
|
||||
string procedureName = model.NewVer == 0 ? "P_BaseSave" : "p_BaseSave70";
|
||||
|
||||
// 构建参数列表(根据ComfirmFlag选择对应参数集)
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
// 基础参数(两个参数集共有的部分)
|
||||
$"@baseSql = N'{EscapeSqlString(model.BaseSql)}'",
|
||||
$"@saveType = {Convert.ToInt32(model.BaseSaveType)}",
|
||||
$"@modid = N'{EscapeSqlString(model.MenuCode)}'",
|
||||
$"@tablename = N'{EscapeSqlString(model.TableName)}'",
|
||||
$"@keyfield = N'{EscapeSqlString(model.KeyField)}'",
|
||||
$"@keyvalue = N'{EscapeSqlString(model.FieldValue)}'",
|
||||
$"@Operatorid = {ERPInfo.Instance.UserId}",
|
||||
$"@operatorName = N'{EscapeSqlString(ERPInfo.Instance.UserName)}'",
|
||||
"@msg = @msg OUTPUT"
|
||||
};
|
||||
|
||||
// 如果确认标志不为0,添加@comfirmFlag参数(对应param2)
|
||||
if (model.ComfirmFlag != 0)
|
||||
{
|
||||
parameters.Add($"@comfirmFlag = {model.ComfirmFlag}");
|
||||
}
|
||||
|
||||
// 构建完整的执行语句
|
||||
string script = $@"DECLARE @msg NVARCHAR(4000), @return INT;
|
||||
EXEC @return = {procedureName} {string.Join(", ", parameters)};
|
||||
SELECT @return AS 'return', @msg AS msg;";
|
||||
|
||||
Clipboard.SetText(script);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// pubadd(ModulePanelEx)或审核界面中点击 保存
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="storedProcedureValue"></param>
|
||||
public static void GenerateBaseSaveProcedureScript(BaseSaveModel model, string storedProcedureValue = "0")
|
||||
{
|
||||
try
|
||||
{
|
||||
// 根据版本选择存储过程名称
|
||||
string procedureName = model.NewVer == 0 ? "P_BaseSave" : "p_BaseSave70";
|
||||
|
||||
// 处理确认标志
|
||||
if (storedProcedureValue.Equals("1"))
|
||||
model.ComfirmFlag = 1;
|
||||
|
||||
// 构建参数列表(保持顺序并统一使用@name=value格式)
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
// 处理baseSql中的单引号转义
|
||||
$"@baseSql = N'{EscapeSqlString(model.BaseSql)}'",
|
||||
$"@saveType = {Convert.ToInt32(model.BaseSaveType)}",
|
||||
$"@modid = N'{EscapeSqlString(model.MenuCode)}'",
|
||||
$"@tablename = N'{EscapeSqlString(model.TableName)}'",
|
||||
$"@keyfield = N'{EscapeSqlString(model.KeyField)}'",
|
||||
$"@keyvalue = N'{EscapeSqlString(model.FieldValue)}'",
|
||||
$"@Operatorid = {ERPInfo.Instance.UserId}",
|
||||
$"@operatorName = N'{EscapeSqlString(ERPInfo.Instance.UserName)}'"
|
||||
};
|
||||
|
||||
// 添加确认标志参数(如果需要)
|
||||
if (model.ComfirmFlag != 0)
|
||||
{
|
||||
parameters.Add($"@comfirmFlag = {model.ComfirmFlag}");
|
||||
}
|
||||
|
||||
// 添加输出参数
|
||||
parameters.Add("@msg = @msg OUTPUT");
|
||||
|
||||
// 构建完整的执行语句
|
||||
string script = $@"DECLARE @msg NVARCHAR(4000), @return INT;
|
||||
EXEC @return = {procedureName} {string.Join(", ", parameters)}
|
||||
SELECT @return AS 'return', @msg AS msg;";
|
||||
|
||||
Clipboard.SetText(script);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// pubadd(ModulePanelEx)点击 提交
|
||||
/// </summary>
|
||||
/// <param name="menuCode"></param>
|
||||
/// <param name="parmaryKey"></param>
|
||||
/// <param name="comfirmType"></param>
|
||||
public static void GenerateBaseApplyScript(string menuCode, string parmaryKey, int comfirmType)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 构建参数列表,统一使用@name=value格式
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
$"@typeCode = N'{EscapeSqlString(menuCode)}'",
|
||||
$"@billDocumentId = N'{EscapeSqlString(parmaryKey)}'",
|
||||
$"@Operatorid = {ERPInfo.Instance.UserId}",
|
||||
$"@operatorName = N'{EscapeSqlString(ERPInfo.Instance.UserName)}'",
|
||||
$"@comfirmType = {comfirmType}",
|
||||
"@msg = @msg OUTPUT"
|
||||
};
|
||||
|
||||
// 构建完整的执行语句
|
||||
string script = $@"DECLARE @msg NVARCHAR(4000), @return INT;
|
||||
EXEC @return = p_baseApply {string.Join(", ", parameters)}
|
||||
SELECT @return AS 'return', @msg AS msg;";
|
||||
|
||||
Clipboard.SetText(script);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//单据保存
|
||||
public static void GenerateBillSaveScript(string masterSql, string detailSql, string detailTable, string billNo,
|
||||
string detailGuid, string billSeq, int billWay, int comfirm,
|
||||
int auditFlag = 0, int newVer = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 根据版本选择存储过程名称
|
||||
string procedureName = newVer == 0 ? "P_BillSavePr_3" : "P_BillSavePr70";
|
||||
|
||||
// 构建参数列表(保持与原方法一致的顺序和格式)
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
// 处理主SQL语句中的单引号转义
|
||||
$"@Sql = N'{EscapeSqlString(masterSql)}'",
|
||||
$"@billdocument_id = N'{EscapeSqlString(billNo)}'",
|
||||
$"@tmpstr = N'{EscapeSqlString(detailGuid)}'",
|
||||
$"@Operatorid = {ERPInfo.Instance.UserId}",
|
||||
$"@Fbilltagid = {billWay}",
|
||||
$"@operateway = N'{EscapeSqlString(billSeq)}'",
|
||||
"@msg = @msg OUTPUT",
|
||||
$"@auditFlag = {auditFlag}",
|
||||
$"@comfirmFlag = {comfirm}"
|
||||
};
|
||||
|
||||
// 构建完整的执行语句(包含临时表清理语句)
|
||||
string script = "--保存明细到临时表\r\n" +detailSql+ "\r\n" + $@"DECLARE @msg NVARCHAR(4000), @return INT;
|
||||
-- 执行单据保存存储过程
|
||||
EXEC @return = {procedureName} {string.Join(", ", parameters)};
|
||||
SELECT @return AS 'return', @msg AS msg;
|
||||
-- 清理临时表
|
||||
DELETE {EscapeSqlString(detailTable)}_temp WHERE sysstr = N'{EscapeSqlString(detailGuid)}';";
|
||||
|
||||
Clipboard.SetText(script);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//提交单据
|
||||
public static void GenerateBillApplyExecutionScript(string typeCode, string billNo, string hintMsg, int comfirm, int comfirmFlag = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 模拟原方法中检查存储过程是否包含@confirmFlag参数的逻辑
|
||||
bool hasConfirmFlag = CheckIfProcedureHasParameter("p_billApply", "@confirmFlag");
|
||||
|
||||
// 构建参数列表,保持与原方法一致的顺序
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
$"@typeCode = N'{EscapeSqlString(typeCode)}'",
|
||||
$"@billDocumentId = N'{EscapeSqlString(billNo)}'",
|
||||
$"@Operatorid = {ERPInfo.Instance.UserId}",
|
||||
$"@operatorName = N'{EscapeSqlString(ERPInfo.Instance.UserName)}'",
|
||||
$"@comfirmType = {comfirm}",
|
||||
$"@msg = @msg OUTPUT"
|
||||
};
|
||||
|
||||
// 如果存储过程包含@confirmFlag参数,则添加该参数
|
||||
if (hasConfirmFlag)
|
||||
{
|
||||
parameters.Add($"@confirmFlag = {comfirmFlag}");
|
||||
}
|
||||
|
||||
// 构建完整的存储过程执行语句
|
||||
string executionScript = $@"DECLARE @msg NVARCHAR(4000), @return INT;
|
||||
EXEC @return = p_billApply {string.Join(", ", parameters)};
|
||||
SELECT @return AS 'return', @msg AS msg;";
|
||||
|
||||
Clipboard.SetText(executionScript);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//审核(单表审核和单据审核)
|
||||
public static void GenerateAuditExecutionScript(
|
||||
DynamicModel sysModel,
|
||||
string stepCode,
|
||||
string billDocumentId,
|
||||
string storedName,
|
||||
string accractFlag,
|
||||
string remindSelect,
|
||||
string remarkText = "",
|
||||
string remindOpers = "",
|
||||
string confirmOpers = "",
|
||||
bool ret = false,
|
||||
int returnd = 0,
|
||||
int selectConfirmFlag = 0,
|
||||
bool isStepOver = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool newAudit = true;
|
||||
string[] newParameter = new string[] { "@nextSelectStepCode", "@nextSelectStepOper", "@selectConfirmFlag" };
|
||||
if (!BaseAuditImpl.isParamComplete(storedName, newParameter)) newAudit = false;
|
||||
|
||||
// 构建参数列表
|
||||
List<string> parameters = new List<string>
|
||||
{
|
||||
// 基础参数
|
||||
$"@typeCode = N'{EscapeSqlString(sysModel.ModuleCode)}'",
|
||||
$"@stepCode = {(string.IsNullOrEmpty(stepCode) ? 0 : Convert.ToInt32(stepCode))}",
|
||||
$"@billDocumentId = N'{EscapeSqlString(billDocumentId)}'",
|
||||
$"@operatorId = {sysModel.UserId}",
|
||||
$"@operatorName = N'{EscapeSqlString(sysModel.UserName)}'",
|
||||
$@"@auditAdvice = N'{EscapeSqlString(accractFlag == "F" ?
|
||||
remarkText : (isStepOver ? $"由[{sysModel.UserName}]强制退回,意见:{remarkText}" : remarkText))}'",
|
||||
$"@Direction = N'{EscapeSqlString(accractFlag)}'",
|
||||
"@msg = @msg OUTPUT"
|
||||
};
|
||||
// 添加新审核相关参数
|
||||
if (newAudit)
|
||||
{
|
||||
parameters.Add($"@selectConfirmFlag = {selectConfirmFlag}");
|
||||
parameters.Add("@nextSelectStepCode = @nextSelectStepCode OUTPUT");
|
||||
parameters.Add("@nextSelectStepOper = @nextSelectStepOper OUTPUT");
|
||||
}
|
||||
|
||||
// 添加提醒相关参数
|
||||
if (remindSelect == "1")
|
||||
{
|
||||
parameters.Add($"@hint_opers = N'{EscapeSqlString(remindOpers)}'");
|
||||
parameters.Add($"@comfirm_opers = N'{EscapeSqlString(confirmOpers)}'");
|
||||
}
|
||||
|
||||
// 添加返回步骤参数
|
||||
if (ret)
|
||||
{
|
||||
parameters.Add($"@backStepCode = {returnd}");
|
||||
}
|
||||
|
||||
|
||||
// 构建完整执行语句(包含参数声明和结果查询)
|
||||
string script = $@"DECLARE
|
||||
@msg {(ERPInfo.Instance.ChangeParameterType ? "NVARCHAR(6000)" : "VARCHAR(3000)")},
|
||||
@nextSelectStepCode VARCHAR(3000),
|
||||
@nextSelectStepOper VARCHAR(3000),
|
||||
@return INT;
|
||||
EXEC @return = {storedName}
|
||||
{string.Join(",\n ", parameters)};
|
||||
SELECT
|
||||
'return' = @return,
|
||||
'msg' = @msg;";
|
||||
|
||||
// 复制到剪贴板
|
||||
Clipboard.SetText(script);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//右键执行存储过程
|
||||
public static void GenerateProcedureExecutionScript(string Action, List<string> paramList,bool isFirstFlag = false,string comfirmFlag = "0")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Action)) return;
|
||||
// 解析存储过程名称和参数
|
||||
List<string> parameters = ReplaceHelper.GetParamFields(Action);
|
||||
string[] paramStr = parameters[0].Replace("{", "").Replace("}", "").Split(',');
|
||||
string procedureName = Action.Replace(parameters[0], "").Trim();
|
||||
|
||||
// 构建参数列表
|
||||
List<string> sqlParameters = new List<string>();
|
||||
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
||||
SqlParameter pComfirmFlag = new SqlParameter("@comfirmFlag", SqlDbType.Int);
|
||||
|
||||
for (int i = 0; i < paramStr.Length; i++)
|
||||
{
|
||||
string paramName = paramStr[i].Trim();
|
||||
if (paramName.Equals("@msg", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// 处理@msg参数
|
||||
pMsg.Direction = ParameterDirection.InputOutput;
|
||||
pMsg.Value = string.IsNullOrEmpty(paramList[i]) ? "" : paramList[i];
|
||||
sqlParameters.Add("@msg = @msg OUTPUT");
|
||||
}
|
||||
else if (paramName.Equals("@comfirmFlag", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// 处理@comfirmFlag参数
|
||||
pComfirmFlag.Value = comfirmFlag;
|
||||
sqlParameters.Add($"@{paramName} = {comfirmFlag}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 处理普通参数
|
||||
sqlParameters.Add($"{paramName} = N'{EscapeSqlString(paramList[i])}'");
|
||||
}
|
||||
}
|
||||
// 构建完整执行语句
|
||||
string script = $@"DECLARE @returnValue INT, @msg VARCHAR(2000);
|
||||
EXEC @returnValue = {procedureName}
|
||||
{string.Join(", ", sqlParameters)};
|
||||
SELECT 'return' = @returnValue, 'msg' = @msg;";
|
||||
|
||||
// 复制到剪贴板
|
||||
Clipboard.SetText(script);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 转义SQL字符串中的单引号,确保生成的语句语法正确
|
||||
/// </summary>
|
||||
private static string EscapeSqlString(string input)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user