CodematicDemo2.0 的PageControl -1

来源:互联网 发布:虎豹骑 优化 编辑:程序博客网 时间:2024/04/25 17:43

Source Code Of Navigation01.cs

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gauss.PageControl
{
    [DefaultProperty(
""), ToolboxData("<{0}:Navigation01 runat=server></{0}:Navigation01>")]
    
public class Navigation01 : WebControl
    
{
       
// Fields
        private string key_Str;
        
private string page_Add;
        
private string page_Delete;
        
private string page_Index;
        
private Mode page_Mode;
        
private string page_Modify;
        
private string page_Search;
        
private string page_Show;
        
private int page_width;
        
private string para_Str;
        
private string table_Name;

        
// Nested Types
        public enum Mode
        
{
            Add,
            Modify,
            Delete,
            Search,
            Show
        }

        
public Navigation01()
        
{
            
this.page_Index = "index.aspx";
            
this.page_Add = "add.aspx";
            
this.page_Delete = "delete.aspx";
            
this.page_Modify = "modify.aspx";
            
this.page_Search = "search.aspx";
            
this.page_Show = "show.aspx";
            
this.page_width = 600;
        }

        
public string Key_Str
        
{
            
get
            
{
                
return this.key_Str;
            }

            
set
            
{
                
this.key_Str = value;
            }

        }

        
public string Page_Add
        
{
            
get
            
{
                
return this.page_Add;
            }

            
set
            
{
                
this.page_Add = value;
            }

        }

        
public string Page_Delete
        
{
            
get
            
{
                
return this.page_Delete;
            }

            
set
            
{
                
this.page_Delete = value;
            }

        }

        
public string Page_Index
        
{
            
get
            
{
                
return this.page_Index;
            }

            
set
            
{
                
this.page_Index = value;
            }

        }

        
public Navigation01.Mode Page_Mode
        
{
            
get
            
{
                
return this.page_Mode;
            }

            
set
            
{
                
this.page_Mode = value;
            }

        }

        
public string Page_Modify
        
{
            
get
            
{
                
return this.page_Modify;
            }

            
set
            
{
                
this.page_Modify = value;
            }

        }

        
public string Page_Search
        
{
            
get
            
{
                
return this.page_Search;
            }

            
set
            
{
                
this.page_Search = value;
            }

        }

        
public string Page_Show
        
{
            
get
            
{
                
return this.page_Show;
            }

            
set
            
{
                
this.page_Show = value;
            }

        }

        [DefaultValue(
""), Bindable(true), Category("Appearance")]
        
public int Page_Width
        
{
            
get
            
{
                
return this.page_width;
            }

            
set
            
{
                
this.page_width = value;
            }

        }

        
public string Para_Str
        
{
            
get
            
{
                
return this.para_Str;
            }

            
set
            
{
                
this.para_Str = value;
            }

        }

        
public string Table_Name
        
{
            
get
            
{
                
return this.table_Name;
            }

            
set
            
{
                
this.table_Name = value;
            }

        }


        
protected override void Render(HtmlTextWriter output)
        
{
            StringBuilder builder1 
= new StringBuilder("");
            builder1.Append(
"<table width="" + this.page_width + "" border="0" cellspacing="0" cellpadding="0" align="center">");
            builder1.Append(
"<tr>");
            builder1.Append(
"<td height="22" width="228">");
            builder1.Append(
"<font color="#CCCCCC">≡ ≡</font>");
            builder1.Append(
"</td>");
            builder1.Append(
"<td height="22">");
            
if (this.Page_Add != "")
            
{
                builder1.Append(
"<div align="right">");
                
if (this.Page_Mode == Navigation01.Mode.Add)
                
{
                    builder1.Append(
" [ <font color="#CCCCCC">添加</font>");
                }

                
else
                
{
                    builder1.Append(
" [ <a href="" + this.Page_Add + "?" + this.Para_Str + "">添加</a>");
                }

                builder1.Append(
" ]");
            }

            
if (this.Page_Delete != "")
            
{
                
if (this.Page_Mode == Navigation01.Mode.Add)
                
{
                    builder1.Append(
" [ <font color="#CCCCCC">删除</font>");
                }

                
else
                
{
                    builder1.Append(
" [ <a href="" + this.Page_Delete + "?" + this.Para_Str + "" onClick="if (!window.confirm('您真的要删除这条记录吗?')){return false;}">删除</a>");
                }

                builder1.Append(
" ]");
            }

            
if (this.Page_Modify != "")
            
{
                
if ((this.Page_Mode == Navigation01.Mode.Add) || (this.Page_Mode == Navigation01.Mode.Modify))
                
{
                    builder1.Append(
" [ <font color="#CCCCCC">修改</font>");
                }

                
else
                
{
                    builder1.Append(
" [ <a href="" + this.Page_Modify + "?" + this.Para_Str + "">修改</a>");
                }

                builder1.Append(
" ]");
            }

            
if (this.Page_Show != "")
            
{
                
if ((this.Page_Mode == Navigation01.Mode.Add) || (this.Page_Mode == Navigation01.Mode.Modify))
                
{
                    builder1.Append(
" [ <a href="" + this.Page_Show + "?" + this.Para_Str + "">取消</a>");
                }

                
else
                
{
                    builder1.Append(
" [ <font color="#CCCCCC">取消</font>");
                }

                builder1.Append(
" ]");
            }

            builder1.Append(
" [ <a href="" + this.Page_Index + "">返回</a> ] </div>");
            builder1.Append(
"</td></tr></table>");
            output.Write(builder1.ToString());
        }

    }


}

 Source Code of Page01.cs

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Gauss.PageControl
{
    [DefaultProperty(
"Text")]
    [ToolboxData(
"<{0}:Page01 runat=server></{0}:Page01>")]
    
public class Page01 : WebControl
    
{
        
// Fields
        private string page_Add;
        
private int page_Count;
        
private int page_Current;
        
private string page_Index;
        
private string page_Makesql;
        
private string page_Search;
        
private int page_Size;
        
private int page_width;
        
private int record_Count;

        
public Page01()
        
{
            
this.page_Size = 10;
            
this.page_Current = 1;
            
this.page_Index = "index.aspx";
            
this.page_Add = "add.aspx";
            
this.page_Search = "search.aspx";
            
this.page_Makesql = "makesql.aspx";
            
this.page_width = 700;
        }

        
public string Page_Add
        
{
            
get
            
{
                
return this.page_Add;
            }

            
set
            
{
                
this.page_Add = value;
            }

        }

        
public int Page_Count
        
{
            
get
            
{
                
return this.page_Count;
            }

            
set
            
{
                
this.page_Count = value;
            }

        }

        
public int Page_Current
        
{
            
get
            
{
                
return this.page_Current;
            }

            
set
            
{
                
this.page_Current = value;
            }

        }

        
public string Page_Index
        
{
            
get
            
{
                
return this.page_Index;
            }

            
set
            
{
                
this.page_Index = value;
            }

        }

        
public string Page_Makesql
        
{
            
get
            
{
                
return this.page_Makesql;
            }

            
set
            
{
                
this.page_Makesql = value;
            }

        }


        
public string Page_Search
        
{
            
get
            
{
                
return this.page_Search;
            }

            
set
            
{
                
this.page_Search = value;
            }

        }

        
public int Page_Size
        
{
            
get
            
{
                
return this.page_Size;
            }

            
set
            
{
                
this.page_Size = value;
            }

        }

        [DefaultValue(
""), Bindable(true), Category("Appearance")]
        
public int Page_Width
        
{
            
get
            
{
                
return this.page_width;
            }

            
set
            
{
                
this.page_width = value;
            }

        }


        
public int Record_Count
        
{
            
get
            
{
                
return this.record_Count;
            }

            
set
            
{
                
this.record_Count = value;
            }

        }

        
protected override void Render(HtmlTextWriter output)
        
{
            StringBuilder builder1 
= new StringBuilder("");
            builder1.Append(
"<table width="" + this.page_width + "" border="0" cellspacing="0" cellpadding="2" align="center" height="22"> ");
            builder1.Append(
" <tr> ");
            builder1.Append(
" <td width="28%">");
            builder1.Append(
string.Concat(new object[] "○ 共"this.Record_Count, "条,共"this.Page_Count, "页,第<font color="#e78a29">"this.Page_Current, "</font>页</td> " }));
            builder1.Append(
" <td width="72%">");
            builder1.Append(
" <div align="right"> ");
            
if (this.Page_Makesql != "")
            
{
                builder1.Append(
" [ <a href=" + this.Page_Makesql + ">全部</a> ]&nbsp; ");
            }

            
if (this.Page_Add != "")
            
{
                builder1.Append(
" [ <a href=" + this.Page_Add + ">添加</a> ]&nbsp; ");
            }

            
if (this.Page_Search != "")
            
{
                builder1.Append(
" [ <a href=" + this.Page_Search + ">搜索</a> ]&nbsp; ");
            }

            builder1.Append(
" [ <a href=" + this.Page_Index + ">刷新</a> ]&nbsp;&nbsp;[");
            
if (this.Page_Current > 1)
            
{
                builder1.Append(
" <a href=" + this.Page_Index + "?page=1>首页</a> ");
            }

            
else
            
{
                builder1.Append(
" <font color=#cccccc>首页</font>  ");
            }

            builder1.Append(
"]&nbsp;[");
            
if ((this.Page_Current - 1> 0)
            
{
                builder1.Append(
string.Concat(new object[] " <a href="this.Page_Index, "?page="this.Page_Current - 1">上页</a> " }));
            }

            
else
            
{
                builder1.Append(
" <font color=#cccccc>上页</font>  ");
            }

            builder1.Append(
"]&nbsp;[");
            
if ((this.Page_Current + 1<= this.Page_Count)
            
{
                builder1.Append(
string.Concat(new object[] " <a href="this.Page_Index, "?page="this.Page_Current + 1">下页</a>  " }));
            }

            
else
            
{
                builder1.Append(
" <font color=#cccccc>下页</font>  ");
            }

            builder1.Append(
"]&nbsp;[");
            
if (this.Page_Current < this.Page_Count)
            
{
                builder1.Append(
string.Concat(new object[] " <a href="this.Page_Index, "?page="this.Page_Count, ">尾页</a> " }));
            }

            
else
            
{
                builder1.Append(
" <font color=#cccccc>尾页</font> ");
            }

            builder1.Append(
"]");
            builder1.Append(
" </div> ");
            builder1.Append(
" </td> ");
            builder1.Append(
" </tr>");
            builder1.Append(
"</table> ");
            output.Write(builder1.ToString());
        }



    }

}