天津投入产出系统后端
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.

214 lines
6.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Basic;
using QMFrameWork.Data;
using System.Data;
using QMAPP.Entity;
3 years ago
using QMAPP.FJC.Entity.MD;
namespace QMAPP.FJC.DAL.Basic
{
/// </summary>
/// 模块名称:配置表
/// 作 者:张松男
/// 编写日期:2021年03月17日
/// </summary>
public class AppConfigDAL
{
/// <summary>
/// 获取全部规则
/// </summary>
/// <returns></returns>
public AppConfig Get(string Code)
{
try
{
string sql = $"SELECT * FROM [T_MD_AppConfig_QD] where Code = '{Code}'";
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.Get<AppConfig>(sql, parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
public int UpdateAppConfig(string pConfigValue,string pConfigCode)
{
try
{
string sqlScript = $" update T_MD_AppConfig_QD set Value='{pConfigValue}' where Code='{pConfigCode}'";
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.ExecuteSql(sqlScript, parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
3 years ago
public AppConfig GetPID(AppConfig Code)
{
try
{
string sql = $"SELECT * FROM [T_MD_AppConfig_QD] where ID = '{Code.ID}'";
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.Get<AppConfig>(sql, parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(AppConfig condition, DataPage page)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
page.KeyName = "ID";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
page = session.GetDataPage<AppConfig>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw ex;
}
}
#region 获取查询语句
/// <summary>
/// 获取查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(AppConfig condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append("SELECT ID,Code,Name,Value,Remark ");
sqlBuilder.Append("FROM [T_MD_AppConfig_QD] ");
//查询条件
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 获取全部规则
/// </summary>
/// <returns></returns>
public List<AppConfig> GetAllList()
{
try
{
string sql = "SELECT * FROM [T_MD_AppConfig_QD]";
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<AppConfig>(sql, parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public int Update(AppConfig info)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//更新基本信息
count = session.Update<AppConfig>(info);
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 获取全部规则
/// </summary>
/// <returns></returns>
public MaterialClass GetMATERIAL(string MATERIALCode,ref string msg)
{
try
{
var sql = $" select MATERIAL_TYPE_NAME,LAYER_NUM,UP_MATERIAL_TYPE_CODE from T_MD_MATERIAL_CLASS where MATERIAL_TYPE_CODE = '{MATERIALCode}'";
var MaterialClass = new MaterialClass();
List<DataParameter> parameters = new List<DataParameter>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
MaterialClass = session.Get<MaterialClass>(sql, parameters.ToArray());
}
if (MaterialClass.LAYER_NUM == "2")
{
msg = MaterialClass.MATERIAL_TYPE_NAME;
return MaterialClass;
}
else
{
GetMATERIAL(MaterialClass.UP_MATERIAL_TYPE_CODE,ref msg);
}
return MaterialClass;
}
catch (Exception ex)
{
throw ex;
}
}
}
}