|
|
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;
|
|
|
|
|
|
namespace DSWeb.Areas.OA.DAL.Jiekuan
|
|
|
{
|
|
|
public partial class JiekuanDAL
|
|
|
{
|
|
|
#region 借款单列表
|
|
|
|
|
|
static public List<Jiekuanmb> 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(" ,sd.deptname,jk.ISDELETE,jk.DELETEUSER,jk.DELETETIME,jk.bsno,vs.CUSTNO,vs.MBLNO,jk.JKSTATUS");
|
|
|
strSql.Append(" ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=jk.JKSTATUS) as JKSTATUS_Ref ");
|
|
|
//strSql.Append(" ,(select dbo.GetRemain_ZWC (jk.deptid,jk.enterdate)) remain,jk.remark");
|
|
|
strSql.Append(" ,'' remain,jk.remark");
|
|
|
strSql.Append(" FROM OA_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 ");
|
|
|
strSql.Append("left join vw_settlement vs on vs.bsno=jk.bsno ");
|
|
|
strSql.Append(" where (jk.isdelete=0 or jk.isdelete is null) ");
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
{
|
|
|
strSql.Append(" and " + strCondition);
|
|
|
}
|
|
|
return SetData(strSql);
|
|
|
}
|
|
|
|
|
|
static public Jiekuanmb GetData(string condition)
|
|
|
{
|
|
|
var list = GetDataList(condition);
|
|
|
if (list.Count > 0)
|
|
|
return list[0];
|
|
|
|
|
|
return new Jiekuanmb();
|
|
|
}
|
|
|
|
|
|
private static List<Jiekuanmb> SetData(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<Jiekuanmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
Jiekuanmb data = new Jiekuanmb();
|
|
|
#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.ToString(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.CUSTNO = Convert.ToString(reader["CUSTNO"]);
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
|
|
|
data.JKSTATUS = Convert.ToString(reader["JKSTATUS"]);
|
|
|
data.JKSTATUS_REF = Convert.ToString(reader["JKSTATUS_REF"]);
|
|
|
data.REMAIN = Convert.ToString(reader["REMAIN"]);
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
|
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
static public List<CHEQUEmb> GetCHEQUE(string condition)
|
|
|
{
|
|
|
var strSql = new StringBuilder();
|
|
|
strSql.Append(" select GID,BILLNO,CHEQUENO,CHEQUEAMOUNT,CHEQUEAMOUNTUPPER,MAKETIMEUPPER,PASSWORD,ModifiedTime, ");
|
|
|
strSql.Append(" dbo.trimdate(CHEQUEMAKETIME) CHEQUEMAKETIME,PRINTTIME,PRINTUSER,PURPOSE,CHEQUECUSTNAME,vs.MBLNO,cfc.customername ");
|
|
|
strSql.Append(" from ch_fee_cheque cfc ");
|
|
|
strSql.Append(" left join vw_settlement vs on vs.bsno=cfc.MAKETIMEUPPER ");//where billno='" + BILLNO + "' ");
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
|
{
|
|
|
strSql.Append(" where " + condition);
|
|
|
}
|
|
|
return SetDataCHEQUE(strSql);
|
|
|
}
|
|
|
|
|
|
private static List<CHEQUEmb> SetDataCHEQUE(StringBuilder strSql)
|
|
|
{
|
|
|
var headList = new List<CHEQUEmb>();
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
{
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
CHEQUEmb data = new CHEQUEmb();
|
|
|
#region Set DB data to Object
|
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
|
data.BILLNO = Convert.ToString(reader["BILLNO"]);
|
|
|
data.CHEQUECUSTNAME = Convert.ToString(reader["CHEQUECUSTNAME"]);
|
|
|
data.MAKETIMEUPPER = Convert.ToString(reader["MAKETIMEUPPER"]);
|
|
|
data.MBLNO = Convert.ToString(reader["MBLNO"]);
|
|
|
data.CHEQUENO = Convert.ToString(reader["CHEQUENO"]);
|
|
|
data.CHEQUEAMOUNTUPPER = Convert.ToString(reader["CHEQUEAMOUNTUPPER"]);
|
|
|
data.CHEQUEAMOUNT = Convert.ToString(reader["CHEQUEAMOUNT"]);
|
|
|
data.PASSWORD = Convert.ToString(reader["PASSWORD"]);
|
|
|
data.CHEQUEMAKETIME = Convert.ToString(reader["CHEQUEMAKETIME"]);
|
|
|
data.PRINTTIME = Convert.ToString(reader["PRINTTIME"]);
|
|
|
data.PRINTUSER = Convert.ToString(reader["PRINTUSER"]);
|
|
|
data.PURPOSE = Convert.ToString(reader["PURPOSE"]);
|
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
|
data.ModifiedTime = Convert.ToString(reader["ModifiedTime"]);
|
|
|
#endregion
|
|
|
headList.Add(data);
|
|
|
}
|
|
|
reader.Close();
|
|
|
}
|
|
|
return headList;
|
|
|
}
|
|
|
|
|
|
|
|
|
#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<Jiekuanmb> JiekuanList)
|
|
|
{
|
|
|
var result = new DBResult();
|
|
|
|
|
|
foreach (var JK in JiekuanList)
|
|
|
{
|
|
|
var status = int.Parse(JK.JKSTATUS);
|
|
|
var canAudit = true;
|
|
|
var GID = JK.GID;
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
|
var updateSql = " update OA_Jiekuan set JKStatus=@JKStatus where GID=@GID ";
|
|
|
|
|
|
const string enumSql =
|
|
|
"select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=@EnumValueID";
|
|
|
|
|
|
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 JK in JiekuanList)
|
|
|
{
|
|
|
var cmdUpdate = db.GetSqlStringCommand(updateSql);
|
|
|
db.AddInParameter(cmdUpdate, "@JKStatus", DbType.Int32, newStatus);
|
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, JK.GID);
|
|
|
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)
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|