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 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=36 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(",jk.SALECORPID,(select [NAME] from [company] where GID=jk.SALECORPID) as SALECORP,0 BALAMOUNT"); 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 List GetDataListZC(string strCondition) { //借款单列表 var strSql = new StringBuilder(); strSql.Append(" SELECT *,ISNULL(AMOUNT,0)-ISNULL(RMBAMOUNT_SETTLEMENT,0)-ISNULL(USDAMOUNT_SETTLEMENT,0)-ISNULL(OTHERAMOUNT_SETTLEMENT,0) AS BALAMOUNT FROM ("); strSql.Append(" select jk.GID,jk.ENTEROPERATOR,u.showname,dbo.trimdate(jk.ENTERDATE) ENTERDATE,jk.COMPANYID,jk.DEPTID,jk.AMOUNT,jk.JKSTATUS"); strSql.Append(" ,jk.STLAMOUNT"); strSql.Append(" ,sd.deptname,jk.ISDELETE,jk.DELETEUSER,jk.DELETETIME,jk.bsno"); //strSql.Append(" , as JKSTATUS_Ref "); strSql.Append(" ,jk.JKTYPE,JK.OP,JK.CURRENCY,JK.REASON"); strSql.Append(" ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=36 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,'' 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(",jk.SALECORPID,(select [NAME] from [company] where GID=jk.SALECORPID) as SALECORP"); strSql.Append(",(select case when (sum(AMOUNT)-SUM(SETTLEMENT))=0 and (sum(AMOUNT)!=0) then '结算完毕'" + " else (select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=jk.JKSTATUS) end from ch_fee where JKGID=jk.GID) as JKSTATUS_Ref"); 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); } strSql.Append(" ) AS V "); return SetData(strSql); } static public string GetDataListStr(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=36 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(",jk.SALECORPID,(select [NAME] from [company] where GID=jk.SALECORPID) as SALECORP"); 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 strSql.ToString(); } static public Jiekuan2mb GetData(string condition) { var list = GetDataList(condition); if (list.Count > 0) return list[0]; return new Jiekuan2mb(); } private static List SetData(StringBuilder strSql) { var headList = new List(); 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"]); if (reader["TimeMark"] != DBNull.Value) 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"]); if (reader["STLAMOUNT"] != DBNull.Value) data.STLAMOUNT = Convert.ToDecimal(reader["STLAMOUNT"]); if (reader["RMBAMOUNT_SETTLEMENT"] != DBNull.Value) 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"]); data.SALECORP = Convert.ToString(reader["SALECORP"]); data.SALECORPID = Convert.ToString(reader["SALECORPID"]); if (reader["BALAMOUNT"] != DBNull.Value) data.BALAMOUNT = Convert.ToDecimal(reader["BALAMOUNT"]); #endregion headList.Add(data); } reader.Close(); } return headList; } #endregion static public List GetJieKuan2Body(string condition) { var strSql = new StringBuilder(); strSql.Append(" select GID,JKGID,BXGID,c.PaymentGID,c.CUSTOMERNAME "); strSql.Append(" ,FEETYPE,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=c.FeeType) FEETYPE_REF "); strSql.Append(" ,c.FEESTATUS,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=c.FeeStatus) FEESTATUS_REF "); strSql.Append(" ,c.BSNO,FEENAME,CURRENCY,AMOUNT,NOTAXAMOUNT,EXCHANGERATE,c.MODIFIEDUSER,c.MODIFIEDTIME,c.Remark,SETTLEMENT,SALESNO,F_NO,C.UNIT "); strSql.Append(" ,B.MBLNO MBLNO,B.CUSTOMERNAME CUSTNAME,B.CNTRTOTAL,B.CUSTNO,B.GOODSNAME,c.FEEDESCRIPTION,c.TAXRATE,c.CARGO_GID "); strSql.Append(" from ch_fee c "); strSql.Append(" left join V_OP_BILL b on b.bsno=c.BSNO ");//where billno='" + BILLNO + "' "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } return SetJieKuan2Body(strSql); } static public List GetJieKuanZCBody(string condition) { var strSql = new StringBuilder(); strSql.Append(" select GID,JKGID,BXGID,c.PaymentGID,c.CUSTOMERNAME "); strSql.Append(" ,FEETYPE,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=c.FeeType) FEETYPE_REF "); strSql.Append(" ,c.FEESTATUS,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=c.FeeStatus) FEESTATUS_REF "); strSql.Append(" ,c.BSNO,FEENAME,CURRENCY,AMOUNT,NOTAXAMOUNT,EXCHANGERATE,c.MODIFIEDUSER,c.MODIFIEDTIME,c.Remark,SETTLEMENT,SALESNO,F_NO,C.UNIT "); strSql.Append(" ,B.MBLNO MBLNO,B.CUSTOMERNAME CUSTNAME,B.CNTRTOTAL,B.CUSTNO,B.GOODSNAME,c.FEEDESCRIPTION,c.TAXRATE,c.CARGO_GID "); strSql.Append(" from ch_fee c "); strSql.Append(" left join V_OP_BILL b on b.bsno=c.PaymentGID ");//where billno='" + BILLNO + "' "); if (!string.IsNullOrEmpty(condition)) { strSql.Append(" where " + condition); } return SetJieKuan2Body(strSql); } private static List SetJieKuan2Body ( StringBuilder strSql ) { var headList = new List(); 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.PaymentGID = Convert.ToString(reader["PaymentGID"]); 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"]); if (reader["NOTAXAMOUNT"] != DBNull.Value) data.NOTAXAMOUNT = Convert.ToDecimal(reader["NOTAXAMOUNT"]); 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.CARGO_GID = Convert.ToString(reader["CARGO_GID"]); data.MBLNO = Convert.ToString(reader["MBLNO"]); data.BSNO = Convert.ToString(reader["BSNO"]); data.CUSTNAME = Convert.ToString(reader["CUSTNAME"]); data.CUSTNO = Convert.ToString(reader["CUSTNO"]); data.CNTRTOTAL = Convert.ToString(reader["CNTRTOTAL"]); data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]); data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]); data.UNIT = Convert.ToString(reader["UNIT"]); data.FEEDESCRIPTION = Convert.ToString(reader["FEEDESCRIPTION"]); if (reader["TAXRATE"] != DBNull.Value) data.TAXRATE = Convert.ToDecimal(reader["TAXRATE"]); if (data.TAXRATE == 0) data.TAX = 0; else data.TAX = Math.Round(data.AMOUNT - data.NOTAXAMOUNT, 2, MidpointRounding.AwayFromZero); #endregion headList.Add(data); } reader.Close(); } return headList; } #region 明细部分 #endregion #region 工作流审核 借款 public static DBResult SubmitAuditNew( String USERID, List 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 ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; } else {//其他直接结算完毕 费用审核通过 _Comm = " update OA_JieKuan set JKSTATUS=0 where GID=@GID "; _Comm = _Comm+ " update ch_fee set FeeSTATUS=9 where ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; } } else { _Comm = " update OA_JieKuan set JKSTATUS=2 where GID=@GID "; _Comm = _Comm + " update ch_fee set FeeSTATUS=2 where ISNULL(JKGID,'')<>'' AND 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 SubmitAuditBackNew(String USERID, List 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.WorkFlowReset(WorkFlowName, _J.GID, USERID); if (WorkResult.Success == true) { var _Comm = ""; //if (_J.JKTYPE != "0")//空白支票 费用审核通过 //{ _Comm = " update OA_JieKuan set JKSTATUS=1 where GID=@GID "; _Comm = _Comm + " update ch_fee set FeeSTATUS=1 where ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; //} //else //{//其他直接结算完毕 费用审核通过 // _Comm = " update OA_JieKuan set JKSTATUS=0 where GID=@GID "; // _Comm = _Comm + " update ch_fee set FeeSTATUS=9 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 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 ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; } else {//其他直接结算完毕 费用审核通过 _Comm = "update OA_JieKuan set JKSTATUS=0 where GID=@GID "; _Comm = _Comm + "update ch_fee set FeeSTATUS=9 where ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; } } else //审核未完成 { _Comm = "update ch_fee set FEESTATUS=2 where GID=@GID"; _Comm = _Comm + "update ch_fee set FeeSTATUS=2 where ISNULL(JKGID,'')<>'' AND 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 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 ISNULL(JKGID,'')<>'' AND 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 public static DBResult AuditZC(String USERID, List 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)//审核完成 { _Comm = "update OA_JieKuan set JKSTATUS=0 where GID=@GID "; _Comm = _Comm + "update ch_fee set FeeSTATUS=0 where ISNULL(JKGID,'')<>'' AND JKGID=@GID2 "; } else //审核未完成 { _Comm = "update ch_fee set FEESTATUS=2 where GID=@GID"; _Comm = _Comm + "update ch_fee set FeeSTATUS=2 where ISNULL(JKGID,'')<>'' AND 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; } } internal class MsChFeeDealException : Exception { internal MsChFeeDealException(string message) : base(message) { } } }