|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Data.Common;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using DSWeb.Areas.Account.Models.Chfee_management;
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
using HcUtility.Comm;
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.Account.DAL.AccountAuditDAL
|
|
|
{
|
|
|
public partial class AccountAuditDAL
|
|
|
{
|
|
|
#region 提交申请
|
|
|
|
|
|
// 根据handle类型执行更新操作:更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息
|
|
|
// 费用状态值 费用状态主要有11个状态,分别为
|
|
|
// 审核通过(STATUS=0)录入状态(STATUS=1)提交审核(STATUS=2)申请修改 (STATUS=3)
|
|
|
// 取消申请(STATUS=5)驳回提交(STATUS=6)驳回申请(STATUS=7)部分结算(STATUS=8)结算完毕(STATUS=9)
|
|
|
//List<C_Mmb> chfeeList
|
|
|
internal static DBResult Audit(int newStatus, List<C_Mmb> chfeeList)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
foreach (var chFee in chfeeList)
|
|
|
{
|
|
|
var status = int.Parse(chFee.FEESTATUS);
|
|
|
var canAudit = true;
|
|
|
var Feeid = chFee.Feeid;
|
|
|
|
|
|
if (newStatus == 2)
|
|
|
{
|
|
|
canAudit = status == 1 || status == 6;
|
|
|
}
|
|
|
else if (newStatus == 0)
|
|
|
{
|
|
|
canAudit = status == 2;
|
|
|
}
|
|
|
else if (newStatus == 6)
|
|
|
{
|
|
|
canAudit = status == 0 || status == 2;
|
|
|
|
|
|
}
|
|
|
else if (newStatus == 8 || newStatus == 9)
|
|
|
{
|
|
|
canAudit = status == 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!canAudit)
|
|
|
{
|
|
|
result.Success = false;
|
|
|
if (newStatus == 2)
|
|
|
result.Message = "只有在'录入状态'和'驳回提交'状态下才能提交审核操作";
|
|
|
else if (newStatus == 0)
|
|
|
{
|
|
|
result.Message = "只有在‘提交审核’状态下才能进行此操作";
|
|
|
}
|
|
|
else if (newStatus == 6)
|
|
|
{
|
|
|
result.Message = "只有在‘审核通过’或‘提交审核’状态下才能进行此操作";
|
|
|
}
|
|
|
else if (newStatus == 8 || newStatus == 9)
|
|
|
{
|
|
|
result.Message = "只有在‘审核通过’状态下才能进行此操作";
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
var feeBsNoList = new List<string>();
|
|
|
foreach (var msChFee in chfeeList)
|
|
|
{
|
|
|
var bsNo = msChFee.Feeid;
|
|
|
if (!feeBsNoList.Contains(bsNo))
|
|
|
{
|
|
|
feeBsNoList.Add(bsNo);
|
|
|
}
|
|
|
}
|
|
|
*/
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
|
|
|
|
|
|
//const string selectSql = "select FeeStatus from ch_fee_management where gid=@gid";
|
|
|
const string updateSql = "update ch_fee_management set FeeStatus=@FeeStatus where Feeid=@Feeid";
|
|
|
const string enumSql =
|
|
|
"select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=@EnumValueID";
|
|
|
|
|
|
//const string updateBsBillSql = "update ch_fee_management set Feestatus=@FeeOpStatus where gid=@gid";
|
|
|
//const string updatePcBillSql = "update ch_fee_management set FeeOpStatus=@FeeOpStatus where gid=@gid";
|
|
|
|
|
|
using (DbConnection connection = db.CreateConnection())
|
|
|
{
|
|
|
connection.Open();
|
|
|
try
|
|
|
{
|
|
|
var cmdEnum = db.GetSqlStringCommand(enumSql);
|
|
|
db.AddInParameter(cmdEnum, "@EnumValueID", DbType.Int32, newStatus);
|
|
|
var newStatusRef = Convert.ToString(db.ExecuteScalar(cmdEnum));
|
|
|
|
|
|
DbTransaction transaction = connection.BeginTransaction();
|
|
|
|
|
|
try
|
|
|
{
|
|
|
|
|
|
foreach (var chFee in chfeeList)
|
|
|
{
|
|
|
//var cmdSelect = db.GetSqlStringCommand(selectSql);
|
|
|
//db.AddInParameter(cmdSelect, "@gid", DbType.String, msChFee.GId);
|
|
|
/* //由于ch_fee_management表内有时间标签,因此不需要对是否已保存进行判断
|
|
|
var feeStatus = db.ExecuteScalar(cmdSelect, transaction);
|
|
|
|
|
|
if (feeStatus == null)
|
|
|
{
|
|
|
//throw new MsChFeeDealException("'" + msChFee.FeeName + "'数据还没有保存,不想允许提交,请保存后重试!");
|
|
|
}
|
|
|
if (feeStatus != msChFee.FEESTATUS)
|
|
|
{
|
|
|
//throw new MsChFeeDealException("'" + msChFee.FeeName + "'费用状态已经改变,不想允许提交,请刷新后重试!");
|
|
|
} */
|
|
|
|
|
|
var cmdUpdate = db.GetSqlStringCommand(updateSql);
|
|
|
db.AddInParameter(cmdUpdate, "@FeeStatus", DbType.Int32, newStatus);
|
|
|
db.AddInParameter(cmdUpdate, "@Feeid", DbType.String, chFee.Feeid);
|
|
|
db.ExecuteNonQuery(cmdUpdate, transaction);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
transaction.Commit();
|
|
|
|
|
|
result.Success = true;
|
|
|
result.Message = "提交成功";
|
|
|
result.Data = newStatusRef;
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
transaction.Rollback();
|
|
|
result.Success = false;
|
|
|
|
|
|
if (e is MsChFeeDealException)
|
|
|
result.Message = e.Message;
|
|
|
else
|
|
|
result.Message = "执行提交发生未知错误,请重试";
|
|
|
}
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
connection.Close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 明细部分
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
internal class MsChFeeDealException : Exception
|
|
|
{
|
|
|
internal MsChFeeDealException(string message)
|
|
|
: base(message)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|