using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Text; using System.Configuration; namespace PublicPageSet { /// <summary> /// 对每页的Title进行设置 /// </summary> public class PageSet { public string GetPageSet(string strTitle) { return GetPageSetHtml(strTitle, ""); } public string GetPageSet(string strTitle, string strHappylink) { return GetPageSetHtml(strTitle, strHappylink); }
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Configuration;
namespace PublicPageSet
{
/// <summary>
/// 对每页的Title进行设置
/// </summary>
public class PageSet
{
public string GetPageSet(string strTitle)
{
return GetPageSetHtml(strTitle, "");
}
public string GetPageSet(string strTitle, string strHappylink)
{
return GetPageSetHtml(strTitle, strHappylink);
}
private string GetPageSetHtml(string strTitle, string strHappylink)
{
//获得项目名称
string strbItemName = ConfigurationSettings.AppSettings["ItemName"].ToString();
StringBuilder sbText = new StringBuilder();
sbText.Append(" <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"LEFT:6px;POSITION:relative\">");
sbText.Append(" <tr>");
sbText.Append(" <td width=\"20\"><img src=\"/"+ strbItemName +"/Images/036.gif\" width=\"20\" height=\"21\"></td>");
sbText.Append(" <td background=\"/"+ strbItemName +"/Images/037.gif\"><nobr style=\"POSITION:relative;TOP:2px\"> "+ strTitle +" ");
if(strHappylink != "")
{
sbText.Append("<span style=\"cursor:hand\" title=\"系统帮助\" onclick=\"window.open('"+ strHappylink +"','_blank','height=440,width=580,resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no')\"><b style=\"position:relative;top:-1px\">?</b> 帮助</span>");
}
sbText.Append(" </nobr></td>");
sbText.Append(" <td width=\"21\"><img src=\"/"+ strbItemName +"/Images/038.gif\" width=\"12\" height=\"21\"></td>");
sbText.Append(" </tr>");
sbText.Append(" </table>");
sbText.Append(" <br>");
return sbText.ToString();
}
} /// <summary>
/// 对页面元素进行样式设置
/// </summary>
public class ElementStyle
{ /// <summary>
/// 对DataGrid进行样式设置
/// </summary>
public void DataGridStyle(DataGrid ThisElement)
{
getDataGridStyle(ThisElement, 0);
}
public void DataGridStyle(DataGrid ThisElement, int Pages)
{
getDataGridStyle(ThisElement, Pages);
}
private void getDataGridStyle(DataGrid ThisElement, int ThisPages)
{
//获得项目名称
string strbItemName = ConfigurationSettings.AppSettings["ItemName"].ToString();
string DataGridBorderColor = "#bdbabd"; //DataGrid 边框的颜色
int DataGridBorderWidth = 1;
int DataGridCellPadding = 5; //DataGrid 行间距
int DataGridFontSize = 9; //DataGrid 文字的大小
string DataGridwidth = "100%"; //DataGrid 宽度 string DataGridHeaderBackgroundImg = "/"+ strbItemName +"/Images/055.gif"; //DataGrid 标题栏背景图片
int DataGridHeaderHeight = 25; //DataGrid 标题栏高度
HorizontalAlign DataGridHeaderAlign = HorizontalAlign.Center; //DataGrid 标题栏文字的位置(居中,靠左,靠右)
string DataGridHeaderFontColor = "#000000"; //DataGrid 标题栏文字颜色 string DataGridItemBackColor = "#FFFFFF"; //DataGrid 列表栏背景色
int DataGridItemHeight = 25; //DataGrid 列表栏的高度
string DataGridItemFontColor = "#000000"; //DataGrid 列表栏的文字颜色 string DataGridItemSwepBackColor = "#f7f3ef"; //DataGrid 列表栏过渡栏的背景色
int DataGridItemSwepHeight = 25; //DataGrid 列表栏过渡栏的高度
string DataGridItemSwepFontColor = "#000000"; //DataGrid 列表栏过渡栏的文字颜色
ThisElement.BorderColor = Color.FromName(DataGridBorderColor);
ThisElement.BorderWidth = DataGridBorderWidth;
ThisElement.CellPadding = DataGridCellPadding;
ThisElement.Font.Size = DataGridFontSize;
ThisElement.Attributes["width"] = DataGridwidth; ThisElement.Attributes["style"] = "background-image: url('"+ DataGridHeaderBackgroundImg +"')";
ThisElement.HeaderStyle.Height = DataGridHeaderHeight;
ThisElement.HeaderStyle.HorizontalAlign = DataGridHeaderAlign;
ThisElement.HeaderStyle.ForeColor = Color.FromName(DataGridHeaderFontColor); ThisElement.ItemStyle.BackColor = Color.FromName(DataGridItemBackColor);
ThisElement.ItemStyle.Height = DataGridItemHeight;
ThisElement.ItemStyle.ForeColor = Color.FromName(DataGridItemFontColor); ThisElement.AlternatingItemStyle.BackColor = Color.FromName(DataGridItemSwepBackColor);
ThisElement.AlternatingItemStyle.Height = DataGridItemSwepHeight;
ThisElement.AlternatingItemStyle.ForeColor = Color.FromName(DataGridItemSwepFontColor); ThisElement.DataBind();
if(ThisPages != 0)
{ ThisElement.PageSize = ThisPages;
ThisElement.AllowPaging = true;
ThisElement.Height = 35;
ThisElement.PagerStyle.VerticalAlign = VerticalAlign.Bottom;
ThisElement.PagerStyle.HorizontalAlign = HorizontalAlign.Right;
ThisElement.PagerStyle.BackColor = Color.FromName("#F7F3F3");
ThisElement.DataBind();
int ThisDataGridPage = 1;
if(HttpContext.Current.Request.Form["DataGridPageSize"] != null)
{
try
{
ThisDataGridPage = Convert.ToInt32(HttpContext.Current.Request.Form["DataGridPageSize"].ToString().Trim());
if(ThisDataGridPage < 1)
{
ThisDataGridPage = 1;
}
if(ThisDataGridPage > ThisElement.PageCount)
{
ThisDataGridPage = ThisElement.PageCount;
}
}
catch(Exception)
{
ThisDataGridPage = 1;
}
}
ThisElement.CurrentPageIndex = ThisDataGridPage;
//页面信息
string strThisPageName = "<span style='color:#ff0000'>"+ ThisDataGridPage.ToString() +"</span>";
string strApageCount = "<span style='color:#ff0000'>"+ ThisElement.PageSize.ToString() +"</span>";
string strAllPage = "<span style='color:#ff0000'>"+ ThisElement.PageCount.ToString() +"</span>";
string strPageInfo = "当前是 "+ strThisPageName +"/"+ strAllPage +" 每页显示 "+ strApageCount +" 条";
//第一页
string strPage1 = "<span onMouseover=this.style.color='#ff0000' onMouseout=this.style.color='#000000' onclick='document.all.DataGridPageSize.value = 1;document.all.tags(\"form\")[0].submit();' style='cursor:hand'>第一页</span>";
if(ThisDataGridPage == 1)
{
strPage1 = "<span disabled>第一页</span>";
} //上一页
string strPage2 = "<span onMouseover=this.style.color='#ff0000' onMouseout=this.style.color='#000000' onclick='document.all.DataGridPageSize.value = "+ Convert.ToString(ThisDataGridPage-1) +";document.all.tags(\"form\")[0].submit();' style='cursor:hand'>上一页</span>";
if(ThisDataGridPage == 1)
{
strPage2 = "<span disabled>上一页</span>";
} //下一页
string strPage3 = "<span onMouseover=this.style.color='#ff0000' onMouseout=this.style.color='#000000' onclick='document.all.DataGridPageSize.value = "+ Convert.ToString(ThisDataGridPage+1) +";document.all.tags(\"form\")[0].submit();' style='cursor:hand'>下一页</span>";
if(ThisDataGridPage == ThisElement.PageCount)
{
strPage3 = "<span disabled>下一页</span>";
} //最后一页
string strPage4 = "<span onMouseover=this.style.color='#ff0000' onMouseout=this.style.color='#000000' onclick='document.all.DataGridPageSize.value = "+ ThisElement.PageCount.ToString() +";document.all.tags(\"form\")[0].submit();' style='cursor:hand'>最后一页</span>";
if(ThisDataGridPage == ThisElement.PageCount)
{
strPage4 = "<span disabled>最后一页</span>";
} //跳到
string strGotoPage = "跳转到 <input type='text' name='DataGridPageSize' style='width:20px'>";
StringBuilder PageText = new StringBuilder();
PageText.Append("</a><span onselectstart='return false'>"+ strPageInfo +" "+ strPage1 +" "+ strPage2 +" "+ strPage3 +" "+ strPage4 +" "+ strGotoPage +"</span><a>"); ThisElement.PagerStyle.NextPageText = PageText.ToString();
ThisElement.CurrentPageIndex = ThisDataGridPage - 1;
//添加分页设置
ThisElement.PagerStyle.NextPageText = PageText.ToString();
ThisElement.PagerStyle.PrevPageText = "";
}
}
} /// <summary>
/// 对功能菜单进行样式设置
/// </summary>
public class MenuStyle
{
/// <summary>
/// 对每页的功能菜单进行页面设置
/// </summary>
public string functionMenuSet(string[] strArayText)
{
//获得项目名称
string strbItemName = ConfigurationSettings.AppSettings["ItemName"].ToString();
StringBuilder sbText = new StringBuilder();
sbText.Append(" <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"position:relative;top:-3px;\">");
sbText.Append(" <tr>");
sbText.Append(" <td width=\"7\"><img src=\"/"+ strbItemName +"/Images/056.gif\" width=\"7\" height=\"25\"></td>"); //定义分解的字符
char[] charAraySplit = new char[1];
charAraySplit[0] = '|'; for(int i=0;i<strArayText.Length;i++)
{
sbText.Append(" <td background=\"/"+ strbItemName +"/Images/058.gif\" width=\"1\" Id=\"Menus"+ i.ToString() +"\" ");
//判断用户是否定义该字段为隐藏菜单项
if(strArayText[i].Split(charAraySplit[0])[2].ToString() == "0")
{
sbText.Append("style=\"display:none\"");
}
sbText.Append(" >");
sbText.Append(" <table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"cursor:hand\" onMouseOver=\"this.rows[0].cells[1].style.color='#FF0000'\" onMouseOut=\"this.rows[0].cells[1].style.color='#000000'\" onclick=\""+ strArayText[i].Split(charAraySplit[0])[1].ToString() +"\">");
sbText.Append(" <tr>");
sbText.Append(" <td valign=\"bottom\" width=\"13\"><img src=\"/"+ strbItemName +"/Images/059.gif\" width=\"13\" height=\"13\"></td>");
sbText.Append(" <td valign=\"bottom\"><nobr style=\"position:relative;top:2px;\">"+ strArayText[i].Split(charAraySplit[0])[0].ToString() +"</nobr></td>");
sbText.Append(" <td valign=\"bottom\" width=\"2\"></td>");
sbText.Append(" </tr>");
sbText.Append(" </table>");
sbText.Append(" </td>");
} sbText.Append(" <td background=\"/"+ strbItemName +"/Images/058.gif\"> </td>");
sbText.Append(" <td width=\"7\"><img src=\"/"+ strbItemName +"/Images/057.gif\" width=\"7\" height=\"25\"></td>");
sbText.Append(" </tr>");
sbText.Append(" </table>");
return sbText.ToString();
}
}
}
不知道有没有别的好办法。
CREATE procedure MyPro_GetUNDP_CX
(@year NVarChar,
@pagesize int ,
@pageindex int,
@docount bit)中的 @year nvarchar,
改为:
@year nvarchar(20)