126 lines
4.4 KiB
C#
126 lines
4.4 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 InfectionDaysignQuestionAnswerDal
|
|||
|
|
{
|
|||
|
|
public List<InfectionOpenUserInfoModel> GetAllDataList()
|
|||
|
|
{
|
|||
|
|
string sql = "SELECT i.user_id,i.name,i.ident,i.phone,i.birth FROM(SELECT user_id " +
|
|||
|
|
"FROM dccdc.dbo.infection_daysign_question_answer GROUP BY user_id) a " +
|
|||
|
|
"LEFT JOIN dccdc.dbo.infection_open_user_info i ON a.user_id = i.user_id";
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<InfectionOpenUserInfoModel>(sql).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public string SaveData(InfectionDaysignQuestionAnswerModel model)
|
|||
|
|
{
|
|||
|
|
string sql = @"insert into infection_daysign_question_answer(question_id,info_id,question_sign,answer,create_time, create_by)Values(@question_id,@info_id,@question_sign,@answer,@create_time,@create_by)";
|
|||
|
|
string returnValue = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
int result = conn.Execute(sql, model);
|
|||
|
|
if (result > 0)
|
|||
|
|
returnValue = "True";
|
|||
|
|
else
|
|||
|
|
returnValue = "False";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
returnValue = "False";
|
|||
|
|
}
|
|||
|
|
return returnValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string delete(string id)
|
|||
|
|
{
|
|||
|
|
string sql = string.Format("DELETE FROM infection_daysign_question_answer WHERE info_id = '{0}'", id);
|
|||
|
|
string returnValue = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
int result = conn.Execute(sql, id);
|
|||
|
|
if (result > 0)
|
|||
|
|
returnValue = "True";
|
|||
|
|
else
|
|||
|
|
returnValue = "False";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
returnValue = "False";
|
|||
|
|
}
|
|||
|
|
return returnValue;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool deleteData(int id)
|
|||
|
|
{
|
|||
|
|
string sql = string.Format("DELETE FROM dccdc.dbo.infection_daysign_question_answer WHERE info_id = '{0}'", id);
|
|||
|
|
string returnValue = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
int result = conn.Execute(sql);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object saveData(InfectionDaysignQuestionAnswerModel model)
|
|||
|
|
{
|
|||
|
|
string sql = @"insert into infection_daysign_question_answer(question_id,user_id,question_sign,answer,create_time)Values(@question_id,@user_id,@question_sign,@answer,@create_time)";
|
|||
|
|
string returnValue = string.Empty;
|
|||
|
|
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 List<InfectionDaysignQuestionAnswerModel> getDataListByUserID(string info_id)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string sql = string.Format("SELECT id,info_id,question_id,question_sign,answer FROM infection_daysign_question_answer WHERE info_id = '{0}' order by question_id asc", info_id);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
using (IDbConnection conn = CommHelper.GetSqlConnection())
|
|||
|
|
{
|
|||
|
|
return conn.Query<InfectionDaysignQuestionAnswerModel>(sql).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|