using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using IStation.Entity;
namespace IStation.DAL
{
///
/// 用户
///
public class User : BaseTraceDAL_Sorter_UseStatus_TagName
{
///
///
///
public override ConnectionConfig ConnectionConfig
{
get { return ConfigHelper.DefaultConnectionConfig; }
}
///
/// 更新登录密码
///
public bool UpdateLoginPwd(long ID, string LoginPwd,long UpdateUserID,DateTime UpdateTime)
{
if (string.IsNullOrEmpty(LoginPwd))
return default;
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
{
return db.Updateable()
.SetColumns(x => x.LoginPwd == LoginPwd)
.SetColumns(x => x.UpdateUserID == UpdateUserID)
.SetColumns(x => x.UpdateTime == UpdateTime)
.Where(x => x.ID == ID)
.ExecuteCommand() > 0;
}
}
///
/// 通过 ID 删除
///
public override bool DeleteByID(long ID)
{
using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
{
db.BeginTran();
var result = db.Deleteable()
.Where(x => x.ID == ID)
.ExecuteCommandHasChange();
if (!result)
{
db.RollbackTran();
return false;
}
db.Deleteable()
.Where(x => x.UserID == ID)
.ExecuteCommand();
db.CommitTran();
return true;
}
}
}
}