80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using Dapper;
|
|
using dccdc.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class InfectionMenuDal
|
|
{
|
|
public List<InfectionMenuModel> getMenuInfection()
|
|
{
|
|
//throw new NotImplementedException();
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select * from infection_menu";
|
|
return conn.Query<InfectionMenuModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public List<InfectionMenuModel> getSJCDInfection()
|
|
{
|
|
|
|
//var dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select id,name from infection_menu where pid=0";
|
|
return conn.Query<InfectionMenuModel>(sql).ToList();
|
|
}
|
|
}
|
|
|
|
public object saveCDInfection(InfectionMenuModel m)
|
|
{
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
//throw new NotImplementedException();
|
|
string sql = "";
|
|
if (m.id == 0)
|
|
{
|
|
sql = "insert into infection_menu(name,pid,cdlx,url,[key])values(@name,@pid,@cdlx,@url,@key)";
|
|
}
|
|
else
|
|
{
|
|
sql = "update infection_menu set name=@name,pid=@pid,cdlx=@cdlx,url=@url,[key]=@key where id=@id";
|
|
}
|
|
conn.Execute(sql, m);
|
|
return new
|
|
{
|
|
State = 1,
|
|
Message = "成功"
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object delCDInfection(int id)
|
|
{
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select count(1) from infection_menu where pid=" + id;
|
|
if (conn.ExecuteScalar<int>(sql) != 0)
|
|
{
|
|
return new { State = 0, Message = "不能删除有下级菜单的项目!" };
|
|
}
|
|
sql = "delete from infection_menu where id=" + id;
|
|
conn.Execute(sql);
|
|
return new { State = 1, Message = "删除成功!" };
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|