168 lines
5.6 KiB
C#
168 lines
5.6 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 ThresholdDeviationMaintainDal
|
|||
|
|
{
|
|||
|
|
public List<ThresholdDeviationMaintainModel> GetAllList(string id, string stauts)
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
string param = "";
|
|||
|
|
if (id != "")
|
|||
|
|
{
|
|||
|
|
param = " and id =@id";
|
|||
|
|
}
|
|||
|
|
if (stauts != "")
|
|||
|
|
{
|
|||
|
|
param += " and status=@stauts";
|
|||
|
|
}
|
|||
|
|
return conn.Query<ThresholdDeviationMaintainModel>("select * from threshold_deviation_maintain where 1=1" + param, new { @id = id, @stauts = stauts }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int getCount(string key)
|
|||
|
|
{
|
|||
|
|
string sql = "select count(1) from dbo.threshold_deviation_maintain where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and threshold_project like @threshold_project";
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql, new { threshold_project = "%" + key + "%" });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据听阈偏差项目获取听阈偏差列表
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="page"></param>
|
|||
|
|
/// <param name="pagesize"></param>
|
|||
|
|
/// <param name="key"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<ThresholdDeviationMaintainModel> getList(int page, int pagesize, string key)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select *,row_number() over(order by id desc) as rownum from threshold_deviation_maintain where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and threshold_project like @threshold_project";
|
|||
|
|
}
|
|||
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.ThresholdDeviationMaintainModel>(sql, new { threshold_project = "%" + key + "%" }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object save(ThresholdDeviationMaintainModel tdm, ERPUser user)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
tdm.creator = user.TrueName;
|
|||
|
|
tdm.create_time = DateTime.Now.ToString("yyyy-MM-dd");
|
|||
|
|
string sql = "";
|
|||
|
|
if (tdm.id == 0)
|
|||
|
|
{
|
|||
|
|
sql = @"INSERT INTO [dbo].[threshold_deviation_maintain]
|
|||
|
|
([threshold_project]
|
|||
|
|
,[exam_project_maintain_id]
|
|||
|
|
,[sex]
|
|||
|
|
,[age_upper]
|
|||
|
|
,[age_lower]
|
|||
|
|
,[deviation_value]
|
|||
|
|
,[status]
|
|||
|
|
,[creator]
|
|||
|
|
,[create_time]
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(@threshold_project
|
|||
|
|
,@exam_project_maintain_id
|
|||
|
|
,@sex
|
|||
|
|
,@age_upper
|
|||
|
|
,@age_lower
|
|||
|
|
,@deviation_value
|
|||
|
|
,@status
|
|||
|
|
,@creator
|
|||
|
|
,@create_time)
|
|||
|
|
";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sql = @"UPDATE [dbo].[threshold_deviation_maintain]
|
|||
|
|
SET [threshold_project]=@threshold_project,[exam_project_maintain_id] = @exam_project_maintain_id
|
|||
|
|
,[sex]=@sex
|
|||
|
|
,[age_upper]=@age_upper ,[age_lower]=@age_lower,[deviation_value]=@deviation_value
|
|||
|
|
,[status]=@status
|
|||
|
|
WHERE id=@id
|
|||
|
|
";
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int c = conn.Execute(sql, tdm);
|
|||
|
|
if (c > 0)
|
|||
|
|
{
|
|||
|
|
return new { State = 1, Message = "保存成功!" };
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = ex.Message };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<ThresholdDeviationMaintainModel> GetAllTreeList()
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<ThresholdDeviationMaintainModel>("select * from threshold_deviation_maintain", new { @status = "是" }).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据id删除听阈偏差
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public object del(string id)
|
|||
|
|
{
|
|||
|
|
string sql = @"delete threshold_deviation_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 };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|