You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.0 KiB
78 lines
3.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using PEIS.Entity;
|
|
using PEIS.Utils;
|
|
|
|
namespace PEIS.Model
|
|
{
|
|
public class UserModel : IModel<User>
|
|
{
|
|
public List<User> GetItems()
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public bool SaveItem(User item)
|
|
{
|
|
var i = DAOHelp.ExecuteSql($@"
|
|
IF NOT EXISTS (SELECT 1 FROM Dict_User WHERE Code = '{item.Code}' AND DID={item.DID})
|
|
BEGIN
|
|
INSERT INTO [dbo].[Dict_User]( [Code], [Name], [DID]) VALUES ( '{item.Code}', '{item.Name}', {item.DID});
|
|
END");
|
|
return i > 0;
|
|
}
|
|
|
|
public List<User> GetItems(Int64 did)
|
|
{
|
|
return DAOHelp.GetDataBySQL<User>($"select * from Dict_User WHERE DID={did} ");
|
|
}
|
|
|
|
public User GetByCode4His(String code)
|
|
{
|
|
List<User> lstUser = DAOHelp.GetDataBySQL<User>($"SELECT a.code AS Code, RTRIM(a.name) AS Name, a.ystype, b.code AS DeptCode, RTRIM(b.name) AS DeptName, b.ksattrib FROM {Global.HisDBName}.YSCODE a(NOLOCK) JOIN {Global.HisDBName}.KSCode b(NOLOCK) ON a.kscode = b.code WHERE a.CODE = '{code}'");
|
|
if (lstUser?.Count() > 0)
|
|
{
|
|
return lstUser.ToArray()[0];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public Boolean HisLogin(User user)
|
|
{
|
|
String sql = String.Format($"SELECT a.code AS Code, RTRIM(a.name) AS Name, a.ystype, b.code AS DeptCode, RTRIM(b.name) AS DeptName, b.ksattrib FROM {Global.HisDBName}.YSCODE a(NOLOCK) JOIN {Global.HisDBName}.KSCode b(NOLOCK) ON a.kscode = b.code WHERE a.CODE = '{user.Code}' AND a.PASSWORD = '{user.PassWord}'");
|
|
List<User> lstUser = DAOHelp.GetDataBySQL<User>(sql);
|
|
if (lstUser.Count == 0)
|
|
return false;
|
|
Global.currentUser = lstUser[0];
|
|
return true;
|
|
}
|
|
|
|
public Boolean PeisLogin(User user)
|
|
{
|
|
String sql = $"SELECT a.*,b.hisCode AS DeptCode, RTRIM(b.name) AS DeptName FROM Dict_User a LEFT JOIN Dict_Dept b ON a.DID = b.ID WHERE a.Code = {user.Code} ORDER BY B.Seq";
|
|
List<User> lstUser = DAOHelp.GetDataBySQL<User>(sql);
|
|
if (lstUser.Count == 0)
|
|
return false;
|
|
Global.currentUser.lstUser = lstUser;
|
|
return true;
|
|
}
|
|
|
|
public User QueryUser(string code)
|
|
{
|
|
return DAOHelp.GetDataBySQL<User>($"select Code,RTRIM(Name) as Name,kscode as DeptCode,RTRIM(ksname) as DeptName from {Global.HisDBName}.yscode where code='{code}'").FirstOrDefault();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断是否是体检科
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Boolean IsPeidDept()
|
|
{
|
|
var sql = $"SELECT a.* FROM Dict_User a LEFT JOIN Dict_Dept b ON a.DID = b.ID WHERE a.Code = '{Global.currentUser.Code}' and b.Code='0001' ";
|
|
return DAOHelp.GetDataBySQL<User>(sql).Count > 0;
|
|
}
|
|
|
|
}
|
|
} |