118 lines
4.3 KiB
C#
118 lines
4.3 KiB
C#
using Dapper;
|
|
using dccdc.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace dccdc.DAL
|
|
{
|
|
public class project_factor_maintainDal
|
|
{
|
|
public List<project_factor_maintainModel> GetAllList(string id, string jobsid, string harmfulid)
|
|
{
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
string sql = "select * from project_factor_maintain where 1=1";
|
|
if (!string.IsNullOrEmpty(id))
|
|
{
|
|
sql += " and id=@id";
|
|
}
|
|
if (!string.IsNullOrEmpty(jobsid))
|
|
{
|
|
sql += " and jobs_state_maintain_id=@jobsid";
|
|
}
|
|
if (!string.IsNullOrEmpty(harmfulid))
|
|
{
|
|
sql += " and harmful_factors_type_maintain_id=@harmfulid";
|
|
}
|
|
return conn.Query<project_factor_maintainModel>(sql, new { @id = id, @jobsid = jobsid, @harmfulid = harmfulid }).ToList();
|
|
}
|
|
}
|
|
|
|
public object save(project_factor_maintainModel model)
|
|
{
|
|
string sql = "";
|
|
if (model.id == 0)
|
|
{
|
|
sql = @"INSERT INTO [dbo].[project_factor_maintain]
|
|
([jobs_state_maintain_id]
|
|
,[harmful_factors_type_maintain_id]
|
|
,[exam_project_maintain_id]
|
|
,[project_code]
|
|
,[project_name]
|
|
,[is_check]
|
|
,[is_goal]
|
|
,[exam_group]
|
|
,[exam_group_maintain_id]
|
|
,[factor_code])
|
|
VALUES
|
|
(@jobs_state_maintain_id
|
|
,@harmful_factors_type_maintain_id
|
|
,@exam_project_maintain_id
|
|
,@project_code
|
|
,@project_name
|
|
,@is_check
|
|
,@is_goal
|
|
,@exam_group
|
|
,@exam_group_maintain_id
|
|
,@factor_code)";
|
|
}
|
|
else
|
|
{
|
|
sql = @"UPDATE [dbo].[project_factor_maintain]
|
|
SET [jobs_state_maintain_id] = jobs_state_maintain_id
|
|
,[harmful_factors_type_maintain_id] =harmful_factors_type_maintain_id
|
|
,[exam_project_maintain_id] = exam_project_maintain_id
|
|
,[project_code] = project_code
|
|
,[project_name] = project_name
|
|
,[is_check] = is_check
|
|
,[is_goal] = is_goal
|
|
,[exam_group] = exam_group
|
|
,[exam_group_maintain_id] = exam_group_maintain_id
|
|
,[factor_code] = factor_code
|
|
WHERE id=@id";
|
|
}
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.Execute(sql, model);
|
|
if (result > 0)
|
|
return new { State = 1, Message = "保存成功!" };
|
|
else
|
|
return new { State = 0, Message = "保存失败!" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
|
|
public object delete(string id)
|
|
{
|
|
string sql = "delete from project_factor_maintain where id=@id";
|
|
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|
{
|
|
try
|
|
{
|
|
int result = conn.Execute(sql, new { id = id });
|
|
if (result > 0)
|
|
return new { State = 1, Message = "操作成功!" };
|
|
else
|
|
return new { State = 0, Message = "操作失败!" };
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return new { State = 0, Message = ex.Message };
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|