forked from youthjoy/hfoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bll_Sys_Config_ListPage.cs
154 lines (138 loc) · 6.49 KB
/
Bll_Sys_Config_ListPage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using QX.DAL;
using QX.Model;
namespace QX.BLL
{
public partial class Bll_Sys_Config_ListPage
{
/// <summary>
/// 初始化Grid
/// </summary>
/// <param name="ModuleCode"></param>
/// <param name="Namespace"></param>
/// <param name="param"></param>
/// <returns></returns>
public DataTable GetListPageAllRecords(string ModuleCode,string Namespace,Dictionary<string,string> param)
{
//读出配置存储过程及参数
Bll_Sys_Config_ListPage ConfigMInstance = new Bll_Sys_Config_ListPage();
Bll_Bse_Dict DictInstance = new Bll_Bse_Dict();
Bll_Sys_Config_Fieled FieldInstance = new Bll_Sys_Config_Fieled();
Sys_Config_ListPage config = ConfigMInstance.GetListByCode(" AND M_ModuleCode='" + ModuleCode + "' ")[0];
List<Sys_Config_Fieled> ListField = FieldInstance.GetListByCode(" AND D_ModuleCode='" + ModuleCode + "'");
List<SqlParameter> list = new List<SqlParameter>();
SqlParameter search = new SqlParameter("@Search",param["@Search"]);
list.Add(search);
SqlParameter sidx = new SqlParameter("@Sidx", param["@Sidx"]);
list.Add(sidx);
SqlParameter sord = new SqlParameter("@Sord", param["@Sord"]);
list.Add(sord);
SqlParameter userid = new SqlParameter("@Userid", param["@Userid"]);
list.Add(userid);
SqlParameter deptid = new SqlParameter("@Deptid", param["@Deptid"]);
list.Add(deptid);
SqlParameter modulecode = new SqlParameter("@ModuleCode", ModuleCode);
list.Add(modulecode);
SqlParameter _namespace = new SqlParameter("@NameSpace", Namespace);
list.Add(_namespace);
SqlParameter InlineType = new SqlParameter("@InlineType", param["@InlineType"]);
list.Add(InlineType);
SqlParameter GeneralType = new SqlParameter("@GeneralType", param["@GeneralType"]);
list.Add(GeneralType);
DataTable newDt=instance.idb.RunProcReturnDatatable(config.M_SQL,list.ToArray());
#region Old,已被废弃掉的代码片段 By Ye Fei 2011-01-30
//首先获取config_filed表中有数据字典的列及相关数据字典标示
//var newList = ListField.Where(o => !string.IsNullOrEmpty(o.D_DictKey) && o.D_EditType.ToLower()=="dict" && o.D_Hidden!="true" );
//if (newList.Count()>0)
//{
// for (int i = 0; i < newDt.Rows.Count; i++)
// {
// foreach (Sys_Config_Fieled item in newList)
// {
// var DictResult = DictInstance.GetListByCode(" AND Dict_Code='" +
// newDt.Rows[i][item.D_Index].ToString()
// + "' AND Dict_Key='"+item.D_DictKey+"' ");
// if (DictResult.Count > 0)
// {
// newDt.Rows[i][item.D_Index] = DictResult.FirstOrDefault().Dict_Name;
// }
// if (param["@InlineType"].Length > 0)
// {
// //物料动态字典取值
// string dynKey = param["@InlineType"] + "TYPE";
// var Result = DictInstance.GetListByCode(" AND Dict_Code='" +
// newDt.Rows[i][item.D_Index].ToString()
// + "' AND Dict_Key='" + dynKey.ToUpper() + "' ");
// if (Result.Count > 0)
// {
// newDt.Rows[i][item.D_Index] = Result.FirstOrDefault().Dict_Name;
// }
// }
// }
// }
//}
///排序
//if (!string.IsNullOrEmpty(config.M_TableName))
//{
// Bll_Comm commInstance = new Bll_Comm();
// DataSet ds = commInstance.GetTableInfo(config.M_TableName);
// string TableKey = commInstance.GetTableKey(ds);
// if (!string.IsNullOrEmpty(TableKey))
// {
// DataView dv = newDt.DefaultView;
// dv.Sort = TableKey + " desc";
// newDt = dv.ToTable();
// }
//}
#endregion
return newDt;
}
public DataTable ListDataByCode(string TableName, string filter)
{
string sql = "SELECT * FROM "+TableName+" WHERE (Stat is null or Stat=0) AND "+filter ;
return instance.idb.ReturnDataTable(sql);
}
public bool SaveData(string sql)
{
//int result = 0;
//result = instance.idb.ExeCmd(sql);
//bool _result = result > 0 ? true : false;
//return _result;
int Re = 0;
//SQL日志记录
var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();
System.Collections.Hashtable param = new System.Collections.Hashtable();
string Ex = "0";
foreach (System.Collections.DictionaryEntry item in instance.idb.GetParameters())
{
param.Add(item.Key, item.Value);
}
try
{
Re = instance.idb.ExeCmd(sql);
Ex = Re.ToString();
}
catch (Exception ex)
{
Ex = ex.Message;
}
SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);
bool _result = Re > 0 ? true : false;
return _result;
}
public string GetTableKeyCode(string NameSapce)
{
SqlParameter x1 = new SqlParameter("@sTable", SqlDbType.NChar, 40);
x1.Value = NameSapce.Trim();
SqlParameter[] param = new SqlParameter[] { x1 };
IDbDataParameter[] parames = param as IDbDataParameter[];
DataTable dt = instance.idb.RunProcReturnDatatable("findnewid", parames);
return dt.Rows[0][0].ToString();
}
}
}