107 lines
3.5 KiB
C#
107 lines
3.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 sqshDal
|
|||
|
|
{
|
|||
|
|
public List<sqshModel> GetAllTreeList()
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<sqshModel>("select * from sqsh", new { @zt = 1 }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public List<sqshModel> GetAllList()
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<sqshModel>("select * from sqsh where zt=1 ").ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<sqshModel> GetListByKey(string type,string sqid)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = "select * from sqsh where type=@type and sqid =@sqid";
|
|||
|
|
return conn.Query<sqshModel>(sql, new { type = type, sqid = sqid }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public sqshModel GetmodelByName(string name)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
List<sqshModel> model = conn.Query<sqshModel>("select * from sqsh where title=@name", new { name = name }).ToList();
|
|||
|
|
if (model.Any())
|
|||
|
|
{
|
|||
|
|
return model[0];
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<sqshModel> GetAllList(string id)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string param = "";
|
|||
|
|
if (id != "")
|
|||
|
|
{
|
|||
|
|
param = " and id=@id";
|
|||
|
|
}
|
|||
|
|
return conn.Query<sqshModel>("select * from sqsh where 1=1" + param, new { @id = id }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool Add(sqshModel model)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = @"INSERT INTO [dbo].[sqsh]
|
|||
|
|
([type]
|
|||
|
|
,[sqid]
|
|||
|
|
,[spr]
|
|||
|
|
,[sptime]
|
|||
|
|
,[spnr]
|
|||
|
|
,[zt]
|
|||
|
|
,[spzw])
|
|||
|
|
VALUES
|
|||
|
|
(@type
|
|||
|
|
,@sqid
|
|||
|
|
,@spr
|
|||
|
|
,@sptime
|
|||
|
|
,@spnr
|
|||
|
|
,@zt
|
|||
|
|
,@spzw)";
|
|||
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool Update(sqshModel model)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string sql = @"UPDATE [dbo].[sqsh]
|
|||
|
|
SET [type] = @type
|
|||
|
|
,[sqid] = @sqid
|
|||
|
|
,[spr] = @spr
|
|||
|
|
,[sptime] = @sptime
|
|||
|
|
,[spnr] = @spnr
|
|||
|
|
,[zt] = @zt
|
|||
|
|
,[spzw] = @spzw
|
|||
|
|
WHERE id=@id";
|
|||
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|