155 lines
5.0 KiB
C#
155 lines
5.0 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 SummaryreportSuggestMaintainDal
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据id删除总结报告处理意见及建议
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public object del(string id)
|
|||
|
|
{
|
|||
|
|
string sql = @"delete summaryreport_suggest_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 };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<SummaryreportSuggestMaintainModel> 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<SummaryreportSuggestMaintainModel>("select * from summaryreport_suggest_maintain where 1=1" + param, new { @id = id, @stauts = stauts }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public int getCount(string key)
|
|||
|
|
{
|
|||
|
|
string sql = "select count(1) from dbo.summaryreport_suggest_maintain where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and opinion_and_suggest like @opinion_and_suggest";
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.ExecuteScalar<int>(sql, new { opinion_and_suggest = "%" + key + "%" });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据处理意见及建议获取总结报告处理意见及建议列表
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="page"></param>
|
|||
|
|
/// <param name="pagesize"></param>
|
|||
|
|
/// <param name="key"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<SummaryreportSuggestMaintainModel> getList(int page, int pagesize, string key)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
string sql = "select *,row_number() over(order by id desc) as rownum from summaryreport_suggest_maintain where 1=1";
|
|||
|
|
if (!string.IsNullOrEmpty(key))
|
|||
|
|
{
|
|||
|
|
sql += " and opinion_and_suggest like @opinion_and_suggest";
|
|||
|
|
}
|
|||
|
|
sql = "select * from (" + sql + ") t where t.rownum>(" + page + "-1)*" + pagesize + " and rownum<=" + page + "*" + pagesize;
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<Models.SummaryreportSuggestMaintainModel>(sql, new { opinion_and_suggest = "%" + key + "%" }).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object save(SummaryreportSuggestMaintainModel cpm, ERPUser user)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
cpm.creator = user.TrueName;
|
|||
|
|
cpm.create_time = DateTime.Now.ToString("yyyy-MM-dd");
|
|||
|
|
string sql = "";
|
|||
|
|
if (cpm.id == 0)
|
|||
|
|
{
|
|||
|
|
sql = @"INSERT INTO [dbo].[summaryreport_suggest_maintain]
|
|||
|
|
(
|
|||
|
|
[opinion_and_suggest],
|
|||
|
|
[status],
|
|||
|
|
[pinyin_code],
|
|||
|
|
[creator],
|
|||
|
|
[create_time]
|
|||
|
|
)
|
|||
|
|
VALUES
|
|||
|
|
(
|
|||
|
|
@opinion_and_suggest,
|
|||
|
|
@status,
|
|||
|
|
@pinyin_code,
|
|||
|
|
@creator,
|
|||
|
|
@create_time
|
|||
|
|
)
|
|||
|
|
";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sql = @"UPDATE [dbo].[summaryreport_suggest_maintain]
|
|||
|
|
SET [opinion_and_suggest]=@opinion_and_suggest,
|
|||
|
|
[status]=@status,
|
|||
|
|
[pinyin_code]=@pinyin_code,
|
|||
|
|
[creator]=@creator,
|
|||
|
|
[create_time]=@create_time
|
|||
|
|
WHERE id=@id
|
|||
|
|
";
|
|||
|
|
}
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int c = conn.Execute(sql, cpm);
|
|||
|
|
if (c > 0)
|
|||
|
|
{
|
|||
|
|
return new { State = 1, Message = "保存成功!" };
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = "操作失败,请联系管理员!" };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return new { State = 0, Message = ex.Message };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|