46 lines
1.5 KiB
C#
46 lines
1.5 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 sqdyDal
|
|||
|
|
{
|
|||
|
|
public List<sqdyModel> GetListByType(string type)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<sqdyModel>("select * from sqdy where 1=1 and type=@type", new { @type = type }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string Add(sqdyModel model)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
var result = conn.Query<sqdyModel>("select * from sqdy where 1=1 and type=@type and hblx=@hblx and hbid=@hbid", new { @type = model.type, @hblx = model.hblx, @hbid = model.hbid }).ToList();
|
|||
|
|
if (result == null || result.Count == 0)
|
|||
|
|
{
|
|||
|
|
string sql = @"INSERT INTO [dccdc].[dbo].[sqdy]
|
|||
|
|
([type]
|
|||
|
|
,[hblx]
|
|||
|
|
,[hbid])
|
|||
|
|
VALUES
|
|||
|
|
(@type
|
|||
|
|
,@hblx
|
|||
|
|
,@hbid)";
|
|||
|
|
var result2 = conn.Execute(sql, model);
|
|||
|
|
return result2.ToString();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
return "1";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|