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.
426 lines
18 KiB
C#
426 lines
18 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Data.Common;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.Areas.OA.Models.Jiekuan;
|
|
using DSWeb.Areas.OA.Models.Comm;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using HcUtility.Comm;
|
|
using DSWeb.MvcShipping.DAL.MsSysParamSet;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
|
|
namespace DSWeb.Areas.OA.DAL.Jiekuan2
|
|
{
|
|
public partial class Jiekuan2DAL
|
|
{
|
|
#region 借款单列表
|
|
|
|
static public List<Jiekuan2mb> GetDataList ( string strCondition )
|
|
{ //借款单列表
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" select jk.GID,jk.ENTEROPERATOR,u.showname,dbo.trimdate(jk.ENTERDATE) ENTERDATE,jk.COMPANYID,jk.DEPTID,jk.AMOUNT");
|
|
strSql.Append(" ,jk.STLAMOUNT");
|
|
strSql.Append(" ,sd.deptname,jk.ISDELETE,jk.DELETEUSER,jk.DELETETIME,jk.bsno,jk.JKSTATUS");
|
|
strSql.Append(" ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=jk.JKSTATUS) as JKSTATUS_Ref ");
|
|
|
|
strSql.Append(" ,jk.JKTYPE,JK.OP,JK.CURRENCY,JK.REASON");
|
|
strSql.Append(" ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=33 and EnumValueID=jk.JKTYPE) as JKTYPE_Ref ");
|
|
strSql.Append(" ,jk.remark remark,jk.remark+dbo.JK_Remark(jk.GID) remarkAll");
|
|
strSql.Append(" ,convert(bigint ,jk.TimeMark) as TimeMark");
|
|
strSql.Append(" ,jk.RMBAMOUNT,jk.USDAMOUNT,jk.OTHERAMOUNT,jk.CHEQUENO");
|
|
strSql.Append(" ,jk.RMBAMOUNT_SETTLEMENT,jk.USDAMOUNT_SETTLEMENT,jk.OTHERAMOUNT_SETTLEMENT");
|
|
strSql.Append(" ,dbo.trimdate(EXREPAYDATE) EXREPAYDATE,dbo.BX_SETTINFO(jk.GID) SETTINFO ");
|
|
strSql.Append(" ,(select showname from vw_user where userid=(select top 1 auditor from workflow_do where billno=jk.GID order by AUDITTIME DESC )) auditor");
|
|
strSql.Append(" ,(select top 1 dbo.trimtime(AUDITTIME) from workflow_do where billno=jk.GID order by AUDITTIME DESC ) audittime");
|
|
strSql.Append(" FROM VW_Jiekuan jk ");
|
|
strSql.Append("left join sys_dept sd on sd.gid=jk.deptid ");
|
|
strSql.Append("left join [user] u on u.gid=jk.ENTEROPERATOR ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public Jiekuan2mb GetData(string condition)
|
|
{
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new Jiekuan2mb();
|
|
}
|
|
|
|
private static List<Jiekuan2mb> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<Jiekuan2mb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Jiekuan2mb data = new Jiekuan2mb();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.ENTEROPERATOR = Convert.ToString(reader["ENTEROPERATOR"]);
|
|
data.ENTERDATE = Convert.ToString(reader["ENTERDATE"]);
|
|
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
|
|
data.DEPTID = Convert.ToString(reader["DEPTID"]);
|
|
data.DEPTNAME = Convert.ToString(reader["DEPTNAME"]);
|
|
//data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
|
|
data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]);
|
|
data.DELETETIME = Convert.ToString(reader["DELETETIME"]);
|
|
data.SHOWNAME = Convert.ToString(reader["SHOWNAME"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
data.JKTYPE = Convert.ToString(reader["JKTYPE"]);
|
|
data.JKTYPE_REF = Convert.ToString(reader["JKTYPE_Ref"]);
|
|
data.JKSTATUS = Convert.ToString(reader["JKSTATUS"]);
|
|
data.JKSTATUS_REF = Convert.ToString(reader["JKSTATUS_REF"]);
|
|
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.REMARKALL = Convert.ToString(reader["remarkAll"]);
|
|
data.RMBAMOUNT = Convert.ToString(reader["RMBAMOUNT"]);
|
|
data.USDAMOUNT = Convert.ToString(reader["USDAMOUNT"]);
|
|
data.OTHERAMOUNT = Convert.ToString(reader["OTHERAMOUNT"]);
|
|
|
|
data.CHEQUENO = Convert.ToString(reader["CHEQUENO"]);
|
|
data.OP = Convert.ToString(reader["OP"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
data.CHEQUENO = Convert.ToString(reader["CHEQUENO"]);
|
|
data.AMOUNT = Convert.ToString(reader["AMOUNT"]);
|
|
data.STLAMOUNT = Convert.ToDecimal(reader["STLAMOUNT"]);
|
|
data.RMBAMOUNT_SETTLEMENT = Convert.ToString(reader["RMBAMOUNT_SETTLEMENT"]);
|
|
data.USDAMOUNT_SETTLEMENT = Convert.ToString(reader["USDAMOUNT_SETTLEMENT"]);
|
|
data.OTHERAMOUNT_SETTLEMENT = Convert.ToString(reader["OTHERAMOUNT_SETTLEMENT"]);
|
|
|
|
data.EXREPAYDATE = Convert.ToString(reader["EXREPAYDATE"]);
|
|
data.SETTINFO = Convert.ToString(reader["SETTINFO"]);
|
|
|
|
data.AUDITOR = Convert.ToString(reader["AUDITOR"]);
|
|
data.AUDITTIME = Convert.ToString(reader["AUDITTIME"]);
|
|
data.REASON = Convert.ToString(reader["REASON"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
static public List<Jiekuan2Bodymb> GetJieKuan2Body(string condition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append(" select GID,JKGID,BXGID ");
|
|
strSql.Append(" ,FEETYPE,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=FeeType) FEETYPE_REF ");
|
|
strSql.Append(" ,FEESTATUS,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=FeeStatus) FEESTATUS_REF ");
|
|
strSql.Append(" ,BSNO,FEENAME,CURRENCY,AMOUNT,EXCHANGERATE,MODIFIEDUSER,MODIFIEDTIME,Remark,SETTLEMENT,SALESNO,F_NO ");
|
|
strSql.Append(" ,(SELECT TOP 1 MBLNO FROM V_OP_BILL WHERE BSNO=C.BSNO) MBLNO ");
|
|
strSql.Append(" from ch_fee c ");
|
|
//strSql.Append(" left join vw_settlement vs on vs.bsno=cfc.MAKETIMEUPPER ");//where billno='" + BILLNO + "' ");
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" where " + condition);
|
|
}
|
|
return SetJieKuan2Body(strSql);
|
|
}
|
|
|
|
private static List<Jiekuan2Bodymb> SetJieKuan2Body ( StringBuilder strSql )
|
|
{
|
|
var headList = new List<Jiekuan2Bodymb>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Jiekuan2Bodymb data = new Jiekuan2Bodymb();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.JKGID = Convert.ToString(reader["JKGID"]);
|
|
data.BXGID = Convert.ToString(reader["BXGID"]);
|
|
data.FEETYPE = Convert.ToString(reader["FEETYPE"]);
|
|
data.FEETYPE_REF = Convert.ToString(reader["FEETYPE_REF"]);
|
|
data.FEESTATUS = Convert.ToString(reader["FEESTATUS"]);
|
|
data.FEESTATUS_REF = Convert.ToString(reader["FEESTATUS_REF"]);
|
|
data.SALESNO = Convert.ToString(reader["SALESNO"]);
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
if (reader["AMOUNT"] != DBNull.Value)
|
|
data.AMOUNT = Convert.ToDecimal(reader["AMOUNT"]);
|
|
data.SETTLEMENT = Convert.ToDecimal(reader["SETTLEMENT"]);
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
if (reader["EXCHANGERATE"] != DBNull.Value)
|
|
data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
data.F_NO = Convert.ToString(reader["F_NO"]);
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#region 明细部分
|
|
|
|
|
|
#endregion
|
|
|
|
#region 工作流审核 借款
|
|
|
|
public static DBResult SubmitAuditNew( String USERID, List<Jiekuan2mb> billList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var WorkFlowName = "JieKuanAudit";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
|
|
foreach (var _J in billList)
|
|
{
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(WorkFlowName, _J.GID, USERID,_J.BILLNO,_J.GID,"");
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var _Comm = "";
|
|
if (WorkResult.islast == true)
|
|
{
|
|
if (_J.JKTYPE != "0")//空白支票 费用审核通过
|
|
{
|
|
_Comm = " update OA_JieKuan set JKSTATUS=0 where GID=@GID ";
|
|
_Comm = _Comm+" update ch_fee set FeeSTATUS=0 where JKGID=@GID2 ";
|
|
}
|
|
else
|
|
{//其他直接结算完毕 费用审核通过
|
|
_Comm = " update OA_JieKuan set JKSTATUS=0 where GID=@GID ";
|
|
_Comm = _Comm+" update ch_fee set FeeSTATUS=9 where JKGID=@GID2 ";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_Comm = " update OA_JieKuan set JKSTATUS=2 where GID=@GID ";
|
|
_Comm = _Comm + " update ch_fee set FeeSTATUS=2 where JKGID=@GID2 ";
|
|
}
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _J.GID);
|
|
db.AddInParameter(cmdupdate, "@GID2", DbType.String, _J.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误!";
|
|
}
|
|
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交审核成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult Audit( String USERID, List<Jiekuan2mb> billList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var WorkFlowName = "JieKuanAudit";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
foreach (var _J in billList)
|
|
{
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, _J.GID, USERID,_J.BILLNO);
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
var _Comm = "";
|
|
if (WorkResult.islast == true)//审核完成
|
|
{
|
|
if (_J.JKTYPE != "0")//空白支票 费用审核通过
|
|
{
|
|
_Comm = "update OA_JieKuan set JKSTATUS=0 where GID=@GID ";
|
|
_Comm = _Comm + "update ch_fee set FeeSTATUS=0 where JKGID=@GID2 ";
|
|
}
|
|
else
|
|
{//其他直接结算完毕 费用审核通过
|
|
_Comm = "update OA_JieKuan set JKSTATUS=0 where GID=@GID ";
|
|
_Comm = _Comm + "update ch_fee set FeeSTATUS=9 where JKGID=@GID2 ";
|
|
}
|
|
}
|
|
else //审核未完成
|
|
{
|
|
_Comm = "update ch_fee set FEESTATUS=2 where GID=@GID";
|
|
_Comm = _Comm + "update ch_fee set FeeSTATUS=2 where JKGID=@GID2 ";
|
|
}
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _J.GID);
|
|
db.AddInParameter(cmdupdate, "@GID2", DbType.String, _J.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
result.Success = false;
|
|
result.Message = "审核错误!";
|
|
}
|
|
}
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "审核成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "审核错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult AuditBack(String USERID, List<Jiekuan2mb> billList, string reasean)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var WorkFlowName = "JieKuanAudit";
|
|
|
|
var i = 0;
|
|
|
|
result.Success = true;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
foreach (var _J in billList)
|
|
{
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, _J.GID, USERID, "");
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
|
|
var _Comm = "";
|
|
|
|
_Comm = " update OA_JieKuan set JKSTATUS=6 where GID=@GID ";
|
|
_Comm = _Comm + " update ch_fee set FeeSTATUS=6 where JKGID=@GID2 ";
|
|
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, _J.GID);
|
|
db.AddInParameter(cmdupdate, "@GID2", DbType.String, _J.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
}
|
|
else
|
|
{
|
|
i = i + 1;
|
|
result.Success = WorkResult.Success;
|
|
result.Message = WorkResult.Message;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (result.Success == true)
|
|
{
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "驳回提交成功";
|
|
tran.Commit();
|
|
}
|
|
else
|
|
{
|
|
result.Success = true;
|
|
result.Message = "驳回完成,其中" + i.ToString() + "票驳回错误,错误信息" + result.Message;
|
|
|
|
tran.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "驳回提交错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
internal class MsChFeeDealException : Exception
|
|
{
|
|
internal MsChFeeDealException(string message)
|
|
: base(message)
|
|
{
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|