You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/AuditProcess/AuditService.aspx.cs

1919 lines
98 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Collections.Generic;
using DSWeb.MvcShipping.Models.MsOpApply;
using DSWeb.MvcShipping.DAL.MsOpApplyDAL;
using DSWeb.MvcShipping.DAL.MsOpBulkDAL;
using DSWeb.MvcShipping.Models.MsOpBulk;
using DSWeb.MvcShipping.DAL.MsOpOtherDAL;
using DSWeb.MvcShipping.Models.MsOpOther;
using DSWeb.WorkFlow;
namespace DSWeb.AuditProcess
{
public partial class AuditService : System.Web.UI.Page
{
private string strHandle;//执行操作类型 "audit"表示审核费用 "auditpass"表示审核通过 "reject"标识驳回提交
private string strFeeGid;//费用GID
private string strBSNO;//委托业务编号
private string strUserID;//用户GID
private int iType;//费用类型
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private string stroplb; //业务类别:海运出口、海运出口
protected void Page_Load(object sender, EventArgs e)
{
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString().Trim();
}
if (Request.QueryString["oplb"] != null)
{
stroplb = Request.QueryString["oplb"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strBSNO = Request.QueryString["bsno"].ToString().Trim();
}
if (Request.QueryString["id"] != null)
{
strFeeGid = Request.QueryString["id"].ToString().Trim();
}
if (Request.QueryString["type"] != null)
{
iType = int.Parse(Request.QueryString["type"].ToString().Trim());
}
if (strHandle == "audit" || strHandle == "Seaiaudit" || strHandle == "auditpass" || strHandle == "reject")
{
Response.Write(ExcuteHandle(strHandle, strFeeGid));
}
if (strHandle == "modifypass")
{
Response.Write(ApplyModifyFee(strFeeGid,iType));
}
if(strHandle == "modifyreject")
{
Response.Write(ApplyRejectFee(strFeeGid));
}
if (strHandle == "deletepass")
{
Response.Write(ApplyDeleteFee(strFeeGid));
}
if (strHandle == "deletereject")
{
Response.Write(ApplyDeleteRejectFee(strFeeGid));
}
if (strHandle == "amend")
{
Response.Write(ExcuteModifyByCopy(strBSNO));
}
if (strHandle == "history")
{
Response.Write(ExistFeeModifyHistory(strFeeGid));
}
if (strHandle == "existmodify" || strHandle == "Seaiexistmodify")
{
//查看是否有费用申请历史记录ch_fee_modify(费用申请修改表)
Response.Write(IsExistFeeModify(strFeeGid));
}
if (strHandle == "batchpass" && strBSNO != null)
{
Response.Write(BatchAuditPass(strBSNO, strUserID));
}
if (strHandle == "lockfee" && strBSNO != null)
{
Response.Write(BatchLockFee(strBSNO));
}
if (strHandle == "unlockfee" && strBSNO != null)
{
Response.Write(BatchUnLockFee(strBSNO));
}
if (strHandle == "getstatus" && strFeeGid != null)
{
Response.Write(GetFeeStatus(strFeeGid));
}
if (strHandle == "LockFeeisinvoice" && strBSNO != null)
{//禁开发票
Response.Write(BatchLockFeeisinvoice(strBSNO));
}
if (strHandle == "unlockfeeisinvoice" && strBSNO != null)
{//解禁发票
Response.Write(BatchUnLockFeeisinvoice(strBSNO));
}
}
#region 获取费用状态值
/// <summary>
/// 获取费用状态值
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <returns>返回费用状态值</returns>
private int GetFeeStatus(string tempFeeID)
{
int iResult = 0;
FeeEntity feeEntity = new FeeEntity();
FeeDA feeDA = new FeeDA();
feeEntity = feeDA.GetFeeByID(tempFeeID);
if (feeEntity != null)
{
if (feeEntity.GID != null)
{
iResult = feeEntity.FeeStatus;
}
else
{
iResult = -1;
}
}
else
{
iResult = -1;
}
return iResult;
}
#endregion
#region 批量审核通过
/// <summary>
/// 批量审核通过
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <param name="tempUserID">用户GID</param>
/// <returns>值等于1表示批量审核通过成功 值不等1表示批量审核失败</returns>
private int BatchAuditPass(string tempBSNO,string tempUserID)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
IList<FeeEntity> feeEntities = new List<FeeEntity>();
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//查找付费工作流信息
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT, strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb == "op_Seae")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Seai")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Sean")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpSeanRecvPayAudit,strCompanyID);
}
else if (stroplb == "op_Apply")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Bulk")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Other")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpOtherRecvPayAudit, strCompanyID);
}
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
IList<WorkFlowDoEntity> messageWorkFlowDoEntities = new List<WorkFlowDoEntity>();
//消息提醒
MessageDA messageDA = new MessageDA();
IList<MessageEntity> messageEntities = new List<MessageEntity>();
feeEntities = feeDA.GetAuditFeeByBSNO(tempBSNO, tempUserID);
foreach (FeeEntity feeEntity in feeEntities)
{
if (feeEntity.FeeStatus == 2)
{
if (feeEntity.FeeStatus == 2)
{
//iResult = feeDA.UpdateFeeStatus(0, strGid);
//如果工作流信息存在
if (workFlowEntity != null)
{
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
//先查看是否当前付费申请已经进入工作流
workFlowDoEntities = workFlowDoDA.GetAllWorkFlowDoByBillNO(workFlowEntity.GID, feeEntity.GID);
if (workFlowDoEntities.Count > 0)
{
int iCount = 0;
//如果付费申请已经进入工作流,先判断当前打开付费审核页面操作人是否是工作流内相关审核人,如果是则
foreach (WorkFlowDoEntity workFlowDoEntity in workFlowDoEntities)
{
//查看当前操作人是否为审核人
if (workFlowDoEntity.Auditor == strUserID)
{
iCount++;
//查看当前审核人所处的步骤是否已经完成
if (!workFlowDoEntity.IsFinish)
{
//iResult等于1表示工作执行操作成功
iResult = workFlowHelper.DoWorkFlowStep(workFlowDoEntity, workFlowEntity);
if (iResult == 1)
{
//遍历工作流步骤信息,如果是工作流步骤最后一步,表示审核通过则置ch_fee审核通过
foreach (WorkFlowStepEntity workFlowStepEntity in workFlowEntity.WorkFlowSteps)
{
if (workFlowStepEntity.StepNO == workFlowDoEntity.StepNO)
{
if (workFlowStepEntity.IsLast)
{
int iTempStatus = feeDA.UpdateFeeStatus(0, feeEntity.GID);
if (iTempStatus != 1)
{
iResult = -5;//更新费用状态失败
}
}
}
}
}
break;
}
else if (workFlowDoEntity.IsFinish)
{
iResult = -4;//付费审核步骤已经完成,不能重复审核
break;
}
}
}
if (iCount == 0)
{
iResult = -3;//没有权利审核付费
}
}
}
}
else
{
iResult = -1;
}
}
}
int iApplicantState = 0;
if (feeEntities.Count > 0 && iResult == 1)
{
messageWorkFlowDoEntities = workFlowDoDA.GetWorkFlowDoAuditPassForMessage(workFlowEntity.GID, feeEntities[0].GID);
if (messageWorkFlowDoEntities.Count > 0)
{
foreach (WorkFlowDoEntity workFlowDo in messageWorkFlowDoEntities)
{
foreach (WorkFlowStepEntity workFlowStepEntity in workFlowEntity.WorkFlowSteps)
{
if (workFlowStepEntity.StepNO == workFlowDo.StepNO)
{
if (workFlowStepEntity.IsLast)
{
if (!workFlowDo.IsFinish)
{
MessageEntity messageEntity = new MessageEntity();
messageEntity.GID = Guid.NewGuid().ToString();
messageEntity.Name = "FeeAudit";
//messageEntity.Description = "应收应付待审核通知";
messageEntity.IsRead = false;
messageEntity.ReadCount = 0;
//messageEntity.MessageContent = strShowName + " 已批准 [应收应付费用审核] 审核,当前等待您的审核 ";
messageEntity.TaskID = "";
messageEntity.Receiver = workFlowDo.Auditor;
messageEntity.TaskUrl = "auditprocess/feeaudit.aspx";
messageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
messageEntity.RecvType = 2;//申请审核类型
if (stroplb == "op_Seai")
{
messageEntity.Description = "海运进口应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运进口应收应付费用审核] 审核,当前等待您的审核 ";
}
else if (stroplb == "op_Seae")
{
messageEntity.Description = "海运出口应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [海运出口应收应付费用审核] 审核,当前等待您的审核 ";
}
else if (stroplb == "op_Sean")
{
messageEntity.Description = "内贸海运应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准[内贸海运应收应付费用审核] 审核,当前等待您的审核";
}
else if (stroplb == "op_Apply")
{
messageEntity.Description = "报关业务应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [报关业务应收应付费用审核] 审核,当前等待您的审核 ";
}
else if (stroplb == "op_Bulk")
{
messageEntity.Description = "大宗散货业务应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [大宗散货业务应收应付费用审核] 审核,当前等待您的审核 ";
}
else if (stroplb == "op_Other")
{
messageEntity.Description = "散杂运输应收应付待审核通知";
messageEntity.MessageContent = strShowName + " 已批准 [散杂运输应收应付费用审核] 审核,当前等待您的审核 ";
}
messageEntities.Add(messageEntity);
if (iApplicantState == 0)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
applicantMessageEntity.Name = "FeeAudit";
//applicantMessageEntity.Description = "应收应付待审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
//applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [应收应付费用审核] 申请,现等待下一步审核 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
applicantMessageEntity.RecvType = 3;//审核完成类型
if (stroplb == "op_Seai")
{
applicantMessageEntity.TaskUrl = "SeaiInfo/SeaImportList.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "海运进口应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口应收应付费用审核] 申请,现等待下一步审核 ";
}
else if (stroplb == "op_Seae")
{
applicantMessageEntity.TaskUrl = "shipping/orderlist.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "海运出口应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运出口应收应付费用审核] 申请,现等待下一步审核 ";
}
else if (stroplb == " op_Sean")
{
applicantMessageEntity.TaskUrl = "SeanInfo/SeanInTradeList.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "内贸海运应收应付待审核通知";
applicantMessageEntity.MessageContent =strShowName+ " 已经批准通过 [内贸海运应收应付费用审核] 申请,现等待下一步审核";
}
else if (stroplb == "op_Apply")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpApply?oplb=" + stroplb;
applicantMessageEntity.Description = "报关业务应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [报关业务应收应付费用审核] 申请,现等待下一步审核 ";
}
else if (stroplb == "op_Bulk")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpBulk?oplb=" + stroplb;
applicantMessageEntity.Description = "大宗散货业务应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [大宗散货业务应收应付费用审核] 申请,现等待下一步审核 ";
}
else if (stroplb == "op_Other")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpOther?oplb=" + stroplb;
applicantMessageEntity.Description = "散杂运输应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [散杂运输应收应付费用审核] 申请,现等待下一步审核 ";
}
messageEntities.Add(applicantMessageEntity);
iApplicantState++;
}
break;
}
else
{
if (iApplicantState == 0)
{
MessageEntity applicantMessageEntity = new MessageEntity();
applicantMessageEntity.GID = Guid.NewGuid().ToString();
applicantMessageEntity.Name = "FeeAudit";
//applicantMessageEntity.Description = "应收应付待审核通知";
applicantMessageEntity.IsRead = false;
applicantMessageEntity.ReadCount = 0;
//applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [应收应付费用审核] 申请,全部审核已完成 ";
applicantMessageEntity.TaskID = "";
applicantMessageEntity.Receiver = workFlowDo.Applicant;
applicantMessageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
applicantMessageEntity.RecvType = 3;//审核完成类型
if (stroplb == "op_Seai")
{
applicantMessageEntity.TaskUrl = "SeaiInfo/SeaImportList.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "海运进口应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运进口应收应付费用审核] 申请,全部审核已完成 ";
}
else if (stroplb == "op_Seae")
{
applicantMessageEntity.TaskUrl = "shipping/orderlist.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "海运出口应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [海运出口应收应付费用审核] 申请,全部审核已完成 ";
}
else if (stroplb == "op_Sean")
{
applicantMessageEntity.TaskUrl = "SeanInfo/SeanInTradeList.aspx?oplb=" + stroplb;
applicantMessageEntity.Description = "内贸海运应收应付待审核通知";
applicantMessageEntity.MessageContent =strShowName+ "已经批准通过 [内贸海运应收应付费用审核] 申请,全部审核已完成";
}
else if (stroplb == "op_Apply")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpApply?oplb=" + stroplb;
applicantMessageEntity.Description = "报关业务应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [报关业务应收应付费用审核] 申请,全部审核已完成 ";
}
else if (stroplb == "op_Bulk")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpBulk?oplb=" + stroplb;
applicantMessageEntity.Description = "大宗散货业务应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [大宗散货业务应收应付费用审核] 申请,全部审核已完成 ";
}
else if (stroplb == "op_Other")
{
applicantMessageEntity.TaskUrl = "MvcShipping/MsOpOther?oplb=" + stroplb;
applicantMessageEntity.Description = "散杂运输应收应付待审核通知";
applicantMessageEntity.MessageContent = strShowName + " 已经批准通过 [散杂运输应收应付费用审核] 申请,全部审核已完成 ";
}
messageEntities.Add(applicantMessageEntity);
iApplicantState++;
}
break;
}
}
}
}
}
if (messageEntities.Count > 0)
{
messageDA.CreateMessage(MessageType.FEEAUDIT, messageEntities);
}
}
}
return iResult;
}
#endregion
#region 批量加锁操作
/// <summary>
/// 批量加锁操作
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示加锁成功 值不等于1表示加锁失败</returns>
private int BatchLockFee(string tempBSNO)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
IList<FeeEntity> feeEntities = new List<FeeEntity>();
feeEntities = feeDA.GetFeeByBSNO(tempBSNO);
int iCount = 0;
for(int i=0;i<feeEntities.Count;i++)
{
if (feeEntities[i].FeeStatus == 0 || feeEntities[i].FeeStatus == 8 || feeEntities[i].FeeStatus == 9)
{
iCount++;
}
}
if (iCount == feeEntities.Count)
{
if (stroplb == "op_Seae")
{
SeaExportInfoDA seaExportInfoDA = new SeaExportInfoDA();
iResult = seaExportInfoDA.LockFeeStatus(tempBSNO);
if (iResult == 1)
{
TopSeaeEntity topSeaeEntity = seaExportInfoDA.GetID(tempBSNO);
if (topSeaeEntity != null)
{
if (topSeaeEntity.BSNO != null)
{
if (topSeaeEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
else if (stroplb == "op_Seai")
{
SeaImportInfoDA seaImportInfoDA = new SeaImportInfoDA();
iResult = seaImportInfoDA.LockFeeStatus(tempBSNO);
if (iResult == 1)
{
TopSeaiEntity topSeaiEntity = seaImportInfoDA.GetID(tempBSNO);
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
else if (stroplb == "op_Sean")
{
Opsean seanDA = new Opsean();
iResult = seanDA.LockSeanFeeStatus(tempBSNO);
if (iResult == 1)
{
OpseanEntity opseanEntity = new OpseanEntity();
opseanEntity = seanDA.GetAllSeanInfo(tempBSNO);
if (opseanEntity != null)
{
if (opseanEntity.BSNO != null)
{
if (opseanEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else if (stroplb == "op_Apply")
{
iResult = MsOpApplyDAL.LockFeeStatus(tempBSNO);
if (iResult == 1)
{
MsOpApply topSeaiEntity = MsOpApplyDAL.GetData("BSNO='"+tempBSNO+"'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
else if (stroplb == "op_Bulk")
{
iResult = MsOpApplyDAL.LockFeeStatus(tempBSNO);
if (iResult == 1)
{
MsOpBulk topSeaiEntity = MsOpBulkDAL.GetData("BSNO='" + tempBSNO + "'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
else if (stroplb == "op_Other")//散杂运输
{
iResult = MsOpOtherDAL.LockFeeStatus(tempBSNO);
if (iResult == 1)
{
MsOpOtherEntity MsOpOtherEntity = MsOpOtherDAL.GetData("BSNO='" + tempBSNO + "'");
if (MsOpOtherEntity != null)
{
if (MsOpOtherEntity.BSNO != null)
{
if (MsOpOtherEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
else
{
iResult = -2;//有未完成审核的费用,不能进行加锁操作
}
return iResult;
}
#endregion
#region 批量解锁操作
/// <summary>
/// 批量解锁操作
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示解锁成功 值不等于1表示解锁失败</returns>
private int BatchUnLockFee(string tempBSNO)
{
int iResult = 0;
if (stroplb == "op_Seae")
{
TopSeaeEntity topSeaeEntity = new TopSeaeEntity();
SeaExportInfoDA seaExportInfoDA = new SeaExportInfoDA();
topSeaeEntity = seaExportInfoDA.GetID(tempBSNO);
if (topSeaeEntity != null)
{
if (topSeaeEntity.BSNO != null)
{
if (topSeaeEntity.FEESTATUS)
{
iResult = seaExportInfoDA.UnLockFeeStatus(tempBSNO);
if (iResult == 1)
{
topSeaeEntity = seaExportInfoDA.GetID(tempBSNO);
if (topSeaeEntity != null)
{
if (topSeaeEntity.BSNO != null)
{
if (topSeaeEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else if (stroplb == "op_Seai")
{
TopSeaiEntity topSeaiEntity = new TopSeaiEntity();
SeaImportInfoDA seaImportInfoDA = new SeaImportInfoDA();
topSeaiEntity = seaImportInfoDA.GetID(tempBSNO);
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = seaImportInfoDA.UnLockFeeStatus(tempBSNO);
if (iResult == 1)
{
topSeaiEntity = seaImportInfoDA.GetID(tempBSNO);
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else if (stroplb == "op_Sean")
{
Opsean seanDA = new Opsean();
OpseanEntity seanEntity = new OpseanEntity();
seanEntity = seanDA.GetAllSeanInfo(tempBSNO);
if (seanEntity != null)
{
if (seanEntity.BSNO != null)
{
if (seanEntity.FEESTATUS)
{
iResult = seanDA.UnLockSeanFeeStatus(tempBSNO);
if (iResult == 1)
{
seanEntity = seanDA.GetAllSeanInfo(tempBSNO);
if (seanEntity != null)
{
if (seanEntity.BSNO != null)
{
if (seanEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;
}
}
else
{
iResult = -3;
}
}
else if (stroplb == "op_Apply")
{
MsOpApply topSeaiEntity = MsOpApplyDAL.GetData("BSNO='" + tempBSNO + "'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = MsOpApplyDAL.UnLockFeeStatus(tempBSNO);
if (iResult == 1)
{
topSeaiEntity = MsOpApplyDAL.GetData("BSNO='" + tempBSNO + "'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else if (stroplb == "op_Bulk")
{
MsOpBulk topSeaiEntity = MsOpBulkDAL.GetData("BSNO='" + tempBSNO + "'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = MsOpBulkDAL.UnLockFeeStatus(tempBSNO);
if (iResult == 1)
{
topSeaiEntity = MsOpBulkDAL.GetData("BSNO='" + tempBSNO + "'");
if (topSeaiEntity != null)
{
if (topSeaiEntity.BSNO != null)
{
if (topSeaiEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else if (stroplb == "op_Other")
{
MsOpOtherEntity MsOpOtherEntity = MsOpOtherDAL.GetData("BSNO='" + tempBSNO + "'");
if (MsOpOtherEntity != null)
{
if (MsOpOtherEntity.BSNO != null)
{
if (MsOpOtherEntity.FEESTATUS)
{
iResult = MsOpOtherDAL.UnLockFeeStatus(tempBSNO);
if (iResult == 1)
{
MsOpOtherEntity = MsOpOtherDAL.GetData("BSNO='" + tempBSNO + "'");
if (MsOpOtherEntity != null)
{
if (MsOpOtherEntity.BSNO != null)
{
if (MsOpOtherEntity.FEESTATUS)
{
iResult = 2;
}
else
{
iResult = 3;
}
}
}
}
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
else
{
iResult = -3;//委托业务费用没有加锁,不能执行解锁操作
}
}
return iResult;
}
#endregion
#region 禁开发票
/// <summary>
/// 禁开发票
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示加锁成功 值不等于1表示加锁失败</returns>
private int BatchLockFeeisinvoice(string tempGid)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
iResult = feeDA.LockFeeISINVOICE(tempGid);
return iResult;
}
#endregion
#region 解禁发票
/// <summary>
/// 解禁发票
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>值等于1表示解锁成功 值不等于1表示解锁失败</returns>
private int BatchUnLockFeeisinvoice(string tempGid)
{
int iResult = 0;
FeeDA feeDA = new FeeDA();
iResult = feeDA.UnLockFeeISINVOICE(tempGid);
return iResult;
}
#endregion
#region 查看是否有费用申请历史记录ch_fee_modify(费用申请修改表)
/// <summary>
/// 查看是否有费用申请历史记录ch_fee_modify(费用申请修改表)
/// </summary>
/// <param name="tempFeeID">费用GID</param>
/// <returns>值1表示存在 值不等于1表示不存在</returns>
private int IsExistFeeModify(string tempFeeID)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
IList<FeeModifyEntity> feeModifyEntities = new List<FeeModifyEntity>();
//获取费用申请更改历史记录ch_fee_modify(费用申请修改表)
feeModifyEntities = feeModifyDA.GetFeeModifyHistory(tempFeeID);
if (feeModifyEntities.Count > 0)
{
iResult = 1;
}
return iResult;
}
#endregion
private int ExistFeeModifyHistory(string strFeeGID)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
IList<FeeModifyEntity> feeModifyEntity = new List<FeeModifyEntity>();
feeModifyEntity = feeModifyDA.GetExistFeeModify(strFeeGID);
if (feeModifyEntity.Count > 0)
{
iResult = 1;
}
return iResult;
}
/// <summary>
/// 通过申请费用更改
/// </summary>
/// <param name="tempFeeID"></param>
/// <returns></returns>
private int ApplyModifyFee(string tempFeeID,int tempType)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
iResult = feeModifyDA.ApplyModifyPass(tempFeeID,strUserID);
return iResult;
}
private int ApplyRejectFee(string tempFeeID)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
iResult = feeModifyDA.ApplyModifyReject(tempFeeID,strUserID);
return iResult;
}
private int ApplyDeleteFee(string tempFeeID)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
iResult = feeModifyDA.ApplyDeletePass(tempFeeID,strUserID);
return iResult;
}
private int ApplyDeleteRejectFee(string tempFeeID)
{
int iResult = 0;
FeeModifyDA feeModifyDA = new FeeModifyDA();
iResult = feeModifyDA.ApplyDeleteReject(tempFeeID,strUserID);
return iResult;
}
/// <summary>
/// 根据handle类型执行更新操作更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息
/// 费用状态值 费用状态主要有11个状态,分别为审核通过STATUS=0录入状态STATUS=1提交审核STATUS=2申请修改 (STATUS=3)
/// 取消申请(STATUS=5)驳回提交STATUS=6驳回申请STATUS=7部分结算STATUS=8结算完毕STATUS=9
/// </summary>
/// <param name="tempHandle"></param>
/// <param name="strGid"></param>
/// <returns></returns>
private int ExcuteHandle(string tempHandle,string strGid)
{
int iResult = 0;
int iWorkFlowStatus = 0;
FeeDA feeDA = new FeeDA();
FeeEntity feeEntity = new FeeEntity();
//通过费用GID获取ch_fee费用信息
feeEntity = feeDA.GetFeeByID(strGid);
#region audit
if (tempHandle.ToLower().Equals("audit"))
{ //ch_fee费用信息的费用状态为1录入状态或6驳回提交
if (feeEntity.FeeStatus == 1 || feeEntity.FeeStatus == 6)
{
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//通过模块NAME获取工作流信息
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT,strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb == "op_Seae")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Seai")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Sean")//内贸应收应付费用审核
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpSeanRecvPayAudit, strCompanyID);
}
else if (stroplb == "op_Apply")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Bulk")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Other")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpOtherRecvPayAudit, strCompanyID);
}
if (workFlowEntity != null)
{
#region 原费用提交审核工作流_无事务
////根据Gid更新ch_fee.feestatus费用状态信息:为"提交审核"
//iResult = feeDA.UpdateFeeStatus(2, strGid);
//if (iResult == 1)
//{
// WorkFlowDoEntity workFlowDoEntity = null;
// WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
// //查看当前提交的应收应付费用审核已经进入工作流通过工作流GID和申请编号BILLNO获取工作流运行表WorkFlowDo信息
// workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
// if (workFlowDoEntity == null)
// {
// IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
// if (workFlowDoEntity.GID == null)
// {
// foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
// {
// //遍历所有工作流下步骤,获取第一步骤GID信息
// if (step.StepNO == 1)
// {
// if (step.IsDepartment)
// {
// string strDepartmentID = step.DepartmentID == null ? "" : step.DepartmentID;
// if (strDepartmentID.Trim() != null)
// {
// SysDeptDA sysDeptDA = new SysDeptDA();
// string strDeptID = sysDeptDA.GetDepartmentIdByUser(strUserID);
// if (strDeptID.Trim().Equals(strDepartmentID) && strDepartmentID != "")
// {
// WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
// initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
// initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
// initWorkFlowDoEntity.StepID = step.GID;
// initWorkFlowDoEntity.StepNO = step.StepNO;
// initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
// initWorkFlowDoEntity.FeeID = "";
// initWorkFlowDoEntity.BSNO = "";
// initWorkFlowDoEntity.FeeStatus = 0;
// initWorkFlowDoEntity.DoQuerySql = "";
// initWorkFlowDoEntity.BillNO = strGid;
// initWorkFlowDoEntity.IsFinish = false;
// initWorkFlowDoEntity.Applicant = strUserID;
// workFlowDoEntities.Add(initWorkFlowDoEntity);
// }
// }
// }
// else
// {
// WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
// initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
// initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
// initWorkFlowDoEntity.StepID = step.GID;
// initWorkFlowDoEntity.StepNO = step.StepNO;
// initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
// initWorkFlowDoEntity.FeeID = "";
// initWorkFlowDoEntity.BSNO = "";
// initWorkFlowDoEntity.FeeStatus = 0;
// initWorkFlowDoEntity.DoQuerySql = "";
// initWorkFlowDoEntity.BillNO = strGid;
// initWorkFlowDoEntity.IsFinish = false;
// initWorkFlowDoEntity.Applicant = strUserID;
// workFlowDoEntities.Add(initWorkFlowDoEntity);
// }
// }
// }
// //插入WorkFlowDo信息
// iWorkFlowStatus = workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
// if (iWorkFlowStatus == 1)
// {
// int iTempStatus = feeDA.UpdateFeeAuditStatus(strGid, 1);
// if (iTempStatus != 1)
// {
// iResult = -5;//更新费用状态失败
// }
// #region
// //else
// //{
// // //状态完成后发送通知消息
// // IList<MessageEntity> messageEntities = new List<MessageEntity>();
// // MessageDA messageDA = new MessageDA();
// // foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
// // {
// // MessageEntity messageEntity = new MessageEntity();
// // messageEntity.GID = Guid.NewGuid().ToString();
// // messageEntity.Name = "FeeAudit";
// // messageEntity.Description = "应收应付审核通知";
// // messageEntity.IsRead = false;
// // messageEntity.ReadCount = 0;
// // messageEntity.MessageContent = strShowName + " 提交 " + (feeEntity.FeeType == 1 ? "应收费用" : "应付费用") + "[" + feeEntity.FeeName + "]费用 应收应付审核 ";
// // messageEntity.TaskID = workFlowDo.BillNO;
// // messageEntity.Receiver = workFlowDo.Auditor;
// // messageEntity.TaskUrl = messageEntity.TaskUrl = "auditprocess/feeaudit.aspx";
// // messageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
// // messageEntities.Add(messageEntity);
// // }
// // if (messageEntities.Count > 0)
// // {
// // messageDA.CreateMessage(MessageType.FEEAUDIT, messageEntities);
// // }
// //}
// #endregion
// }
// }
// }
// else
// {
// IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
// if (workFlowDoEntity.GID == null)
// {
// foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
// {
// //遍历所有工作流下步骤,获取第一步骤GID信息
// if (step.StepNO == 1)
// {
// if (step.IsDepartment)
// {
// string strDepartmentID = step.DepartmentID == null ? "" : step.DepartmentID;
// if (strDepartmentID.Trim() != null)
// {
// SysDeptDA sysDeptDA = new SysDeptDA();
// string strDeptID = sysDeptDA.GetDepartmentIdByUser(strUserID);
// if (strDeptID.Trim().Equals(strDepartmentID) && strDepartmentID != "")
// {
// WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
// initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
// initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
// initWorkFlowDoEntity.StepID = step.GID;
// initWorkFlowDoEntity.StepNO = step.StepNO;
// initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
// initWorkFlowDoEntity.FeeID = "";
// initWorkFlowDoEntity.BSNO = "";
// initWorkFlowDoEntity.FeeStatus = 0;
// initWorkFlowDoEntity.DoQuerySql = "";
// initWorkFlowDoEntity.BillNO = strGid;
// initWorkFlowDoEntity.IsFinish = false;
// initWorkFlowDoEntity.Applicant = strUserID;
// workFlowDoEntities.Add(initWorkFlowDoEntity);
// }
// }
// }
// else
// {
// WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
// initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
// initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
// initWorkFlowDoEntity.StepID = step.GID;
// initWorkFlowDoEntity.StepNO = step.StepNO;
// initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
// initWorkFlowDoEntity.FeeID = "";
// initWorkFlowDoEntity.BSNO = "";
// initWorkFlowDoEntity.FeeStatus = 0;
// initWorkFlowDoEntity.DoQuerySql = "";
// initWorkFlowDoEntity.BillNO = strGid;
// initWorkFlowDoEntity.IsFinish = false;
// initWorkFlowDoEntity.Applicant = strUserID;
// workFlowDoEntities.Add(initWorkFlowDoEntity);
// }
// }
// }
// iWorkFlowStatus = workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
// if (iWorkFlowStatus == 1)
// {
// int iTempStatus = feeDA.UpdateFeeAuditStatus(strGid, 1);
// if (iTempStatus != 1)
// {
// iResult = -5;//更新费用状态失败
// }
// #region 注释
// //else
// //{
// // //状态完成后发送通知消息
// // IList<MessageEntity> messageEntities = new List<MessageEntity>();
// // MessageDA messageDA = new MessageDA();
// // foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
// // {
// // MessageEntity messageEntity = new MessageEntity();
// // messageEntity.GID = Guid.NewGuid().ToString();
// // messageEntity.Name = "FeeAudit";
// // messageEntity.Description = "应收应付审核通知";
// // messageEntity.IsRead = false;
// // messageEntity.ReadCount = 0;
// // messageEntity.MessageContent = strShowName + " 提交 " + (feeEntity.FeeType == 1 ? "应收费用" : "应付费用") + "[" + feeEntity.FeeName + "]费用 应收应付审核 ";
// // messageEntity.TaskID = workFlowDo.BillNO;
// // messageEntity.Receiver = workFlowDo.Auditor;
// // messageEntity.TaskUrl = "auditprocess/feeaudit.aspx";
// // messageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
// // messageEntities.Add(messageEntity);
// // }
// // if (messageEntities.Count > 0)
// // {
// // messageDA.CreateMessage(MessageType.FEEAUDIT, messageEntities);
// // }
// //}
// #endregion
// }
// }
// }
//}
#endregion
#region 费用提交审核工作流_有事务
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
iResult = workFlowDoDA.FeeAudit(workFlowEntity, strGid, strUserID);
#endregion
}
else
{
//因未走工作流所以根据Gid更新ch_fee.feestatus费用状态信息:为"审核通过"
iResult = feeDA.UpdateFeeStatus(0, strGid);
if (iResult == 1)
{
iResult = 10;//未走工作流,自动审核通过
}
}
}
else
{
iResult = -1;
}
}
#endregion
#region auditpass
if (tempHandle.ToLower().Equals("auditpass"))
{
if (feeEntity.FeeStatus == 2)
{
//iResult = feeDA.UpdateFeeStatus(0, strGid);
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//查找付费工作流信息
//WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT,strCompanyID);
WorkFlowEntity workFlowEntity = new WorkFlowEntity();
if (stroplb == "op_Seae")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Seai")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiFEEAUDIT, strCompanyID);
}
else if (stroplb == "wms_out")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.WmsOutFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Sean")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpSeanRecvPayAudit,strCompanyID);
}
else if (stroplb == "op_Apply")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Bulk")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Other")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpOtherRecvPayAudit, strCompanyID);
}
//如果工作流信息存在
if (workFlowEntity != null)
{
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
//先查看是否当前付费申请已经进入工作流
workFlowDoEntities = workFlowDoDA.GetAllWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
if (workFlowDoEntities.Count > 0)
{
int iCount = 0;
//如果付费申请已经进入工作流,先判断当前打开付费审核页面操作人是否是工作流内相关审核人,如果是则
foreach (WorkFlowDoEntity workFlowDoEntity in workFlowDoEntities)
{
//查看当前操作人是否为审核人
if (workFlowDoEntity.Auditor == strUserID)
{
iCount++;
//查看当前审核人所处的步骤是否已经完成
if (!workFlowDoEntity.IsFinish)
{
//iResult等于1表示工作执行操作成功
iResult = workFlowHelper.DoWorkFlowStep(workFlowDoEntity, workFlowEntity);
if (iResult == 1)
{
//遍历工作流步骤信息,如果是工作流步骤最后一步,表示审核通过则置ch_fee审核通过
foreach (WorkFlowStepEntity workFlowStepEntity in workFlowEntity.WorkFlowSteps)
{
if (workFlowStepEntity.StepNO == workFlowDoEntity.StepNO)
{
if (workFlowStepEntity.IsLast)
{
int iTempStatus = feeDA.UpdateFeeStatus(0, strGid);
if (iTempStatus != 1)
{
iResult = -5;//更新费用状态失败
}
if (iTempStatus == 1)
{
feeEntity = feeDA.GetFeeByID(strGid);
iResult = feeEntity.FeeStatus;
}
}
}
}
}
break;
}
else if (workFlowDoEntity.IsFinish)
{
iResult = -4;//付费审核步骤已经完成,不能重复审核
break;
}
}
}
if (iCount == 0)
{
iResult = -3;//没有权利审核付费
}
}
}
}
else
{
iResult = -1;
}
}
#endregion
#region reject
if (tempHandle.ToLower().Equals("reject"))
{
if (feeEntity.FeeStatus == 2 || feeEntity.FeeStatus == 5 || feeEntity.FeeStatus == 0)
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
int iCount = int.Parse(T_ALL_DA.GetStrSQL("hj", "select count(*) as hj from ch_fee_do where (ISDELETED=0 or ISDELETED is null) and feeid='" + strGid + "'"));
if (iCount > 0 && feeEntity.FeeStatus == 0)
{
return -10;//注:已经做收付费申请或发票申请的费用,不允许驳回申请!
}
//
FeeDoDA feeDoDA = new FeeDoDA();
IList<FeeDoEntity> feeDoEntities = new List<FeeDoEntity>();
feeDoEntities = feeDoDA.GetFeeDoByBillNO(strGid);
//工作流
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//查找付费工作流信息
WorkFlowEntity workFlowEntity =new WorkFlowEntity();
if (stroplb == "op_Seae")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Seai")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Sean")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpSeanRecvPayAudit,strCompanyID);
}
else if (stroplb == "op_Apply")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.APPLYFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Bulk")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.BULKFEEAUDIT, strCompanyID);
}
else if (stroplb == "op_Other")
{
workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.FeeOpOtherRecvPayAudit, strCompanyID);
}
//如果工作流信息存在
if (workFlowEntity != null)
{
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
//先查看是否当前付费申请已经进入工作流
workFlowDoEntities = workFlowDoDA.GetAllWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
if (workFlowDoEntities.Count > 0)
{
//如果付费申请已经进入工作流,先判断当前打开付费审核页面操作人是否是工作流内相关审核人,如果是则
foreach (WorkFlowDoEntity workFlowDoEntity in workFlowDoEntities)
{
//查看当前操作人是否为审核人
if (workFlowDoEntity.Auditor == strUserID)
{
workFlowDoEntity.IsFinish = true;
workFlowDoEntity.IsDelete = true;
workFlowDoEntity.DeleteStep = workFlowDoEntity.StepID;
workFlowDoEntity.DeleteOperator = strUserID;
workFlowDoEntity.DeleteStepNO = workFlowDoEntity.StepNO;
workFlowDoEntity.IsFinish = true;
int iTempRejectStatus = workFlowHelper.DoWorkFlowReject(workFlowDoEntity, WorkFlowType.FEEAUDIT, feeDoEntities,strGid,strCompanyID);
if (iTempRejectStatus == 1)
{
int iFeeStatus = feeDA.UpdateFeeStatus(6, strGid);
if (iFeeStatus == 1)
{
feeEntity = feeDA.GetFeeByID(strGid);
iResult = feeEntity.FeeStatus;
}
else
{
iResult = -5;//费用状态更新失败
}
}
else
{
iResult = -4;//工作流审核驳回失败
}
}
}
}
}
}
#region 注释
////如果FeeStatus状态是申请修改 (STATUS=3) 取消申请(STATUS=5) 则状态更新驳回申请
//if (feeEntity.FeeStatus == 3 || feeEntity.FeeStatus == 5)
//{
// iResult = feeDA.UpdateFeeStatus(7, strGid);
//}
//else if (feeEntity.FeeStatus == 2 || feeEntity.FeeStatus == 0)
//{
// iResult = feeDA.UpdateFeeStatus(6, strGid);
//}
//else
//{
// iResult = -1;
//}
#endregion
}
#endregion
#region seaiaudit
if (tempHandle.ToLower().Equals("seaiaudit"))
{ //ch_fee费用信息的费用状态为1录入状态或6驳回提交
if (feeEntity.FeeStatus == 1 || feeEntity.FeeStatus == 6)
{ //根据Gid更新ch_fee.feestatus费用状态信息:为"提交审核"
iResult = feeDA.UpdateFeeStatus(2, strGid);
if (iResult == 1)
{
WorkFlowHelper workFlowHelper = new WorkFlowHelper();
//通过模块NAME获取工作流信息
WorkFlowEntity workFlowEntity = workFlowHelper.FindWorkFlow(WorkFlowType.SeaiFEEAUDIT, strCompanyID);
if (workFlowEntity != null)
{
WorkFlowDoEntity workFlowDoEntity = null;
WorkFlowDoDA workFlowDoDA = new WorkFlowDoDA();
//查看当前提交的应收应付费用审核已经进入工作流通过工作流GID和申请编号BILLNO获取工作流运行表WorkFlowDo信息
workFlowDoEntity = workFlowDoDA.GetSigleWorkFlowDoByBillNO(workFlowEntity.GID, strGid);
if (workFlowDoEntity == null)
{
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
if (workFlowDoEntity.GID == null)
{
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
//遍历所有工作流下步骤,获取第一步骤GID信息
if (step.StepNO == 1)
{
if (step.IsDepartment)
{
string strDepartmentID = step.DepartmentID == null ? "" : step.DepartmentID;
if (strDepartmentID.Trim() != null)
{
SysDeptDA sysDeptDA = new SysDeptDA();
string strDeptID = sysDeptDA.GetDepartmentIdByUser(strUserID);
if (strDeptID.Trim().Equals(strDepartmentID) && strDepartmentID != "")
{
WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
initWorkFlowDoEntity.StepID = step.GID;
initWorkFlowDoEntity.StepNO = step.StepNO;
initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
initWorkFlowDoEntity.FeeID = "";
initWorkFlowDoEntity.BSNO = "";
initWorkFlowDoEntity.FeeStatus = 0;
initWorkFlowDoEntity.DoQuerySql = "";
initWorkFlowDoEntity.BillNO = strGid;
initWorkFlowDoEntity.IsFinish = false;
initWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(initWorkFlowDoEntity);
}
}
}
else
{
WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
initWorkFlowDoEntity.StepID = step.GID;
initWorkFlowDoEntity.StepNO = step.StepNO;
initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
initWorkFlowDoEntity.FeeID = "";
initWorkFlowDoEntity.BSNO = "";
initWorkFlowDoEntity.FeeStatus = 0;
initWorkFlowDoEntity.DoQuerySql = "";
initWorkFlowDoEntity.BillNO = strGid;
initWorkFlowDoEntity.IsFinish = false;
initWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(initWorkFlowDoEntity);
}
}
}
//插入WorkFlowDo信息
iWorkFlowStatus = workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
if (iWorkFlowStatus == 1)
{
int iTempStatus = feeDA.UpdateFeeAuditStatus(strGid, 1);
if (iTempStatus != 1)
{
iResult = -5;//更新费用状态失败
}
#region
//else
//{
// //状态完成后发送通知消息
// IList<MessageEntity> messageEntities = new List<MessageEntity>();
// MessageDA messageDA = new MessageDA();
// foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
// {
// MessageEntity messageEntity = new MessageEntity();
// messageEntity.GID = Guid.NewGuid().ToString();
// messageEntity.Name = "FeeAudit";
// messageEntity.Description = "应收应付审核通知";
// messageEntity.IsRead = false;
// messageEntity.ReadCount = 0;
// messageEntity.MessageContent = strShowName + " 提交 " + (feeEntity.FeeType == 1 ? "应收费用" : "应付费用") + "[" + feeEntity.FeeName + "]费用 应收应付审核 ";
// messageEntity.TaskID = workFlowDo.BillNO;
// messageEntity.Receiver = workFlowDo.Auditor;
// messageEntity.TaskUrl = messageEntity.TaskUrl = "auditprocess/feeaudit.aspx";
// messageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
// messageEntities.Add(messageEntity);
// }
// if (messageEntities.Count > 0)
// {
// messageDA.CreateMessage(MessageType.FEEAUDIT, messageEntities);
// }
//}
#endregion
}
}
}
else
{
IList<WorkFlowDoEntity> workFlowDoEntities = new List<WorkFlowDoEntity>();
if (workFlowDoEntity.GID == null)
{
foreach (WorkFlowStepEntity step in workFlowEntity.WorkFlowSteps)
{
//遍历所有工作流下步骤,获取第一步骤GID信息
if (step.StepNO == 1)
{
if (step.IsDepartment)
{
string strDepartmentID = step.DepartmentID == null ? "" : step.DepartmentID;
if (strDepartmentID.Trim() != null)
{
SysDeptDA sysDeptDA = new SysDeptDA();
string strDeptID = sysDeptDA.GetDepartmentIdByUser(strUserID);
if (strDeptID.Trim().Equals(strDepartmentID) && strDepartmentID != "")
{
WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
initWorkFlowDoEntity.StepID = step.GID;
initWorkFlowDoEntity.StepNO = step.StepNO;
initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
initWorkFlowDoEntity.FeeID = "";
initWorkFlowDoEntity.BSNO = "";
initWorkFlowDoEntity.FeeStatus = 0;
initWorkFlowDoEntity.DoQuerySql = "";
initWorkFlowDoEntity.BillNO = strGid;
initWorkFlowDoEntity.IsFinish = false;
initWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(initWorkFlowDoEntity);
}
}
}
else
{
WorkFlowDoEntity initWorkFlowDoEntity = new WorkFlowDoEntity();
initWorkFlowDoEntity.GID = Guid.NewGuid().ToString();
initWorkFlowDoEntity.WorkFlowID = workFlowEntity.GID;
initWorkFlowDoEntity.StepID = step.GID;
initWorkFlowDoEntity.StepNO = step.StepNO;
initWorkFlowDoEntity.Auditor = step.Auditor == null ? step.DefaultAuditor : step.Auditor;
initWorkFlowDoEntity.FeeID = "";
initWorkFlowDoEntity.BSNO = "";
initWorkFlowDoEntity.FeeStatus = 0;
initWorkFlowDoEntity.DoQuerySql = "";
initWorkFlowDoEntity.BillNO = strGid;
initWorkFlowDoEntity.IsFinish = false;
initWorkFlowDoEntity.Applicant = strUserID;
workFlowDoEntities.Add(initWorkFlowDoEntity);
}
}
}
iWorkFlowStatus = workFlowDoDA.InsertWorkFlowDo(workFlowDoEntities);
if (iWorkFlowStatus == 1)
{
int iTempStatus = feeDA.UpdateFeeAuditStatus(strGid, 1);
if (iTempStatus != 1)
{
iResult = -5;//更新费用状态失败
}
#region 注释
//else
//{
// //状态完成后发送通知消息
// IList<MessageEntity> messageEntities = new List<MessageEntity>();
// MessageDA messageDA = new MessageDA();
// foreach (WorkFlowDoEntity workFlowDo in workFlowDoEntities)
// {
// MessageEntity messageEntity = new MessageEntity();
// messageEntity.GID = Guid.NewGuid().ToString();
// messageEntity.Name = "FeeAudit";
// messageEntity.Description = "应收应付审核通知";
// messageEntity.IsRead = false;
// messageEntity.ReadCount = 0;
// messageEntity.MessageContent = strShowName + " 提交 " + (feeEntity.FeeType == 1 ? "应收费用" : "应付费用") + "[" + feeEntity.FeeName + "]费用 应收应付审核 ";
// messageEntity.TaskID = workFlowDo.BillNO;
// messageEntity.Receiver = workFlowDo.Auditor;
// messageEntity.TaskUrl = "auditprocess/feeaudit.aspx";
// messageEntity.Type = messageDA.GetMessageType(MessageType.FEEAUDIT);
// messageEntities.Add(messageEntity);
// }
// if (messageEntities.Count > 0)
// {
// messageDA.CreateMessage(MessageType.FEEAUDIT, messageEntities);
// }
//}
#endregion
}
}
}
}
}
}
else
{
iResult = -1;
}
}
#endregion
return iResult;
}
/// <summary>
/// 更改单复制委托信息
/// </summary>
/// <param name="tempBSNO">委托业务编号</param>
/// <returns>插入状态</returns>
private string ExcuteModifyByCopy(string tempBSNO)
{
TopSeaeEntity topSeaeEntity;
int iResult = 0;
SeaExportInfoDA seaExportDA = new SeaExportInfoDA();
topSeaeEntity = seaExportDA.GetID(tempBSNO);
if (topSeaeEntity.BSNO != null)
{
IList<TopSeaeEntity> topSeaeEntities = new List<TopSeaeEntity>();
topSeaeEntities.Add(topSeaeEntity);
//复制委托信息
TopSeaeEntity newTopSeaeEntity = seaExportDA.GetID(tempBSNO);
//产生新的委托业务编号
newTopSeaeEntity.BSNO = "topseae" + Guid.NewGuid().ToString().Replace("-", "");
topSeaeEntities.Add(newTopSeaeEntity);
AmendDA amendDA = new AmendDA();
IList<AmendEntity> amendEntities = new List<AmendEntity>();
for(int i = 0;i<topSeaeEntities.Count;i++)
{
AmendEntity amendEntity = new AmendEntity();
amendEntity.GID = Guid.NewGuid().ToString();
amendEntity.BSNO = topSeaeEntities[i].BSNO;
//amendEntity.ACCDate = DateTime.MinValue;
amendEntity.ParentID = topSeaeEntities[0].BSNO;
amendEntity.CreateUser = strUserID;
amendEntity.FeeStatus = 1;
amendEntity.Reason = "";
amendEntity.Remarks = "";
amendEntities.Add(amendEntity);
}
iResult = amendDA.InsertAmends(amendEntities);
if (iResult > 0)
{
//复制一条记录到
iResult = seaExportDA.InserInfo(newTopSeaeEntity);
}
}
return iResult.ToString();
}
#region 注释
//public string ExcuteApplyModifyFee(string tempFeeGID,string tempBSNO)
//{
// TopSeaeEntity topSeaeEntity;
// int iResult = 0;
// SeaExportInfoDA seaExportDA = new SeaExportInfoDA();
// topSeaeEntity = seaExportDA.GetID(tempBSNO);
// if (topSeaeEntity.BSNO != null)
// {
// if (topSeaeEntity.FEESTATUS.Trim().Equals("未锁定"))
// {
// FeeModifyDA feeModifyDA = new FeeModifyDA();
// IList<FeeModifyEntity> feeModifyEntities = new List<FeeModifyEntity>();
// }
// }
//}
//public string ExcuteApplyDeleteFee()
//{
// TopSeaeEntity topSeaeEntity;
// int iResult = 0;
// SeaExportInfoDA seaExportDA = new SeaExportInfoDA();
// topSeaeEntity = seaExportDA.GetID(tempBSNO);
// if (topSeaeEntity.BSNO != null)
// {
// if (topSeaeEntity.FEESTATUS.Trim().Equals("未锁定"))
// {
// FeeModifyDA feeModifyDA = new FeeModifyDA();
// IList<FeeModifyEntity>
// }
// }
//}
#endregion
}
}