229 lines
7.8 KiB
C#
229 lines
7.8 KiB
C#
|
|
using Dapper;
|
|||
|
|
using dccdc.Models;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace dccdc.DAL
|
|||
|
|
{
|
|||
|
|
public class SbjfwwhDLL
|
|||
|
|
{
|
|||
|
|
public List<JfSjfwwxgl> getJfSjfwwxglxx(JfSjfwwxgl jfsjfwwxgl, int page, int pagesize)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String strsql = "select a.*,row_number() over(order by id) as rownum,"
|
|||
|
|
+ "(select TOP 1 BM.BuMenName FROM OA..ERPBuMen BM WHERE BM.ID = A.KSID) KSMC"+
|
|||
|
|
",(select TOP 1 U.TrueName FROM OA..ERPUser U WHERE U.ID = A.sqrid) SQRMC" +
|
|||
|
|
" from jf_sbjfwwxgl a where 1 =1 ";
|
|||
|
|
if (jfsjfwwxgl.zt != null)
|
|||
|
|
{
|
|||
|
|
strsql += " and zt=@zt ";
|
|||
|
|
}
|
|||
|
|
if (jfsjfwwxgl.sqrid != 0)
|
|||
|
|
{
|
|||
|
|
strsql += " and sqrid=@sqrid";
|
|||
|
|
}
|
|||
|
|
if (jfsjfwwxgl.sqsj != null)
|
|||
|
|
{
|
|||
|
|
strsql += " and sqsj=@sqsj";
|
|||
|
|
}
|
|||
|
|
if (jfsjfwwxgl.ksid !=null&& jfsjfwwxgl.ksid !=0)
|
|||
|
|
{
|
|||
|
|
strsql += " and ksid = @ksid" ;
|
|||
|
|
}
|
|||
|
|
strsql = "select * from (" + strsql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
return conn.Query<JfSjfwwxgl>(strsql, jfsjfwwxgl).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int count(JfSjfwwxgl jfsjfwwxgl)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String strsql = "select count(1) from jf_sbjfwwxgl where ksid = @ksid";
|
|||
|
|
if (jfsjfwwxgl.zt != null)
|
|||
|
|
{
|
|||
|
|
strsql += " and zt=@zt ";
|
|||
|
|
}
|
|||
|
|
if (jfsjfwwxgl.sqrid != 0)
|
|||
|
|
{
|
|||
|
|
strsql += " and sqrid=@sqrid";
|
|||
|
|
}
|
|||
|
|
return conn.ExecuteScalar<int>(strsql, jfsjfwwxgl);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<JfSjfwwxgl> getspJfSjfwwxglxx(string ksidstr, string ztstr, int page, int pagesize)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String strsql = "select a.*,row_number() over(order by id) as rownum,"
|
|||
|
|
+ "(select TOP 1 BM.BuMenName FROM OA..ERPBuMen BM WHERE BM.ID = A.KSID) KSMC" +
|
|||
|
|
",(select TOP 1 U.TrueName FROM OA..ERPUser U WHERE U.ID = A.sqrid) SQRMC" +
|
|||
|
|
" from jf_sbjfwwxgl a where 1 =1 ";
|
|||
|
|
|
|||
|
|
if (ztstr != null && ztstr != "")
|
|||
|
|
{
|
|||
|
|
strsql += ztstr;
|
|||
|
|
}else
|
|||
|
|
{
|
|||
|
|
strsql += "AND 1=2";
|
|||
|
|
}
|
|||
|
|
strsql = "select * from (" + strsql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
return conn.Query<JfSjfwwxgl>(strsql).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int countspsbjfwwh(string ksidstr, string ztstr)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String strsql = "select count(1) from jf_sbjfwwxgl where 1 =1";
|
|||
|
|
|
|||
|
|
if (ztstr != null && ztstr != "")
|
|||
|
|
{
|
|||
|
|
strsql += ztstr;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
strsql += "AND 1=2";
|
|||
|
|
}
|
|||
|
|
return conn.ExecuteScalar<int>(strsql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<JfSjfwwxgl> getJfSjfwwxglxxOne(JfSjfwwxgl jfsjfwwxgl)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String strsql = "select a.*,"
|
|||
|
|
+ "(select TOP 1 BM.BuMenName FROM OA..ERPBuMen BM WHERE BM.ID = A.KSID) KSMC" +
|
|||
|
|
",(select TOP 1 U.TrueName FROM OA..ERPUser U WHERE U.ID = A.sqrid) SQRMC" +
|
|||
|
|
" from jf_sbjfwwxgl a where id=@id";
|
|||
|
|
return conn.Query<JfSjfwwxgl>(strsql, jfsjfwwxgl).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool delJfSjfwwxglxx(JfSjfwwxgl jfsjfwwxgl)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
String sql = "delete from jf_sbjfwwxgl where id=@id";
|
|||
|
|
return (conn.Execute(sql, jfsjfwwxgl) != 0 ? true : false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool addJfSjfwwxglxx(JfSjfwwxgl jfsjfwwxgl)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = @"INSERT INTO [jf_sbjfwwxgl]
|
|||
|
|
([sbfwwxid]
|
|||
|
|
,[ksid]
|
|||
|
|
,[sqrid]
|
|||
|
|
,[sqsj]
|
|||
|
|
,[wxly]
|
|||
|
|
,[wxnr]
|
|||
|
|
,[sxfy]
|
|||
|
|
,[jfly]
|
|||
|
|
,[bz]
|
|||
|
|
,[glsqd]
|
|||
|
|
,[szydsqd]
|
|||
|
|
,[zt]
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(@sbfwwxid
|
|||
|
|
,@ksid
|
|||
|
|
,@sqrid
|
|||
|
|
,@sqsj
|
|||
|
|
,@wxly
|
|||
|
|
,@wxnr
|
|||
|
|
,@sxfy
|
|||
|
|
,@jfly
|
|||
|
|
,@bz
|
|||
|
|
,@glsqd
|
|||
|
|
,@szydsqd
|
|||
|
|
,@zt)";
|
|||
|
|
return (conn.Execute(sql, jfsjfwwxgl) != 0 ? true : false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool updJfSjfwwxglxx(JfSjfwwxgl jfsjfwwxgl)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = @"update [jf_sbjfwwxgl]
|
|||
|
|
set [wxly]=@wxly
|
|||
|
|
,[wxnr]=@wxnr
|
|||
|
|
,[sxfy]=@sxfy
|
|||
|
|
,[jfly]=@jfly
|
|||
|
|
,[bz]=@bz
|
|||
|
|
,[glsqd]=@glsqd
|
|||
|
|
,[szydsqd] =@szydsqd
|
|||
|
|
,[zt]=@zt
|
|||
|
|
,[ksldspyj]=@ksldspyj
|
|||
|
|
,[ksldsprq]=@ksldsprq
|
|||
|
|
,[fgldspyj]=@fgldspyj
|
|||
|
|
,[fgldsprq]=@fgldsprq
|
|||
|
|
,[zxldspyj]=@zxldspyj
|
|||
|
|
,[zxldsprq]=@zxldsprq where id = @id";
|
|||
|
|
return (conn.Execute(sql, jfsjfwwxgl) != 0 ? true : false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int getCountLevel(string where)
|
|||
|
|
{
|
|||
|
|
string sql = "select count(1) from dbo.jf_sbjfwwxgl where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(where))
|
|||
|
|
{
|
|||
|
|
sql += where;
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<JfSjfwwxgl> getPageLevel(int page, int pagesize, string where)
|
|||
|
|
{
|
|||
|
|
string sql = "select *,row_number() over(order by id desc) as rownum from jf_sbjfwwxgl where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(where))
|
|||
|
|
{
|
|||
|
|
sql += where;
|
|||
|
|
}
|
|||
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.JfSjfwwxgl>(sql).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public int counterpnm(ERPBuMenModel erpbm)
|
|||
|
|
{
|
|||
|
|
string sql = "select count(1) from dbo.ERPBuMen where 1=1";
|
|||
|
|
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection("OADB"))
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<ERPBuMenModel> geterpbm(int page, int pagesize, ERPBuMenModel erpbm)
|
|||
|
|
{
|
|||
|
|
string sql = "select *,row_number() over(order by id desc) as rownum from [ERPBuMen] where 1=1";
|
|||
|
|
|
|||
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection("OADB"))
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.ERPBuMenModel>(sql).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|