104 lines
3.2 KiB
C#
104 lines
3.2 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 SummaryReportHarmMaintainDal
|
|
{
|
|
/// <summary>
|
|
/// 根据id获取总结报告职业危害列表
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public List<SummaryReportHarmMaintainModel> GetAllList(string id)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string param = "";
|
|
if (id != "")
|
|
{
|
|
param = " and id=@id";
|
|
}
|
|
return conn.Query<SummaryReportHarmMaintainModel>("select * from summary_report_harm_maintain where 1=1 " + param+" order by id desc", new { @id = id }).ToList();
|
|
}
|
|
}
|
|
|
|
public bool Update(SummaryReportHarmMaintainModel model)
|
|
{
|
|
string sql = @"UPDATE [summary_report_harm_maintain]
|
|
SET [harmful_factor_name] = @harmful_factor_name
|
|
,[harmful_factors_maintain_id] = @harmful_factors_maintain_id
|
|
,[name] =@name
|
|
,[pinyin_code] = @pinyin_code
|
|
,[status] = @status
|
|
,[creator] = @creator
|
|
,[create_time] = @create_time
|
|
WHERE id=@id";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|
}
|
|
}
|
|
|
|
public bool Add(SummaryReportHarmMaintainModel model)
|
|
{
|
|
string sql = @"INSERT INTO [summary_report_harm_maintain]
|
|
([harmful_factor_name]
|
|
,[harmful_factors_maintain_id]
|
|
,[name]
|
|
,[pinyin_code]
|
|
,[status]
|
|
,[creator]
|
|
,[create_time])
|
|
VALUES
|
|
(@harmful_factor_name
|
|
,@harmful_factors_maintain_id
|
|
,@name
|
|
,@pinyin_code
|
|
,@status
|
|
,@creator
|
|
,@create_time)";
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
return (conn.Execute(sql, model) != 0 ? true : false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据id删除总结报告职业危害
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public object del(string id)
|
|
{
|
|
string sql = @"delete summary_report_harm_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 };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|