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

114 lines
4.6 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.MD.Entity;
using QMFrameWork.Log;
using System.Data;
using QMAPP.DAL;
namespace QMAPP.MD.DAL
{
/// <summary>
/// 模块名称:配置明细表
/// 作 者:周晓东
/// 编写日期:20180705
/// </summary>
public class ConfigDetailDAL : BaseDAL
{
#region 获取查询语句
/// <summary>
/// 获取查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(ConfigDetail condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
sqlBuilder.AppendLine(" SELECT M.PID ");
sqlBuilder.AppendLine(" ,F.MainTypeName ");
sqlBuilder.AppendLine(" ,M.MainTypeCode ");
sqlBuilder.AppendLine(" ,M.DetailTypeCode ");
sqlBuilder.AppendLine(" ,M.DetailTypeName ");
sqlBuilder.AppendLine(" ,M.State ");
sqlBuilder.AppendLine(" ,M.REMARK ");
sqlBuilder.AppendLine(" ,M.CREATEUSER ");
sqlBuilder.AppendLine(" ,M.CREATEDATE ");
sqlBuilder.AppendLine(" ,M.UPDATEUSER ");
sqlBuilder.AppendLine(" ,M.UPDATEDATE ");
sqlBuilder.AppendLine(" FROM T_MD_ConfigDetail M ");
sqlBuilder.AppendLine(" LEFT JOIN T_MD_ConfigMain F ON M.MainTypeCode=F.MainTypeCode ");
//查询条件
whereBuilder.Append(" AND M.State <> '1'");
//主档类型编码
if (string.IsNullOrEmpty(condition.MainTypeCode) == false)
{
whereBuilder.Append(" AND M.MainTypeCode = @MainTypeCode");
parameters.Add(new DataParameter { ParameterName = "MainTypeCode", DataType = DbType.String, Value = condition.MainTypeCode });
}
//明细类型编码
if (string.IsNullOrEmpty(condition.DetailTypeCode) == false)
{
whereBuilder.Append(" AND M.DetailTypeCode = @DetailTypeCode");
parameters.Add(new DataParameter { ParameterName = "DetailTypeCode", DataType = DbType.String, Value = condition.DetailTypeCode });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 获取一级菜单
/// </summary>
/// <param name="condition">获取条件</param>
/// <returns>用户信息列表</returns>
public List<ConfigDetail> GetAllList(string MainTypeCode)
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
var sql =
"SELECT D.* ,M.MainTypeName FROM T_MD_ConfigDetail D LEFT JOIN T_MD_ConfigMain M ON M.MainTypeCode = D.MainTypeCode WHERE D.State <> '1' AND (D.tempId = '' or D.tempId is NULL) AND D.MainTypeCode = '" +
MainTypeCode + "'";
//sql = this.GetQuerySql(condition, ref parameters);
return session.GetList<ConfigDetail>(sql, new List<DataParameter>().ToArray()).ToList();
}
}
/// <summary>
/// 获取二级菜单
/// </summary>
/// <param name="condition">获取条件</param>
/// <returns>用户信息列表</returns>
public List<ConfigDetail> GetSecondList(string MainTypeCode, string PID)
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
var sql =
"SELECT D.* ,M.MainTypeName FROM T_MD_ConfigDetail D LEFT JOIN T_MD_ConfigMain M ON M.MainTypeCode = D.MainTypeCode WHERE D.State <> '1' AND D.MainTypeCode = '" + MainTypeCode + "' AND D.tempId = '" + PID + "'";
//sql = this.GetQuerySql(condition, ref parameters);
return session.GetList<ConfigDetail>(sql, new List<DataParameter>().ToArray()).ToList();
}
}
}
}