134 lines
4.3 KiB
C#
134 lines
4.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Dapper;
|
|
using System.Data;
|
|
using dccdc.Models;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class special_companyDal
|
|
{
|
|
internal List<Models.special_companyModel> getKYList()
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "select * from special_company where status='是'";
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<Models.special_companyModel>(sql).ToList();
|
|
}
|
|
|
|
}
|
|
|
|
public int getCount(string company_name)
|
|
{
|
|
string sql = "select count(1) from dbo.special_company where 1=1";
|
|
if (!string.IsNullOrEmpty(company_name))
|
|
{
|
|
sql += " and company_name like @company_name";
|
|
}
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.ExecuteScalar<int>(sql, new { company_name = "%" + company_name + "%" });
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据名称获取不可维护企业列表
|
|
/// </summary>
|
|
/// <param name="page"></param>
|
|
/// <param name="pagesize"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public List<special_companyModel> getList(int page, int pagesize, string company_name)
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "select *,row_number() over(order by id desc) as rownum from special_company where 1=1";
|
|
if (!string.IsNullOrEmpty(company_name))
|
|
{
|
|
sql += " and company_name like @company_name";
|
|
}
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<Models.special_companyModel>(sql, new { company_name = "%" + company_name + "%" }).ToList();
|
|
}
|
|
}
|
|
public object save(special_companyModel cpm)
|
|
{
|
|
string sql = "";
|
|
if (cpm.id == 0)
|
|
{
|
|
sql = @"INSERT INTO [dbo].[special_company]
|
|
([company_name],
|
|
[status]
|
|
)
|
|
VALUES
|
|
(@company_name,
|
|
@status
|
|
)
|
|
";
|
|
}
|
|
else
|
|
{
|
|
sql = @"UPDATE [dbo].[special_company]
|
|
SET [company_name]=@company_name,
|
|
[status]=@status
|
|
WHERE id=@id
|
|
";
|
|
}
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
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 };
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id删除特殊企业
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public object del(string id)
|
|
{
|
|
string sql = @"delete special_company where id=@id";
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int c = conn.Execute(sql, new { id = id });
|
|
if (c > 0)
|
|
{
|
|
return new { State = 1, Message = "操作成功!" };
|
|
}
|
|
else
|
|
{
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|