-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeavStkTemplate.aspx.cs
155 lines (146 loc) · 4.39 KB
/
LeavStkTemplate.aspx.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
155
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
public partial class LeavStkTemplate : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string action = Request.Form["act"];
if (!string.IsNullOrEmpty(action))
{
Response.Clear();
if (action == "getTable")
{
Response.Write(getTable());
}
else if (action == "getDatalist")
{
Response.Write(getDatalist());
}
else if (action == "add")
{
Response.Write(add());
}
else if (action == "edit")
{
Response.Write(edit());
}
else if (action == "getFormDetail")
{
Response.Write(getFormDetail());
}
else if (action == "CheckInfo")
{
Response.Write(CheckInfo());
}
else if (action == "delete")
{
Response.Write(delete());
}
Response.End();
}
}
private string getTable()
{
string res = "";
DataSet ds = LeaveStockInfoManage.GetTemplateInfo();
if(ds !=null)
{
res = JsonHelper.DataTableToJsonForEasyUiDataGridLoadDataMethod(ds.Tables[0].Rows.Count, ds.Tables[0]);
}
return res;
}
private string getDatalist()
{
string res = "";
DataSet ds = LeaveStockInfoManage.GetDatalistInfo();
if (ds != null)
{
res = JsonHelper.DataTableToJsonForEasyUiDataGridLoadDataMethod(ds.Tables[0].Rows.Count, ds.Tables[0]);
}
return res;
}
private string delete()
{
return LeaveStockInfoManage.DeleteTemplate(Request.Form["type"]);
}
private string add()
{
string res = "";
DataSet ds = LeaveStockInfoManage.GetTemplateInfo();
if (ds != null)
{
ArrayList list = new ArrayList();
foreach (DataRow row in ds.Tables[0].Rows)
{
Dictionary<string, string> dict = new Dictionary<string, string>();
string val = Request.Form[row["field"].ToString()];
dict.Add("field", row["field"].ToString());
dict.Add("alias", val);
dict.Add("type", Request.Form["type"]);
list.Add(dict);
}
res = LeaveStockInfoManage.InsertTemplate(list);
}
return res;
}
private string edit()
{
string res = "";
DataSet ds = LeaveStockInfoManage.GetTemplateInfo();
if (ds != null)
{
ArrayList list = new ArrayList();
foreach (DataRow row in ds.Tables[0].Rows)
{
Dictionary<string, string> dict = new Dictionary<string, string>();
string val = Request.Form[row["field"].ToString()];
dict.Add("field", row["field"].ToString());
dict.Add("alias", val);
dict.Add("type", Request.Form["type"]);
list.Add(dict);
}
res = LeaveStockInfoManage.UpdateTemplate(list, Request.Form["type"]);
}
return res;
}
private string getFormDetail()
{
string res = "";
Dictionary<string, string> dict = LeaveStockInfoManage.GetFormDetail(Request.Form["dataType"]);
res = JsonHelper.SerializeObject(dict);
return res;
}
private string CheckInfo()
{
bool isEdit = false;
if (Request.Form["state"] == "edit")
{
isEdit = true;
}
DataSet ds = LeaveStockInfoManage.CheckInfo(Request.Form["dataType"]);
int standartNumber = 0;//插入模式不允许查询到记录
if (isEdit)
{
standartNumber = 1;//编辑模式最多查询到1条记录
}
string res = "数据库读取失败!";
if (ds != null)
{
if (ds.Tables[0].Rows.Count > standartNumber)
{
res += "数据模板名称已存在,请重新输入!";
}
else
{
res = "T";
}
}
return res;
}
}