132 lines
4.4 KiB
C#
132 lines
4.4 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using dccdc.Models.PT;
|
|||
|
|
using Dapper;
|
|||
|
|
using System.Data;
|
|||
|
|
|
|||
|
|
namespace dccdc.DAL
|
|||
|
|
{
|
|||
|
|
public class ordDAL
|
|||
|
|
{
|
|||
|
|
public int getCount(string jgmc)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select count(1) from org where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(jgmc))
|
|||
|
|
{
|
|||
|
|
sql += " and zoe_value like @zoe_value";
|
|||
|
|
}
|
|||
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql, new { zoe_value = "%" + jgmc + "%" });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据机构名称获取辖区医疗机构列表
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="page"></param>
|
|||
|
|
/// <param name="pagesize"></param>
|
|||
|
|
/// <param name="jgmc"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<org> getList(int page, int pagesize, string jgmc)
|
|||
|
|
{
|
|||
|
|
string sql = "select *,row_number() over(order by zoe_code desc) as rownum from org where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(jgmc))
|
|||
|
|
{
|
|||
|
|
sql += " and zoe_value like @zoe_value";
|
|||
|
|
}
|
|||
|
|
sql = "select * from ( " + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.PT.org>(sql, new { zoe_value = "%" + jgmc + "%" }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Models.PT.org getM(string id)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select * from org where zoe_code=@zoe_code";
|
|||
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.PT.org>(sql, new { zoe_code = id }).FirstOrDefault();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object save(org o)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select * from org where zoe_code=@zoe_code";
|
|||
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
var m = conn.Query<Models.PT.org>(sql, new { zoe_code = o.zoe_code }).FirstOrDefault();
|
|||
|
|
if (m == null)
|
|||
|
|
{
|
|||
|
|
sql = "insert into org(zoe_dict_name,zoe_code,zoe_value,used) values(@zoe_dict_name,@zoe_code,@zoe_value,@used)";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sql = "update org set zoe_value=@zoe_value,used=@used where zoe_code=@zoe_code";
|
|||
|
|
}
|
|||
|
|
conn.Execute(sql, o);
|
|||
|
|
return new { State = 1, Message = "保存成功!" };
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = ex.Message };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object getorgs(string key)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select zoe_code,zoe_value from org where used='1'";
|
|||
|
|
if(!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and zoe_value like @zoe_value";
|
|||
|
|
}
|
|||
|
|
using (var conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query(sql, new { zoe_value ="%"+key+"%"}).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据id删除辖区医疗机构
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public object delORG(string id)
|
|||
|
|
{
|
|||
|
|
string sql = @"delete org where zoe_code=@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 };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|