Implement. net cms system Article 3-core source code

Source: Internet
Author: User

1 using System;
2 using System. Collections. Generic;
3 using System. Linq;
4 using System. Text;
5
6 namespace Aspx. Web
7 {
8 public class Condition // Condition object for returning data
9 {
10 /// <summary>
11 // data table name
12 /// </summary>
13 private string _ TblName = "";
14 public string TblName
15 {
16 get {return _ TblName ;}
17 set {_ TblName = value ;}
18}
19 /// <summary>
20 /// field name in the table
21 /// </summary>
22 private string _ Filed = "";
23 public string Field
24 {
25 get {return _ Filed ;}
26 set {_ Filed = value ;}
27}
28 /// <summary>
29 // whether the page is displayed
30 /// </summary>
31 private bool _ Page = false;
32 public bool Page
33 {
34 get {return _ Page ;}
35 set {_ Page = value ;}
36}
37 // <summary>
38 // The number of lines per page
39 /// </summary>
40 private int _ Num = 10;
41 public int Num
42 {
43 get {return _ Num ;}
44 set {_ Num = value ;}
45}
46 // <summary>
47 // sorting method
48 /// </summary>
49 private string _ Sort = "";
50 public string Sort
51 {
52 get {return _ Sort ;}
53 set {_ Sort = value ;}
54}
55 /// <summary>
56 // query Conditions
57 /// </summary>
58 private string _ Where = "";
59 public string Where
60 {
61 get {return _ Where ;}
62 set {_ Where = value ;}
63}
64 /// <summary>
65 // enter the name of the input parameter in the current address bar for retrieval.
66 /// </summary>
67 private string _ GetKey = "";
68 public string GetKey
69 {
70 get {return _ GetKey ;}
71 set {_ GetKey = value ;}
72}
73}
74 public class _ Model: Condition
75 {
76 public string Aspx (string htmlContent)
77 {
78 string html = "";
79 switch (TblName)
80 {
81 case "News": html = Html_News (htmlContent); break;
82 // expand tables
83 // case "About": html = Html_About (htmlContent); break;
84 default: break;
85}
86 return html;
87}
88 private string GetWhere ()
89 {
90 string strWhere = "";
91 // encapsulate query Conditions
92 return strWhere;
93}
94 private string GetSort ()
95 {
96 string strSort = "";
97 // encapsulate the sorting method
98 return strSort;
99}
100
101 # region News data
102 private string Html_News (string htmlContent)
103 {
104 string html = "";
105 List <News> list_News = null; // obtain the News data source here, you know.
106 foreach (News n in list_News)
107 {
108 html + = String. Format (htmlContent, Replace_News (n ));
109}
110 return html;
111}
112 private string [] Replace_News (News n)
113 {
114 List <string> list_Str = null;
115 if (Field! = "")
116 {
117 foreach (string s in Field. Split (','))
118 {
119 string str = "";
120 switch (s)
121 {
122 case "NewsID": str = n. NewsID. ToString (); break;
123 case "Title": str = n. Title; break;
124 case "Content": str = n. Content; break;
125 case "Time": str = n. Time. ToString (); break;
126 default: break;
127}
128 list_Str.Add (str );
129}
130 string [] arr_Str = new string [list_Str.Count];
131 for (int I = 0; I <list_Str.Count; I ++)
132 {
133 arr_Str [I] = list_Str [I]. ToString ();
134}
135 return arr_Str;
136}
137 else
138 {
139 string [] arr_Str = new string [] {"enter the Field "};
140 return arr_Str;
141}
142}
143 # endregion
144
145 # region
146 # endregion
147}
148 public class News
149 {
150 private int-NewsID;
151 public int NewsID
152 {
153 get {return _ NewsID ;}
154 set {_ NewsID = value ;}
155}
156 private string _ Title;
157 public string Title
158 {
159 get {return _ Title ;}
160 set {_ Title = value ;}
161}
162 private string _ Content;
163 public string Content
164 {
165 get {return _ Content ;}
166 set {_ Content = value ;}
167}
168 private DateTime _ Time;
169 public DateTime Time
170 {
171 get {return _ Time ;}
172 set {_ Time = value ;}
173}
174}
175 public class About
176 {
177
178}
179}
 
From 19 shore

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.