一厂MES,含注塑,喷涂,冲孔
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.

107 lines
3.2 KiB

3 months ago
using MESClassLibrary.BLL.Log;
using MESClassLibrary.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.DAL.Log
{
public class LogSysDAL
{
public static string TableName = "LogSys";
public string GetTableName()
{
return TableName;
}
/// <summary>
/// 查询全部错误信息
/// </summary>
/// <returns></returns>
public DataTable Search_Info()
{
try
{
string sql = @"select * from " + TableName + " order by CreateTime desc";
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
public DataTable Search_InfoByTime(DateTime stime, DateTime etime)
{
try
{
string sql = @"select * from " + TableName + @"
where CreateTime>=@stime and CreateTime<=@etime order by CreateTime desc";
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("@stime", SqlDbType.DateTime);
param[0].Value = stime;
param[1] = new SqlParameter("@etime", SqlDbType.DateTime);
param[1].Value = etime;
return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0];
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
/// <summary>
/// 添加错误信息
/// </summary>
/// <param name="mod"></param>
/// <returns></returns>
public bool Add_Info(LogSysModel mod)
{
try
{
#region 添加数据
string sql = "";
SqlParameter[] param = null;
sql = "INSERT INTO " + TableName + " (ID,SysContent,SysSource";
sql += ") VALUES (";
sql += "@ID,";
sql += "@SysContent,";
sql += "@SysSource)";
#region 添加参数
param = new SqlParameter[3];
param[0] = new SqlParameter("@ID", SqlDbType.VarChar);
param[0].Value = mod.ID;
param[1] = new SqlParameter("@SysContent", SqlDbType.VarChar);
param[1].Value = mod.SysContent;
param[2] = new SqlParameter("@SysSource", SqlDbType.VarChar);
param[2].Value = mod.SysSource;
#endregion
SqlHelper.ExecuteNonQuery(SqlHelper.GetConnSting(), CommandType.Text, sql, param);
#endregion
return true;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return false;
}
}
}
}