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/MvcShipping/DAL/MsMessTip/MsMessTipDAL.cs

91 lines
6.2 KiB
C#

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsMessTip;
using DSWeb.MvcShipping.Models.MsTemplet;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using System.IO;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
namespace DSWeb.MvcShipping.DAL.MsMessTip
{
public class MsMessTipDAL
{
static public List<MsMessTipModel> GetMessTip(string userid)
{
var strSql = new StringBuilder();
strSql.AppendLine("SELECT ");
strSql.AppendLine("(select count(*) from v_op_bill where EXISTS (select 1 from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID where v_op_bill.BSNO=ch_fee.BSNO and ch_fee.FEESTATUS in (2,3,4) and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0)) as RECEXPENSE,");
strSql.AppendLine("(select count(*) FROM ch_fee_payapplication i left join workflow_using wu on wu.bsno=i.billno where i.BILLSTATUS in (2,3) and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0) as RECPAYMENT,");
strSql.AppendLine("(select count(*) FROM ch_fee_invoiceapplication i left join workflow_using wu on wu.bsno=i.billno where i.BILLSTATUS=2 and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0) as RECINVOICE,");
strSql.AppendLine("(select count(*) from op_ctnbscard where EXISTS (select 1 from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID where op_ctnbscard.GID=ch_fee.BSNO and ch_fee.FEESTATUS in (2,3,4) and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0)) as CHFEEAUDIT,");
strSql.AppendLine("(select count(*) from op_blissuelist ob left join workflow_using wu on wu.bsno=ob.BSNO where dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0) as INDEXSP,");
strSql.AppendLine("(case when (select COUNT(*) from user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyGoodsAudit') and USERID='" + userid + "')=0 then (select COUNT(*) from user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyGoodsAudit') and USERID='" + userid + "') else (select COUNT(*) from op_ctnapply where AUDITSTATUS='提交审核') end) as GOODSAUDIT, ");
strSql.AppendLine("(case when (select count(*) FROM user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyCostIndex') and USERID='"+userid+"')=0 then (select count(*) FROM user_action WHERE ACTIONID in (select GID from action where [NAME]='modCtnApplyCostIndex') and USERID='"+userid+"') else (select count(*) from op_ctnapply where COSTAUDITSTATUS='提交审核') end) as COSTAUDIT, ");
strSql.AppendLine("(select count(*) from v_op_bill where EXISTS (select 1 from ch_fee left join workflow_using wu on wu.bsno=ch_fee.GID where v_op_bill.BSNO=ch_fee.BSNO and ch_fee.FEESTATUS in (2,3,4) and (wu.FINISHED=0 or wu.FINISHED is null) and op='"+userid+"')) as SENEXPENSE,");
strSql.AppendLine("(select count(*) FROM ch_fee_payapplication i left join workflow_using wu on wu.bsno=i.billno where i.BILLSTATUS in (2,3) and (wu.FINISHED=0 or wu.FINISHED is null) and op='"+userid+"') as SENPAYMENT,");
strSql.AppendLine("(select count(*) FROM ch_fee_invoiceapplication i left join workflow_using wu on wu.bsno=i.billno where i.BILLSTATUS=2 and i.BILLSTATUS=2 and (wu.FINISHED=0 or wu.FINISHED is null) and op='"+userid+"') as SENINVOICE");
return SetData(strSql);
}
private static List<MsMessTipModel> SetData(StringBuilder strSql)
{
var headList = new List<MsMessTipModel>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsMessTipModel data = new MsMessTipModel();
#region Set DB data to Object
data.RECEXPENSE = Convert.ToString(reader["RECEXPENSE"]);//待审核 费用审核
data.RECPAYMENT = Convert.ToString(reader["RECPAYMENT"]);//待审核 付费申请
data.RECINVOICE = Convert.ToString(reader["RECINVOICE"]);//待审核 发票申请
data.SENEXPENSE = Convert.ToString(reader["SENEXPENSE"]);//已提交未审核 费用审核
data.SENPAYMENT = Convert.ToString(reader["SENPAYMENT"]);//已提交未审核 付费申请
data.SENINVOICE = Convert.ToString(reader["SENINVOICE"]);//已提交未审核 发票申请
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 查询模板地址
public static List<MsTempletStructure> GetTempletURL(string gid, string companyid)
{
List<MsTempletStructure> list = new List<MsTempletStructure>();
StringBuilder sql = new StringBuilder();
//sql.AppendLine("select top 1 TEMPLETURL from templet where TEMPLETID='" + gid + "'");
sql.AppendLine("select distinct B.GID,A.TEMPLETURL ");
sql.AppendLine("from templet as A ");
sql.AppendLine("left join user_templet as B on A.TEMPLETID=B.TEMPLETID ");
sql.AppendLine("where A.TEMPLETID='" + gid + "' and B.LINKURL='.' and B.COMPANYID='" + companyid + "' ");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql.ToString()))
{
while (reader.Read())
{
MsTempletStructure data = new MsTempletStructure();
data.GID = Convert.ToString(reader["GID"]);
data.LINKURL = Convert.ToString(reader["TEMPLETURL"]);
list.Add(data);
}
reader.Close();
}
return list;
}
#endregion
}
}