零代码配置xml维护单表
发布日期:2021-05-09 04:22:20 浏览次数:17 分类:博客文章

本文共 20609 字,大约阅读时间需要 68 分钟。

   ������������cnblogs������������������������������������������������������������������������������������������(������������������������������������������������������)���������������������������,������������������������������������blog������������cnblogs���������������������������������������������������������������!������������������������������������������������31���������������������������������������������������blog������������������������������������������������������(������������������������!)���������������������������������������������������������������������������������������������������������������������������������������������������������������������������xml���������������������������������������������XDJM���������������������.

   ������������������������������������������������

  ��������� ������������������(������������sqlserver 2005)

 

T_NEWSTYPE(������������)
ID(
int
 ������������),NAME (
varchar
(
50
))
T_INFO(������)
ID(
char
(
36
)),TITLE(
varchar
(
100
)),CONTENT(
varchar
(
max
)),ADDTIME(
smalldatetime
),CLICKNUM(
int
),TYPE(
varchar
(
10
))

 

 

 ��������� ������������������������xml������

 

������
 
<
table 
id
="99"
 key
="id"
 name
="T_NEWSTYPE"
 cnname
="������������"
 order
="id desc"
>
    
<
column 
name
="ID"
 cnname
="������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="n"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
=""
></
column
>
    
<
column 
name
="NAME"
 cnname
="������������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="y"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
="textbox"
></
column
>
  
</
table
>
 
<
table 
id
="100"
 key
="id"
 name
="T_Info"
 cnname
="������"
 order
="addtime desc,id desc"
>
    
<
column 
name
="ID"
 cnname
="������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="n"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
="key"
></
column
>
    
<
column 
name
="TITLE"
 cnname
="������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="y"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
="textbox"
></
column
>
    
<
column 
name
="file"
 cnname
="������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="n"
 visible
="n"
 allownull
="n"
 regex
=""
 tip
=""
 type
="file"
></
column
>
    
<
column 
name
="TYPE"
 cnname
="������"
 ftable
="T_NEWSTYPE"
 fvalue
="ID"
 ftext
="NAME"
 isfilter
="n"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
="dropdownlist"
></
column
>
    
<
column 
name
="CONTENT"
 cnname
="������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="n"
 visible
="n"
 allownull
="n"
 regex
=""
 tip
=""
 type
="fck"
></
column
>
    
<
column 
name
="ADDTIME"
 cnname
="������������"
 ftable
=""
 fvalue
=""
 ftext
=""
 isfilter
="n"
 visible
="y"
 allownull
="n"
 regex
=""
 tip
=""
 type
="autodatetime"
></
column
>
  
</
table
>

 

 ��������� ���xml���������������id���������������������������������,������������������������������������������������������������

���������������������������������������������������(���������������������������������������������������������������������������������������������������������������������������������������������)

���������������������������������������������������������������

���������������������������������������������aspx���������������������

 

������
 1 
<%
@ Page Language
=
"
C#
"
 AutoEventWireup
=
"
true
"
 CodeFile
=
"
commonAdd.aspx.cs
"
 Inherits
=
"
webadmin_common_commonAdd
"
 
%>
 2 
 3 
<%
@ Register Assembly
=
"
FredCK.FCKeditorV2
"
 Namespace
=
"
FredCK.FCKeditorV2
"
 TagPrefix
=
"
FCKeditorV2
"
 
%>
 4 
 5 
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
 6 
 7 
<
html 
xmlns
="http://www.w3.org/1999/xhtml"
 
>
 8 
<
head 
runat
="server"
>
 9 
    
<
title
>
������������
</
title
>
10 
     
<
link 
href
="../css/style.css"
 rel
="stylesheet"
 type
="text/css"
 
/>
11 
</
head
>
12 
<
body
>
13 
    
<
form 
id
="form1"
 runat
="server"
>
14 
      
<
table 
width
="100%"
>
15 
  
<
tr
>
16 
    
<
td 
class
="sitemap"
><
span
><
img 
src
="../images/home.jpg"
 
/></
span
>
���������������������
<
asp:Literal 
ID
="tableCnName"
 runat
="server"
></
asp:Literal
>
������
</
td
>
17 
  
</
tr
>
18 
</
table
>
19 
        
<
asp:PlaceHolder 
ID
="contentPlaceHolder"
 runat
="server"
></
asp:PlaceHolder
>
20 
    
</
form
>
21 
</
body
>
22 
</
html
>

 

������������������������,ID���tableCnName���literal���������������������������ID���contentPlaceHolder���������������������xml���������������������������

 

aspx.cs���������������������

 

������
  1 
using
 System;
  2 
using
 System.Data;
  3 
using
 System.Configuration;
  4 
using
 System.Collections;
  5 
using
 System.Web;
  6 
using
 System.Web.Security;
  7 
using
 System.Web.UI;
  8 
using
 System.Web.UI.WebControls;
  9 
using
 System.Web.UI.WebControls.WebParts;
 10 
using
 System.Web.UI.HtmlControls;
 11 
using
 System.Data.SqlClient;
 12 
 13 
using
 System.Xml;
 14 
using
 Personal.Wgc.Diys.DBUtility;
 15 
using
 Personal.Wgc.Diys.WebTools;
 16 
using
 System.Collections.Generic;
 17 
using
 System.Text;
 18 
using
 System.Data.Common;
 19 
using
 Personal.Wgc.Diys.CommonDiyControls;
 20 
using
 Personal.Wgc.Diys.Dal;
 21 
 22 
public
 
partial
 
class
 webadmin_common_commonAdd : System.Web.UI.Page
 23 
{
 24 
    
private
 XmlDocument doc 
=
 
new
 XmlDocument();
 25 
    
public
 webadmin_common_commonAdd()
 26 
    {
 27 
        doc.Load(Server.MapPath(
"
http://www.cnblogs.com/app_data/config.xml
"
));
 28 
    }
 29 
    
protected
 
void
 Page_Load(
object
 sender, EventArgs e)
 30 
    {
 31 
        
//
if (UserService.GetInstance().GetLoginedUserTicket() < 1)
 32 
        
//
{
 33 
        
//
    this.ClientScript.RegisterClientScriptBlock(GetType(), "", "top.location='../default.aspx'", true);
 34 
        
//
    return;
 35 
        
//
}
 36 
        
if
 (
string
.IsNullOrEmpty(Request.QueryString[
"
id
"
]))
 37 
        {
 38 
            Response.Write(
"
������������������������,������������
"
);
 39 
            Response.End();
 40 
        }
 41 
        
if
 (ViewState[
"
columnList
"
==
 
null
)
 42 
        {
 43 
            InitialXmlInfo();
 44 
        }
 45 
        BuildPage();
 46 
    }
 47 
    
private
 
void
 InitialXmlInfo()
 48 
    {
 49 
        List
<
T_COLUMN
>
 columnList 
=
 
new
 List
<
T_COLUMN
>
();
 50 
        T_COLUMN column;
 51 
        XmlNode node 
=
 doc.SelectSingleNode(
"
/root/table[@id='
"
+
Request.QueryString[
"
id
"
]
+
"
']
"
);
 52 
        
if
 (node 
!=
 
null
)
 53 
        {
 54 
            
if
 (node.ChildNodes.Count 
==
 
0
)
 55 
            {
 56 
                Response.Write(
"
������������������,������������������!
"
);
 57 
                Response.End();
 58 
            }
 59 
            tableCnName.Text 
=
 node.Attributes[
"
cnname
"
].Value;
 60 
            
foreach
 (XmlNode columnNode 
in
 node.ChildNodes)
 61 
            {
 62 
                column 
=
 
new
 T_COLUMN();
 63 
                column.AllowNull 
=
 columnNode.Attributes[
"
allownull
"
].Value.ToString().ToUpper() 
==
 
"
Y
"
 
?
 
true
 : 
false
;
 64 
                column.CnName 
=
 columnNode.Attributes[
"
cnname
"
].Value;
 65 
                column.FTable 
=
 columnNode.Attributes[
"
ftable
"
].Value;
 66 
                column.FText 
=
 columnNode.Attributes[
"
ftext
"
].Value;
 67 
                column.FValue 
=
 columnNode.Attributes[
"
fvalue
"
].Value;
 68 
                column.IsFilter 
=
 columnNode.Attributes[
"
isfilter
"
].Value.ToString().ToUpper() 
==
 
"
Y
"
 
?
 
true
 : 
false
;
 69 
                column.Key 
=
 node.Attributes[
"
key
"
].Value;
 70 
                column.Name 
=
 columnNode.Attributes[
"
name
"
].Value;
 71 
                column.Regex 
=
 columnNode.Attributes[
"
regex
"
].Value;
 72 
                column.TableName 
=
 node.Attributes[
"
name
"
].Value;
 73 
                column.Type 
=
 columnNode.Attributes[
"
type
"
].Value;
 74 
                column.Visible 
=
 columnNode.Attributes[
"
visible
"
].Value.ToString().ToUpper() 
==
 
"
Y
"
 
?
 
true
 : 
false
;
 75 
                column.Tip 
=
 columnNode.Attributes[
"
tip
"
].Value;
 76 
                columnList.Add(column);
 77 
            }
 78 
            ViewState[
"
columnList
"
=
 columnList;
 79 
        }
 80 
        
else
 81 
        {
 82 
            Response.Write(
"
������������������
"
);
 83 
            Response.End();
 84 
        }
 85 
    }
 86 
    
private
 
void
 BuildPage()
 87 
    {
 88 
        Table myTable 
=
 
new
 Table();
 89 
        myTable.Attributes.Add(
"
cellpadding
"
"
4
"
);
 90 
        myTable.Attributes.Add(
"
cellspacing
"
"
1
"
);
 91 
        myTable.Style.Add(HtmlTextWriterStyle.Width, 
"
100%
"
);
 92 
        
if
 (ViewState[
"
columnList
"
==
 
null
)
 93 
        {
 94 
            InitialXmlInfo();
 95 
        }
 96 
        List
<
T_COLUMN
>
 columnList 
=
 (List
<
T_COLUMN
>
)ViewState[
"
columnList
"
];
 97 
        
foreach
 (T_COLUMN column 
in
 columnList)
 98 
        {
 99 
            TableRow tr 
=
 
new
 TableRow();
100 
            tr.Style.Add(HtmlTextWriterStyle.BackgroundColor, 
"
white
"
);
101 
            tr.Style.Add(HtmlTextWriterStyle.Height, 
"
30px
"
);
102 
            tr.Style.Add(HtmlTextWriterStyle.Padding, 
"
5
"
);
103 
            tr.Style.Add(HtmlTextWriterStyle.FontSize, 
"
14px
"
);
104 
            TableCell tc 
=
 
new
 TableCell();
105 
            tc.Text 
=
 column.CnName;
106 
            tr.Cells.Add(tc);
107 
            tc 
=
 
new
 TableCell();
108 
            
if
 (column.Type.ToLower() 
==
 
"
textbox
"
)
109 
            {
110 
                TextBox tb 
=
 
new
 TextBox();
111 
                tb.ID 
=
 column.Name;
112 
                tb.ToolTip 
=
 column.Tip;
113 
                tb.Style.Add(HtmlTextWriterStyle.Width, 
"
400px
"
);
114 
                tc.Controls.Add(tb);
115 
                
if
 (
!
column.AllowNull)
116 
                {
117 
                    Literal msg 
=
 
new
 Literal();
118 
                    msg.Text 
=
 
"
<font color=\
"
red\
"
>*</font>
"
;
119 
                    tc.Controls.Add(msg);
120 
                    RequiredFieldValidator rfv 
=
 
new
 RequiredFieldValidator();
121 
                    rfv.ControlToValidate 
=
 column.Name;
122 
                    rfv.ErrorMessage 
=
 
"
���������
"
;
123 
                    tc.Controls.Add(rfv);
124 
                }
125 
                
if
 (
!
string
.IsNullOrEmpty(column.Regex.Trim()))
126 
                {
127 
                    RegularExpressionValidator rev 
=
 
new
 RegularExpressionValidator();
128 
                    rev.ControlToValidate 
=
 column.Name;
129 
                    rev.ErrorMessage 
=
 
"
������������!
"
;
130 
                    rev.ValidationExpression 
=
 column.Regex;
131 
                    tc.Controls.Add(rev);
132 
                }
133 
                tr.Cells.Add(tc);
134 
            }
135 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
mtextbox
"
)
136 
            {
137 
                TextBox tb 
=
 
new
 TextBox();
138 
                tb.ID 
=
 column.Name;
139 
                tb.TextMode 
=
 TextBoxMode.MultiLine;
140 
                tb.ToolTip 
=
 column.Tip;
141 
                tb.Style.Add(HtmlTextWriterStyle.Width, 
"
90%
"
);
142 
                tb.Style.Add(HtmlTextWriterStyle.Height, 
"
30px
"
);
143 
                tc.Controls.Add(tb);
144 
                
if
 (
!
column.AllowNull)
145 
                {
146 
                    Literal msg 
=
 
new
 Literal();
147 
                    msg.Text 
=
 
"
<font color=\
"
red\
"
>*</font>
"
;
148 
                    tc.Controls.Add(msg);
149 
                    RequiredFieldValidator rfv 
=
 
new
 RequiredFieldValidator();
150 
                    rfv.ControlToValidate 
=
 column.Name;
151 
                    rfv.ErrorMessage 
=
 
"
���������
"
;
152 
                    tc.Controls.Add(rfv);
153 
                }
154 
                tr.Cells.Add(tc);
155 
            }
156 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
timetextbox
"
)
157 
            {
158 
159 
                Personal.Wgc.Diys.CommonDiyControls.DatePicker.DropDownDatePicker tb 
=
 
new
 Personal.Wgc.Diys.CommonDiyControls.DatePicker.DropDownDatePicker();
160 
                tb.Style.Add(HtmlTextWriterStyle.Width, 
"
200px
"
);
161 
                tb.ID 
=
 column.Name;
162 
                tc.Controls.Add(tb);
163 
                tr.Controls.Add(tc);
164 
            }
165 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
numbertextbox
"
)
166 
            {
167 
                Personal.Wgc.Diys.CommonDiyControls.DiyTextBox.NumberTextBox tb 
=
 
new
 Personal.Wgc.Diys.CommonDiyControls.DiyTextBox.NumberTextBox();
168 
                tb.Style.Add(HtmlTextWriterStyle.Width, 
"
200px
"
);
169 
                tb.ID 
=
 column.Name;
170 
                tb.ToolTip 
=
 column.Tip;
171 
                tc.Controls.Add(tb);
172 
                
if
 (
!
column.AllowNull)
173 
                {
174 
                    Literal msg 
=
 
new
 Literal();
175 
                    msg.Text 
=
 
"
<font color=\
"
red\
"
>*</font>
"
;
176 
                    tc.Controls.Add(msg);
177 
                    RequiredFieldValidator rfv 
=
 
new
 RequiredFieldValidator();
178 
                    rfv.ControlToValidate 
=
 column.Name;
179 
                    rfv.ErrorMessage 
=
 
"
���������
"
;
180 
                    tc.Controls.Add(rfv);
181 
                }
182 
                tr.Controls.Add(tc);
183 
            }
184 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
maxlengthtextbox
"
)
185 
            {
186 
                Personal.Wgc.Diys.CommonDiyControls.DiyTextBox.MaxLengthTextBox tb 
=
 
new
 Personal.Wgc.Diys.CommonDiyControls.DiyTextBox.MaxLengthTextBox();
187 
                tb.ID 
=
 column.Name;
188 
                
if
 (column.FText 
==
 
"
1
"
)
189 
                {
190 
                    tb.TextMode 
=
 TextBoxMode.MultiLine;
191 
                    tb.Style.Add(HtmlTextWriterStyle.Width, 
"
80%
"
);
192 
                    tb.Style.Add(HtmlTextWriterStyle.Height, 
"
50px
"
);
193 
                    
if
 (
!
string
.IsNullOrEmpty(column.FValue))
194 
                    {
195 
                        tb.Length 
=
 
int
.Parse(column.FValue);
196 
                    }
197 
                }
198 
                
else
199 
                {
200 
                    tb.Style.Add(HtmlTextWriterStyle.Width, 
"
400px
"
);
201 
                    
if
 (
!
string
.IsNullOrEmpty(column.FValue))
202 
                    {
203 
                        tb.MaxLength 
=
 
int
.Parse(column.FValue);
204 
                    }
205 
                }
206 
                tc.Controls.Add(tb);
207 
                
if
 (
!
column.AllowNull)
208 
                {
209 
                    Literal msg 
=
 
new
 Literal();
210 
                    msg.Text 
=
 
"
<font color=\
"
red\
"
>*</font>
"
;
211 
                    tc.Controls.Add(msg);
212 
                    RequiredFieldValidator rfv 
=
 
new
 RequiredFieldValidator();
213 
                    rfv.ControlToValidate 
=
 column.Name;
214 
                    rfv.ErrorMessage 
=
 
"
���������
"
;
215 
                    tc.Controls.Add(rfv);
216 
                }
217 
                tr.Cells.Add(tc);
218 
            }
219 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
autodatetime
"
)
220 
            {
221 
                TextBox tb 
=
 
new
 TextBox();
222 
                tb.Style.Add(HtmlTextWriterStyle.Width, 
"
200px
"
);
223 
                tb.Text 
=
 DateTime.Now.ToString();
224 
                tb.Enabled 
=
 
false
;
225 
                tb.ID 
=
 column.Name;
226 
                tb.ToolTip 
=
 column.Tip;
227 
                tc.Controls.Add(tb);
228 
                tr.Cells.Add(tc);
229 
            }
230 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
fck
"
)
231 
            {
232 
                FredCK.FCKeditorV2.FCKeditor fckEditor 
=
 
new
 FredCK.FCKeditorV2.FCKeditor();
233 
                fckEditor.ID 
=
 column.Name;
234 
                fckEditor.Width 
=
 
new
 Unit(
800
);
235 
                fckEditor.Height 
=
 
new
 Unit(
400
);
236 
                tc.Controls.Add(fckEditor);
237 
                tr.Cells.Add(tc);
238 
            }
239 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
dropdownlist
"
)
240 
            {
241 
                DropDownList ddl 
=
 
new
 DropDownList();
242 
                ddl.ID 
=
 column.Name;
243 
                SQLData sqldata 
=
 
new
 SQLData();
244 
                sqldata.SqlString 
=
 
"
select * from 
"
 
+
 column.FTable 
+
 
""
;
245 
                SqlDataReader dr 
=
 SqlHelper.ExecuteReader(SqlHelper.ConnString, sqldata);
246 
                
while
 (dr.Read())
247 
                {
248 
                    ddl.Items.Add(
new
 ListItem(dr[column.FText].ToString(), dr[column.FValue].ToString()));
249 
                }
250 
                dr.Close();
251 
                tc.Controls.Add(ddl);
252 
                tr.Cells.Add(tc);
253 
            }
254 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
key
"
)
255 
            {
256 
                tc.Text 
=
 
string
.Empty;
257 
                tr.Cells.Add(tc);
258 
            }
259 
            
else
 
if
 (
string
.IsNullOrEmpty(column.Type.Trim()))
260 
            {
261 
                tc.Text 
=
 
string
.Empty;
262 
                tr.Cells.Add(tc);
263 
            }
264 
            
else
 
if
 (column.Type.ToLower() 
==
 
"
file
"
)
265 
            {
266 
                
this
.ClientScript.RegisterClientScriptInclude(
"
jquery
"
,
"
http://www.cnblogs.com/js/jquery.js
"
);
267 
                
this
.ClientScript.RegisterClientScriptInclude(
"
moreFile
"
,
"
http://www.cnblogs.com/js/addmorefile.js
"
);
268 
                FileUpload file 
=
 
new
 FileUpload();
269 
                file.ID 
=
 column.Name;
270 
                HtmlInputButton inputButton 
=
 
new
 HtmlInputButton();
271 
                inputButton.Attributes.Add(
"
onclick
"
"
addFile()
"
);
272 
                inputButton.Attributes.Add(
"
value
"
"
������������
"
);
273 
                tc.Controls.Add(file);
274 
                tc.Controls.Add(inputButton);
275 
                HtmlGenericControl span 
=
 
new
 HtmlGenericControl(
"
span
"
);
276 
                span.ID 
=
 
"
moreFile
"
;
277 
                span.Style.Add(
"
margin-top
"
"
0px
"
);
278 
                tc.Controls.Add(span);
279 
                tr.Controls.Add(tc);
280 
            }
281 
            
if
 (column.Type.ToLower() 
==
 
"
key
"
 
||
 
string
.IsNullOrEmpty(column.Type.Trim()))
282 
            {
283 
                
//
���������������,������������������
284 
                
//
 donothing
285 
            }
286 
            
else
287 
            {
288 
                myTable.Rows.Add(tr);
289 
            }
290 
        }
291 
        TableRow trOperation 
=
 
new
 TableRow();
292 
        TableCell tcOperation 
=
 
new
 TableCell();
293 
        tcOperation.Text 
=
 
string
.Empty;
294 
        tcOperation.Style.Add(HtmlTextWriterStyle.BackgroundColor, 
"
white
"
);
295 
        trOperation.Cells.Add(tcOperation);
296 
        tcOperation 
=
 
new
 TableCell();
297 
        tcOperation.Style.Add(HtmlTextWriterStyle.BackgroundColor, 
"
white
"
);
298 
        Button buttonSave 
=
 
new
 Button();
299 
        buttonSave.Text 
=
 
"
��� ���
"
;
300 
        buttonSave.Click
+=
new
 EventHandler(buttonSave_Click);
301 
        Literal backButton 
=
 
new
 Literal();
302 
        backButton.Text 
=
 
"
&nbsp;<input type=\
"
button\
"
 value=\
"
������\
"
 onclick=\
"
location
=
'
commonquery.aspx?id=" + Request.QueryString["id"] + "
'
\
"
/>
"
;
303 
        tcOperation.Controls.Add(buttonSave);
304 
        tcOperation.Controls.Add(backButton);
305 
        trOperation.Controls.Add(tcOperation);
306 
        myTable.Rows.Add(trOperation);
307 
        contentPlaceHolder.Controls.Add(myTable);
308 
    }
309 
    
protected
 
void
 buttonSave_Click(
object
 sender, EventArgs e)
310 
    {
311 
        
//
������������������������������
312 
        
string
 id 
=
 Guid.NewGuid().ToString();
313 
        
//
���������������
314 
        List
<
Personal.Wgc.Diys.Model.T_DATA
>
 fileList 
=
 
new
 List
<
Personal.Wgc.Diys.Model.T_DATA
>
();
315 
316 
        List
<
T_COLUMN
>
 columnList 
=
 (List
<
T_COLUMN
>
)ViewState[
"
columnList
"
];
317 
        
318 
        
if
 (columnList.Count 
>
 
0
)
319 
        {
320 
            List
<
DbParameter
>
 sqlParameterList 
=
 
new
 List
<
DbParameter
>
();
321 
            StringBuilder sql 
=
 
new
 StringBuilder();
322 
            StringBuilder paras 
=
 
new
 StringBuilder();
323 
            paras.Append(
"
values (
"
);
324 
            sql.Append(
"
insert into 
"
);
325 
            sql.Append(columnList[
0
].TableName);
326 
            sql.Append(
"
(
"
);
327 
            
foreach
 (T_COLUMN column 
in
 columnList)
328 
            {
329 
                
//
������������������������
330 
                
if
 (
!
string
.IsNullOrEmpty(column.Type.Trim()))
331 
                {
332 
                    
//
������������������
333 
                    
if
 (column.Type.ToLower() 
!=
 
"
file
"
)
334 
                    {
335 
                        sql.Append(column.Name);
336 
                        sql.Append(
"
,
"
);
337 
                        paras.Append(
"
@
"
);
338 
                        paras.Append(column.Name);
339 
                        paras.Append(
"
,
"
);
340 
                    }
341 
                    
else
342 
                    { 
343 
                     
//
������������
344 
                        Personal.Wgc.Diys.Model.T_DATA file;
345 
                        
for
 (
int
 i 
=
 
0
; i 
<
 Request.Files.Count; i
++
)
346 
                        {
347 
                            
//
���������������������
348 
                            
if
 (
!
string
.IsNullOrEmpty(Request.Files[i].FileName))
349 
                            {
350 
                                file 
=
 
new
 Personal.Wgc.Diys.Model.T_DATA();
351 
                                file.ID 
=
 Guid.NewGuid().ToString();
352 
                                file.LINKID 
=
 id;
353 
                                file.NAME 
=
 Request.Files[i].FileName.Substring(Request.Files[i].FileName.LastIndexOf(
"
\\
"
+
 
1
);
354 
                                file.SUFFIX 
=
 Request.Files[i].FileName.Substring(Request.Files[i].FileName.LastIndexOf(
'
.
'
+
 
1
).ToLower();
355 
                                
byte
[] fileContent 
=
 
new
 
byte
[Request.Files[i].ContentLength];
356 
                                Request.Files[i].InputStream.Read(fileContent, 
0
, fileContent.Length);
357 
                                file.CONTENT 
=
 fileContent;
358 
                                fileList.Add(file);
359 
                            }
360 
                        }
361 
                    }
362 
                }
363 
                
//
-------------------parameters deal
364 
                
if
 (column.Type.ToLower() 
==
 
"
textbox
"
 
||
 column.Type.ToLower() 
==
 
"
mtextbox
"
 
||
 column.Type.ToLower() 
==
 
"
numbertextbox
"
 
||
 column.Type.ToLower() 
==
 
"
moneytextbox
"
 
||
 column.Type.ToLower() 
==
 
"
maxlengthtextbox
"
 
||
 column.Type.ToLower() 
==
 
"
autodatetime
"
)
365 
                {
366 
                    TextBox tb 
=
 
this
.FindControl(column.Name) 
as
 TextBox;
367 
                    
if
 (tb 
!=
 
null
)
368 
                    {
369 
                        sqlParameterList.Add(
new
 SqlParameter(
"
@
"
 
+
 column.Name, WebUtility.CleanString(tb.Text.Trim())));
370 
                    }
371 
                }
372 
                
else
 
if
 (column.Type.ToLower() 
==
 
"
dropdownlist
"
)
373 
                {
374 
                    DropDownList ddl 
=
 
this
.FindControl(column.Name) 
as
 DropDownList;
375 
                    
if
 (ddl 
!=
 
null
)
376 
                    {
377 
                        sqlParameterList.Add(
new
 SqlParameter(
"
@
"
 
+
 column.Name, ddl.SelectedValue));
378 
                    }
379 
                }
380 
                
else
 
if
 (column.Type.ToLower() 
==
 
"
fck
"
)
381 
                {
382 
                    FredCK.FCKeditorV2.FCKeditor fck 
=
 
this
.FindControl(column.Name) 
as
 FredCK.FCKeditorV2.FCKeditor;
383 
                    
if
 (fck 
!=
 
null
)
384 
                    {
385 
                        sqlParameterList.Add(
new
 SqlParameter(
"
@
"
 
+
 column.Name,WebUtility.CleanString(fck.Value)));
386 
                    }
387 
                }
388 
                
else
 
if
 (column.Type.ToLower() 
==
 
"
timetextbox
"
)
389 
                {
390 
                    TextBox tb 
=
 
this
.FindControl(column.Name) 
as
 TextBox;
391 
                    
if
 (tb 
!=
 
null
)
392 
                    {
393 
                        sqlParameterList.Add(
new
 SqlParameter(
"
@
"
 
+
 column.Name, WebUtility.CleanString(tb.Text.Trim())));
394 
                    }
395 
                }
396 
                
else
 
if
 (column.Type.ToLower() 
==
 
"
key
"
)
397 
                {
398 
                    sqlParameterList.Add(
new
 SqlParameter(
"
@
"
 
+
 column.Name, id));
399 
                }
400 
                
else
401 
                {
402 
                    
//
������������������������������
403 
                }
404 
            }
405 
            sql.Remove(sql.Length 
-
 
1
1
);
406 
            sql.Append(
"
)
"
);
407 
            paras.Remove(paras.Length 
-
 
1
1
);
408 
            paras.Append(
"
)
"
);
409 
            SQLData sqldata 
=
 
new
 SQLData();
410 
            sqldata.SqlString 
=
 sql.ToString() 
+
 paras.ToString();
411 
            sqldata.SqlParameter 
=
 sqlParameterList;
412 
            
try
413 
            {
414 
                
if
 (SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, sqldata) 
>
 
0
)
415 
                {
416 
                    
//
���������������
417 
                    
if
 (fileList.Count 
>
 
0
)
418 
                    {
419 
                        List
<
SQLData
>
 sqldataList 
=
 
new
 List
<
SQLData
>
();
420 
                        
foreach
 (Personal.Wgc.Diys.Model.T_DATA item 
in
 fileList)
421 
                        {
422 
                            
if
 (item.SUFFIX 
!=
 
"
exe
"
 
&&
 item.SUFFIX 
!=
 
"
jar
"
 
&&
 item.SUFFIX 
!=
 
"
dll
"
)
423 
                            {
424 
                                sqldata 
=
 
new
 SQLData();
425 
                                sqldata.SqlString 
=
 
"
insert into t_data(id,linkid,suffix,name,content) values(@id,@linkid,@suffix,@name,@content)
"
;
426 
                                sqldata.SqlParameter.Add(
new
 SqlParameter(
"
@id
"
, item.ID));
427 
                                sqldata.SqlParameter.Add(
new
 SqlParameter(
"
@linkid
"
,id));
428 
                                sqldata.SqlParameter.Add(
new
 SqlParameter(
"
@suffix
"
,item.SUFFIX));
429 
                                sqldata.SqlParameter.Add(
new
 SqlParameter(
"
@name
"
, item.NAME));
430 
                                sqldata.SqlParameter.Add(
new
 SqlParameter(
"
@content
"
, item.CONTENT));
431 
                                sqldataList.Add(sqldata);
432 
                            }
433 
                        }
434 
                        
if
 (sqldataList.Count 
>
 
0
)
435 
                        {
436 
                            
try
437 
                            {
438 
                                SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, sqldataList);
439 
                            }
440 
                            
catch
441 
                            { 
442 
                             
//
 do nothing
443 
                            }
444 
                        }
445 
                    }
446 
                    
this
.ClientScript.RegisterClientScriptBlock(GetType(), 
"
add
"
"
alert('������������');location='commonquery.aspx?id=
"
 
+
 Request.QueryString[
"
id
"
+
 
"
'
"
true
);
447 
                }
448 
                
else
449 
                {
450 
                    
this
.ClientScript.RegisterClientScriptBlock(GetType(), 
"
add
"
"
alert('������������')
"
true
);
451 
                }
452 
            }
453 
            
catch
454 
            {
455 
                
this
.ClientScript.RegisterClientScriptBlock(GetType(), 
"
add
"
"
alert('������������������������')
"
true
);
456 
            }
457 
        }
458 
    }
459 
}
460 

 

 ������������������������������xml������������������������������iexplorer.exe������������������350M���������������������������������������������������������������������������������������������������������������������������������������������XDJM���������������������xml���������������������������������������������������

 

上一篇:不写一行代码,实现单表增删改查(附demo)
下一篇:【译】.NET 跨平台界面框架和为什么你首先要考虑再三

发表评论

最新留言

很好
[***.229.124.182]2025年04月17日 01时07分26秒