136 lines
3.5 KiB
C#
136 lines
3.5 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using dccdc.Models;
|
|||
|
|
using Dapper;
|
|||
|
|
|
|||
|
|
namespace dccdc.DAL
|
|||
|
|
{
|
|||
|
|
public class crbsjDal
|
|||
|
|
{
|
|||
|
|
public List<crbsjModel> GetAllList(string id, string stauts)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string param = "";
|
|||
|
|
if (id != "")
|
|||
|
|
{
|
|||
|
|
param = " and id =@id";
|
|||
|
|
}
|
|||
|
|
if (stauts != "")
|
|||
|
|
{
|
|||
|
|
param += " and status=@stauts";
|
|||
|
|
}
|
|||
|
|
return conn.Query<crbsjModel>("select * from crbsj where 1=1" + param, new { @id = id, @stauts = stauts }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int getCount(string key)
|
|||
|
|
{
|
|||
|
|
string sql = "select count(1) from dbo.crbsj where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and hzxm like @charge_method";
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql, new { charge_method = "%" + key + "%" });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<crbsjModel> getList(int page, int pagesize, string key)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select *,row_number() over(order by id) as rownum from crbsj where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and hzxm like @charge_method";
|
|||
|
|
}
|
|||
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.crbsjModel>(sql, new { charge_method = "%" + key + "%" }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object save(crbsjModel cpm, ERPUser user)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
cpm.drr = user.TrueName;
|
|||
|
|
cpm.drsj = DateTime.Now;
|
|||
|
|
string sql = "";
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
sql = "select count(1) from crbsj where kpdm=@kpdm";
|
|||
|
|
int c1 = conn.ExecuteScalar<int>(sql, new { kpdm = cpm.kpdm });
|
|||
|
|
if (c1 > 0)
|
|||
|
|
return new { State = 1, Message = "重复数据跳过!" }; ;
|
|||
|
|
sql = @"INSERT INTO [dbo].[crbsj]
|
|||
|
|
([kpdm],
|
|||
|
|
[hzxm],
|
|||
|
|
[jzxm],
|
|||
|
|
[yxzjh],
|
|||
|
|
[xb],
|
|||
|
|
[csrq],
|
|||
|
|
[nl],
|
|||
|
|
[gzdw],
|
|||
|
|
[lxdh],
|
|||
|
|
[zzbm],
|
|||
|
|
[xxzz],
|
|||
|
|
[rqfl],
|
|||
|
|
[zd],
|
|||
|
|
[zdsj],
|
|||
|
|
[tkys],
|
|||
|
|
[bgdw],
|
|||
|
|
[bklrsj],
|
|||
|
|
[drsj],
|
|||
|
|
[drr]
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(@kpdm,
|
|||
|
|
@hzxm,
|
|||
|
|
@jzxm,
|
|||
|
|
@yxzjh,
|
|||
|
|
@xb,
|
|||
|
|
@csrq,
|
|||
|
|
@nl,
|
|||
|
|
@gzdw,
|
|||
|
|
@lxdh,
|
|||
|
|
@zzbm,
|
|||
|
|
@xxzz,
|
|||
|
|
@rqfl,
|
|||
|
|
@zd,
|
|||
|
|
@zdsj,
|
|||
|
|
@tkys,
|
|||
|
|
@bgdw,
|
|||
|
|
@bklrsj,
|
|||
|
|
@drsj,
|
|||
|
|
@drr
|
|||
|
|
)
|
|||
|
|
";
|
|||
|
|
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int c = conn.Execute(sql, cpm);
|
|||
|
|
if (c > 0)
|
|||
|
|
{
|
|||
|
|
return new { State = 1, Message = "保存成功!" };
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = ex.Message };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|