142 lines
5.0 KiB
C#
142 lines
5.0 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 MedicalSchemeMaintainDal
|
|
{
|
|
public List<MedicalSchemeMaintainModel> GetAllTreeList()
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return conn.Query<MedicalSchemeMaintainModel>("select * from medical_scheme_maintain", new { @status = "是" }).ToList();
|
|
}
|
|
}
|
|
public List<MedicalSchemeMaintainModel> GetAllList()
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
|
|
return conn.Query<MedicalSchemeMaintainModel>("select * from medical_scheme_maintain where status='是' ").ToList();
|
|
}
|
|
}
|
|
|
|
public List<MedicalSchemeMaintainModel> GetAllListByCrowd()
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
|
|
return conn.Query<MedicalSchemeMaintainModel>("select * from medical_scheme_maintain where status='是' and medical_scheme in (Select name From infection_open_crowd Where isOpen = 1) ").ToList();
|
|
}
|
|
}
|
|
|
|
public MedicalSchemeMaintainModel GetmodelByName(string name)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
List<MedicalSchemeMaintainModel> model = conn
|
|
.Query<MedicalSchemeMaintainModel>("select * from medical_scheme_maintain where medical_scheme=@name",
|
|
new { name = name }).ToList();
|
|
if (model.Any())
|
|
{
|
|
return model[0];
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id获取体检方案列表
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public List<MedicalSchemeMaintainModel> GetAllList(string id)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string param = "";
|
|
if (id != "")
|
|
{
|
|
param = " and id=@id";
|
|
}
|
|
return conn.Query<MedicalSchemeMaintainModel>("select * from medical_scheme_maintain where 1=1" + param+ " order by id desc", new { @id = id }).ToList();
|
|
}
|
|
}
|
|
|
|
public bool Add(MedicalSchemeMaintainModel model)
|
|
{
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = @"INSERT INTO [medical_scheme_maintain]
|
|
([code]
|
|
,[medical_scheme]
|
|
,[status]
|
|
,[creator]
|
|
,isCharge
|
|
,[create_time])
|
|
VALUES
|
|
(@code
|
|
,@medical_scheme
|
|
,@status
|
|
,@creator
|
|
,@isCharge
|
|
,@create_time)";
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|
}
|
|
}
|
|
|
|
public bool Update(MedicalSchemeMaintainModel model)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = @"UPDATE [dbo].[medical_scheme_maintain]
|
|
SET [code] = @code
|
|
,[medical_scheme] = @medical_scheme
|
|
,[status] = @status
|
|
,[creator] = @creator
|
|
,[create_time] = @create_time
|
|
,[isCharge]=@isCharge
|
|
WHERE id=@id";
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id删除体检方案
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public object del(string id)
|
|
{
|
|
string sql = @"delete medical_scheme_maintain 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 };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |