You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
4.2 KiB

using Module.DB.DBUtility;
using Module.DB.Model.DBEapModel;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Module.DB.SQLServerDAL
{
/// <summary>
/// 获取设备常量参数信息
/// </summary>
public class SEapConstParamInfo
{
/// <summary>
/// 查询常量参数消息
/// </summary>
/// <returns>常量参数消息列表</returns>
public static List<EapConstParam> GetConstInfoList()
{
try
{
var list = new List<EapConstParam>();
string countSql = "SELECT * FROM t_eap_const_param" + " ";
countSql += "ORDER BY f_sn asc";
SQLServerHelper sHelper = new SQLServerHelper();
DataTable dtResult = sHelper.QuerySql(countSql);
int rownum = dtResult.Rows.Count;
if (rownum > 0)
{
for (var i = 0; i < rownum; i++)
{
var constInfo = new EapConstParam();
var temp = dtResult.Rows[i];
object objID = temp["f_sn"];
constInfo.f_sn = (objID == null || objID.ToString().Trim() == "") ? 0 : Convert.ToInt32(objID);
object objEcid = temp["f_ecid"];
constInfo.f_ecid = (objEcid == null || objEcid.ToString().Trim() == "") ? 0 : Convert.ToUInt32(objEcid);
constInfo.f_ecname = temp["f_ecname"].ToString();
constInfo.f_format = temp["f_format"].ToString();
constInfo.f_max = String.IsNullOrEmpty(temp["f_max"].ToString()) ? 0 : Convert.ToInt32(temp["f_max"].ToString());
constInfo.f_min = String.IsNullOrEmpty(temp["f_min"].ToString()) ? 0 : Convert.ToInt32(temp["f_min"].ToString());
constInfo.f_default = temp["f_default"].ToString();
constInfo.f_unit = temp["f_unit"].ToString();
constInfo.f_value = temp["f_value"].ToString();
list.Add(constInfo);
}
}
return list;
}
catch (Exception ex)
{
ex.ToString();
return null;
}
}
/// <summary>
/// 查询常量参数消息
/// </summary>
/// <returns>常量参数消息列表</returns>
public static int AddConstInfoList(List<EapConstParam> lstParams)
{
try
{
int rtnResult = 0;
if (lstParams != null)
{
int count = lstParams.Count;
if (count > 0)
{
for (int i = 0; i < count; i++)
{
string addSql = "INSERT INTO t_eap_const_param" + " ";
addSql += "(f_ecid,f_ecname,f_format,f_max,f_min,f_default,f_unit,f_value)";
addSql += " VALUES";
addSql += "('" + lstParams[i].f_ecid + "',";
addSql += "'" + lstParams[i].f_ecname + "',";
addSql += "'" + lstParams[i].f_format + "',";
addSql += "'" + lstParams[i].f_max + "',";
addSql += "'" + lstParams[i].f_min + "',";
addSql += "'" + lstParams[i].f_default + "',";
addSql += "'" + lstParams[i].f_unit + "',";
addSql += "'" + lstParams[i].f_value + "')";
SQLServerHelper sHelper = new SQLServerHelper();
int result = sHelper.ExecuteNonQuerySQL(addSql);
rtnResult += result;
}
}
}
return rtnResult;
}
catch (Exception ex)
{
ex.ToString();
return 0;
}
}
}
}