
2007年5月30日
下面是在考虑公司内部的协作平台时的选型说明,贴出来供有需要的弟兄参考。
“软件开发协作平台”需求是
a.支持项目管理、BUG及用户支持管理;b.内部公告;c.可定制流程、可自定义字段;d.权限控制;e.Email通知及监控 f.统计报表及导出 g.最好易扩展
狂找一顿后的选型结果就是:“URTracker+Excel”。0321Update:最终还是“Mantis+Excel”了,考虑到URTracker收费的问题,因为要推广到全公司5个帐号就不够了。
具体操作的模式是:用excel来做项目计划、任务分解、记录指派、进度总结;用URTracker来分派任务并作进度反馈/跟踪。其中用“分级/组合”的效果可以做出像project那样任务分级下拉、收起的效果,用“数据透视表”可以方便实现统计分析的效果。project就没必要用了,常用的功能无非就是那几个,实在不需要这么庞大无聊的东西,excel就很好用。
注:选它的理由,是它可以很方便的定制流程、自定义字段,而且把项目管理和bug管理、需求管理都可以通过定制的方式,纳入同一个平台了;另外你可以看到它的sql server数据库,这样很方便你写sql或扩展程序,以得到需要的统计分析报表。mantis的字段也可以自定义,但唯一的不足就是不能加流程状态,它可以定制流程,但是状态就是那几个状态,加不了。
当然,“工具配合的是管理”,关键还是人。没有相应的理念,再好的工具也是白费。目前这个平台也未经验证,具体使用效果,以后再来总结。
需注意,URTracker是收费的,但是有5个帐号的免费版,可以满足小团队。以后如果要注册,45元/帐号,应该也可以接受。如果你一定要免费,那可以用mantis代替之,缺陷是流程定制的效果差点。
1.URTracker:
http://www.lealsoft.com/urtracker/优点:可以满足我们的需求,操作也较符合国内习惯,另外是.net+sql 做的,可方便自行扩展。(内部公告可以用知识库来代替)
缺点:收费。(但是有5个帐号的免费版)
2.Mantis:
www.mantisbt.org/如果要用免费的软件,就是这个了。它的不足除了流程状态不能加外,项目管理只能通过当一个bug项目来做,这样感觉可能不是很爽,有点折衷。
3.http://at.tryphpgroupware.org/phpgroupware/login.php
优点:可支持项目管理及bug,内部公告。(流程及自定义字段未知)。另外集成的功能模块较多,日历、论坛、wiki等。开源免费。国外开源会不断升级。
缺点:操作习惯没这么好,另外是php+mysql做的,较难扩展。
4.http://egroupware.outdoor-training.de/egw-head/login.php
优点:可支持项目管理及bug,内部公告。(流程及自定义字段好像不行?)。另外集成的功能模块较多,日历、论坛、wiki等。开源免费。国外开源会不断升级。
缺点:操作习惯没这么好,另外是php+mysql做的,较难扩展。
5.Sawin2006研发协作平台
http://www.sawin.cn/OpenProject/sawin2006/welcome.htm界面、流程不符合我们的需求,不作考虑。
支持需求管理及bug管理。开源。
6.BugFree:
http://bugfree.1zsoft.com/Demo/功能较简单,不能满足项目管理的需求。优点是界面设计比较清晰。用来做bug管理还是可以的。当然个人感觉Mantis用惯了。
7.https://gforge.org/
可能更适合开源软件,效果未知。可以支持项目管理及bug管理。
8.JIRA:
据说也可以支持项目管理和bug,且还可以,不过是收费的(对开源项目免费)。见
http://blog.csdn.net/judyxm/archive/2006/04/26/678456.aspx 9.其他收费的软件,应该还有些。在此不找了。
http://www.php-open.com/ 有些开源软件。
最后,最近的发现,Windows SharePoint Services 3.0似乎都可以满足需求,似乎很不错。不过太庞大了点,维护也不好做,暂不考虑了。说明见这里:
http://www.cnblogs.com/cleo/archive/2007/03/16/SharePointV3_Templates_Demo.html
posted @
2007-05-30 10:00 CqRandy 阅读(412) |
评论 (0) |
编辑 收藏

2007年2月15日
摘要: 1.Accordion 功能:实现了QQ、Msn好友分类的折叠效果,就像包含了多个CollapsiblePanels 细节: (1)不要把Accordion放在Table种同时又把 FadeTransitions 设置为True,这将引起布局混乱 (2)每一个 AccordionPane control 有一个Header 和Content的 templa...
阅读全文
posted @
2007-02-15 08:51 CqRandy 阅读(878) |
评论 (0) |
编辑 收藏

2006年9月2日
方案1:
/// <summary>
/// 传入URL返回网页的html代码
/// </summary>
/// <param name="Url">URL</param>
/// <returns></returns>
public static string getUrltoHtml(string Url)
{
errorMsg = "";
try
{
System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url);
// Get the response instance.
System.Net.WebResponse wResp =wReq.GetResponse();
// Read an HTTP-specific property
//if (wResp.GetType() ==HttpWebResponse)
//{
//DateTime updated =((System.Net.HttpWebResponse)wResp).LastModified;
//}
// Get the response stream.
System.IO.Stream respStream = wResp.GetResponseStream();
// Dim reader As StreamReader = New StreamReader(respStream)
System.IO.StreamReader reader = new System.IO.StreamReader(respStream, System.Text.Encoding.GetEncoding("gb2312"));
return reader.ReadToEnd();
}
catch(System.Exception ex)
{
errorMsg = ex.Message ;
}
return "";
}
你可以用这个函数获取网页的客户端的html代码,然后保存到.html文件里就可以了。
方案2:
生成单个的静态页面不是难点,难的是各个静态页面间的关联和链接如何保持完整;
特别是在页面频繁更新、修改、或删除的情况下;
像阿里巴巴的页面也全部是html的,估计用的是地址映射的功能
关于地址映射可参考:http://www.easewe.com/Article/ShowArticle.aspx?article=131
可以看看这个页面,分析一下他的“竞价倒计时”功能
http://info.china.alibaba.com/news/subject/v1-s5011580.html?head=top4&Bidding=home5
ASP.Net生成静态HTML页
在Asp中实现的生成静态页用到的FileSystemObject对象!
在.Net中涉及此类操作的是System.IO
以下是程序代码 注:此代码非原创!参考别人代码
CODE:
//生成HTML页
public static bool WriteFile(string strText,string strContent,string strAuthor)
{
string path = HttpContext.Current.Server.MapPath("/news/");
Encoding code = Encoding.GetEncoding("gb2312");
// 读取模板文件
string temp = HttpContext.Current.Server.MapPath("/news/text.html");
StreamReader sr=null;
StreamWriter sw=null;
string str="";
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd(); // 读取文件
}
catch(Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html";
// 替换内容
// 这时,模板文件已经读入到名称为str的变量中了
str =str.Replace("ShowArticle",strText); //模板页中的ShowArticle
str = str.Replace("biaoti",strText);
str = str.Replace("content",strContent);
str = str.Replace("author",strAuthor);
// 写文件
try
{
sw = new StreamWriter(path + htmlfilename , false, code);
sw.Write(str);
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
return true;
此函数放在Conn.CS基类中了
在添加新闻的代码中引用 注:工程名为Hover
if(Hover.Conn.WriteFilethis.Title.Text.ToString),this.Content.Text.ToString),this.Author.Text.ToString)))
{
Response.Write("添加成功");
}
else
{
Response.Write("生成HTML出错!");
}
模板页Text.html代码
CODE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ShowArticle</title>
<body>
biaoti
<br>
content<br>
author
</body>
</HTML>
biaoti
<br>
content<br>
author
</body>
</HTML>
提示添加成功后会出以当前时间为文件名的html文件!上面只是把传递过来的几个参数直接写入了HTML文件中,在实际应用中需要先添加数据库,然后再写入HTML文件
方案3:
给一个客户端参考的例子(SJ)
它的作用在于以客户端的方式获取某个页面的代码,然后可以做为其他用途,本例是直接输出
<script>
var oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
oXmlHttp.open("GET","http://www.163.com", false);
oXmlHttp.send()
var oStream = new ActiveXObject("ADODB.Stream");
if(oStream == null)
alert("您的机器不支持ADODB.Stream.")
else
{
oStream.Type=1;
oStream.Mode=3;
oStream.Open() ;
oStream.Write(oXmlHttp.responseBody);
oStream.Position= 0;
oStream.Type= 2;
oStream.Charset="gb2312";
var result= oStream.ReadText();
oStream.Close();
oStream = null;
var aa = window.open("","")
document.write(result);
aa.document.write(result);
}
</script>
方案4:学csdn一样。用xml保存数据,模版XSL也只有一个文件。
使用xml来保存数据,使用xsl来定义模板并且生称数据。可以通过xsl来很方便的在客户端或者服务段显示数据。如果要生成静态叶面那更简单了。去查一下.net的xml类包问题解决。
优点:可以方便快速转换成你想要的格式和内容。
缺点:需要学习更多的内容,不好入门。
方案5:
思路
1. 利用如Dw-Mx这样的工具生成html格式的模板,在需要添加格式的地方加入特殊标记(如$htmlformat$),动态生成文件时利用代码读取此模板,然后获得前台输入的内容,添加到此模板的标记位置中,生成新文件名后写入磁盘,写入后再向数据库中写入相关数据。
2. 使用后台代码硬编码Html文件,可以使用HtmlTextWriter类来写html文件。
优点
1. 可以建立非常复杂的页面,利用包含js文件的方法,在js文件内加入document.write()方法可以在所有页面内加入如页面头,广告等内容。
2. 静态html文件利用MS Windows2000的Index Server可以建立全文搜索引擎,利用asp.net可以以DataTable的方式得到搜索结果。而Win2000的Index服务无法查找xml文件的内容。如果包括了数据库搜索与Index索引双重查找,那么此搜索功能将非常强大。
3. 节省服务器的负荷,请求一个静态的html文件比一个aspx文件服务器资源节省许多。
缺点
思路二: 如果用硬编码的方式,工作量非常大,需要非常多的html代码。调试困难。而且使用硬编码生成的html样式无法修改,如果网站更换样式,那么必须得重新编码,给后期带来巨大的工作量。
因此这里采用的是第一种思路
示列代码
1.定义(template.htm)html模板页面
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body >
<table $htmlformat[0] height="100%" border="0" width="100%" cellpadding="10" cellspacing="0" bgcolor="#eeeeee" style="border:1px solid #000000">
<tr>
<td width="100%" valign="middle" align="left">
<span style="color: $htmlformat[1];font-size: $htmlformat[2]">$htmlformat[3]</span>
</td>
</tr>
</table>
</body>
</html>
2.asp.net代码:
//---------------------读html模板页面到stringbuilder对象里----
string[] format=new string[4];//定义和htmlyem标记数目一致的数组
StringBuilder htmltext=new StringBuilder();
try
{
using (StreamReader sr = new StreamReader("存放模板页面的路径和页面名"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
htmltext.Append(line);
}
sr.Close();
}
}
catch
{
Response.Write("<Script>alert('读取文件错误')</Script>");
}
//---------------------给标记数组赋值------------
format[0]="background="bg.jpg"";//背景图片
format[1]= "#990099";//字体颜色
format[2]="150px";//字体大小
format[3]= "<marquee>生成的模板html页面</marquee>";//文字说明
//----------替换htm里的标记为你想加的内容
for(int i=0;i<4;i++)
{
htmltext.Replace("$htmlformat["+i+"]",format[i]);
}
//----------生成htm文件------------------――
try
{
using(StreamWriter sw=new StreamWriter("存放路径和页面名",false,System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(htmltext);
sw.Flush();
sw.Close();
}
}
catch
{
Response.Write ("The file could not be wirte:");
}
小结
用此方法可以方便的生成html文件。程序使用了是循环替换,因此对需替换大量元素的模板速度非常快。
posted @
2006-09-02 21:45 CqRandy 阅读(310) |
评论 (0) |
编辑 收藏

2006年6月2日
1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table
2. <body onselectstart="return false"> 取消选取、防止复制
3. onpaste="return false" 不准粘贴
4. oncopy="return false;" oncut="return false;" 防止复制
5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标
6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标
7. <input style="ime-mode:disabled"> 关闭输入法
8. 永远都会带着框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>
9. 防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
10. <noscript><iframe src=*.html></iframe></noscript> 网页将不能被另存为
11. <input type=button value=查看网页源代码
onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'">
12. 怎样通过asp的手段来检查来访者是否用了代理
<% if Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then
response.write "<font color=#FF0000>您通过了代理服务器,"& _
"真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
end if
%>
13. 取得控件的绝对位置
//javascript
<script language="javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"\nleft="+l);
}
</script>
//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>
14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
15. 判断上一页的来源
asp:
request.servervariables("HTTP_REFERER")
javascript:
document.referrer
16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE
17.
<%
'定义数据库连接的一些常量
Const adOpenForwardOnly = 0 '游标只向前浏览记录,不支持分页、Recordset、BookMark
Const adOpenKeyset = 1 '键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark
Const adOpenDynamic = 2 '动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。
Const adOpenStatic = 3 '静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动
Const adLockReadOnly = 1 '锁定类型,默认的,只读,不能作任何修改
Const adLockPessimistic = 2 '当编辑时立即锁定记录,最安全的方式
Const adLockOptimistic = 3 '只有在调用Update方法时才锁定记录集,而在此前的其他*作仍可对当前记录进行更改、插入和删除等
Const adLockBatchOptimistic = 4 '当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的
Const adCmdText = &H0001
Const adCmdTable = &H0002
%>
18. 网页不会被缓存
HTM网页
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">
ASP网页
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.cachecontrol = "no-cache"
PHP网页
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
19. 检查一段字符串是否全由数字组成
<script language="javascript"><!--
function checkNum(str){return str.match(/\D/)==null}
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>
20. 获得一个窗口的大小
document.body.clientWidth,document.body.clientHeight
21. 怎么判断是否是字符
if (/[^\x00-\xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");
22.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
posted @
2006-06-02 09:41 CqRandy 阅读(982) |
评论 (0) |
编辑 收藏

2006年5月30日
//取CPU号
public string GetCpuID()
{
try
{
ManagementClass mc = new ManagementClass("Win32_Processor");
ManagementObjectCollection moc = mc.GetInstances();
string strCpuID = null ;
foreach( ManagementObject mo in moc )
{
strCpuID = mo.Properties["ProcessorId"].Value.ToString();
break;
}
return strCpuID;
}
catch
{
return "";
}
}
//取第一块硬盘号
public string GetHardDiskID()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
string strHardDiskID = null ;
foreach(ManagementObject mo in searcher.Get())
{
strHardDiskID = mo["ModuleNumber"].ToString().Trim();
if(strHardDiskID != "")
{
break;
}
}
return strHardDiskID ;
}
catch
{
return "";
}
}//end
//取第一块网卡号
public string GetNetworkID()
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration");
string strNetworkID = null ;
foreach(ManagementObject mo in searcher.Get())
{
strNetworkID = mo["MACAddress"].ToString().Trim();
if(strNetworkID != "")
{
break;
}
}
return strNetworkID ;
}
catch
{
return "";
}
}//end
//取串口
public int getport(int portnum)
{
//链接服务器
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");
//检测是否已存在相同串口的站点,并获取PORT值
foreach(DirectoryEntry e in root.Children)
{
if(e.SchemaClassName == "IIsWebServer")
{
if(e.Properties["ServerBindings"].Value != null)
{
int strstart = e.Properties["ServerBindings"].Value.ToString().IndexOf(":",0);
int strend = e.Properties["ServerBindings"].Value.ToString().IndexOf(":",strstart+1);
string thisport = e.Properties["ServerBindings"].Value.ToString().Substring((strstart+1),(strend-strstart-1));
if(thisport == portnum.ToString())
{
portnum++;
portnum = getport(portnum);
break;
}
}
}
}
return portnum;
}
posted @
2006-05-30 08:46 CqRandy 阅读(561) |
评论 (0) |
编辑 收藏

2006年5月29日
大家在实际工作中有没有遇到要在DataGrid中显示带有主次结构的数据呢?如果你对ADO.NET和SQL Server2000熟悉的话,我们下面就举一个利用VS.NET自带的示例数据库Northwind和VB.NET来说明如何实现这一目标。
首先,我们先准备要显示的带有主次结构的数据。
下面就是要绑定到HierarchicalDataGrid.aspx的VB.NET代码文件HierarchicalDataGrid.aspx.vb的内容:
Imports System.Data.SqlClient
Public Class HierarchicalDataGrid
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
#Region " Web Form Designer Generated Code "
'下面的调用对Web Form设计器来说是必须的
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 这个方法是为Web Form设计器调用的
'不要用代码编辑器改变这里.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'打开数据库连接
Dim OrdersConnection As New SqlConnection("Server=(local)\NetSDK;Database=northwind;Trusted_Connection=yes")
'得到订单和订单详细信息
Dim OrderAdapter As New SqlDataAdapter("Select * from Orders; select OrderID ,Products.ProductName,[order Details].Unitprice,[order Details].Quantity,[order Details].discount from [order Details],Products where [Order Details].ProductId=Products.ProductID", OrdersConnection)
'创建并填充DataSet对象
Dim OrderDataSet As New DataSet()
OrderAdapter.Fill(OrderDataSet)
'设定表名字
OrderDataSet.Tables(0).TableName = "Orders"
OrderDataSet.Tables(1).TableName = "Order Details"
'在基于OrderID字段的两个表之间建立父子关系
Dim Parent As DataColumn = OrderDataSet.Tables("Orders").Columns("OrderID")
Dim Child As DataColumn = OrderDataSet.Tables("Order Details").Columns("OrderID")
Dim OrderRelation As DataRelation = New DataRelation("OrderRelation", Parent, Child, False)
'为DataSet添加关系
OrderDataSet.Relations.Add(OrderRelation)
'把DataGrid绑定到Orders表
DataGrid1.DataSource = OrderDataSet.Tables("Orders").DefaultView
DataBind()
End Sub
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
e.Item.Cells(0).BackColor = System.Drawing.Color.Ivory
End Sub
End Class
在HierarchicalDataGrid.aspx中,我们为DataGrid1建立模板列,并把另外一个DataGrid嵌入到这个模板列,父一级的DataGrid用来显示主记录,比如:订单。子一级DataGrid用来显示详细信息,比如:订单的详细信息。我们这样为子DataGrid动态指定数据源:
DataSource='<%# Ctype(Container.DataItem,DataRowView).CreateChildView("OrderRelation") %>'>
上面这句就是实现显示主次关系数据的关键。根据当前父一级记录,DataRowView.CreateChildView利用前面创建的关系的名字作为参数获得子记录,并把它绑定到子DataGrid上。
下面就是我们要显示的ASPX页面的代码,HierarchicalDataGrid.aspx:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="HierarchicalDataGrid.aspx.vb" Inherits="HierarchicalDataGrid.HierarchicalDataGrid" %>
<%@ Import namespace="System.Data"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>显示主次关系数据的例子</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="FrmDataGrid" method="post" runat="server">
<P align="center">
<asp:DataGrid id="DataGrid1" BorderColor="#0099FF" runat="server" ShowHeader="False" Width="470px" CellPadding="0" CellSpacing="0" AutoGenerateColumns="False" BorderWidth="2px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<TD bgColor="#FF6600"><B>订单号:
<%# DataBinder.Eval(Container.DataItem, "OrderID") %>
</B>
</TD>
</TR>
<TR>
<TD align="right">
<asp:DataGrid id=DataGrid2 runat="server" AutoGenerateColumns="False" BorderColor="#33FF33" DataKeyField="OrderID" DataSource='<%# Ctype(Container.DataItem,DataRowView).CreateChildView("OrderRelation") %>'>
<HeaderStyle Font-Bold="True" ForeColor="#CC0066" BackColor="#FFCCFF"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="OrderID" ReadOnly="True"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="产品名称">
<HeaderStyle Width="300px"></HeaderStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ProductName") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="UnitPrice" HeaderText="单价"></asp:BoundColumn>
<asp:BoundColumn DataField="Quantity" HeaderText="数量"></asp:BoundColumn>
<asp:BoundColumn DataField="Discount" HeaderText="折扣"></asp:BoundColumn>
</Columns>
</asp:DataGrid></TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></P>
</form>
</body>
</HTML>
posted @
2006-05-29 09:19 CqRandy 阅读(267) |
评论 (0) |
编辑 收藏
结合客户端脚本,我们可以创建出可以拖动列,可以拖动改变列宽度,显示、隐藏列、编辑列的XP风格的 DataGrid,下面就是所有的代码。自己调试时请注意修改eMeng.Exam.UltraGrid路径。
查看例子
UltraGrid.aspx
]]>XP 风格的可拖动列、可排序、可改变宽度的DataGrid的例子
UltraGrid.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace eMeng.Exam.UltraGrid
{
///
/// UltraGrid 的摘要说明。本例子演示了如何创建可排序、可拖放、可调整宽度的XP风格的DataGrid。
/// 出自:【孟宪会之精彩世界】
///
public class UltraGrid : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlGenericControl gridRow;
protected System.Web.UI.WebControls.Literal RowItem;
protected System.Web.UI.HtmlControls.HtmlGenericControl coolUltraGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
coolUltraGrid1.Attributes.Add("class","coolUltraGrid");
coolUltraGrid1.Attributes.Add("style","WIDTH: 100%; HEIGHT: 400");
coolUltraGrid1.Attributes.Add("borderStyle","2");
coolUltraGrid1.Attributes.Add("altRowColor","oldLace");
coolUltraGrid1.Attributes.Add("selectionStyle","1");
/// 请根据你的数据库的设置,修改这里的数据库连接字符串和查询语句。其它不要修改。
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\xxx.mdb");
cn.Open();
string sqlstring = "SELECT TOP 30 D.Title As 文档标题,D.CreateDate as 发布时间,S.Title AS 所属栏目 ";
sqlstring += "FROM Document D,Subject S WHERE D.pid=S.id ORDER BY D.CreateDate DESC";
OleDbCommand cmd = new OleDbCommand(sqlstring,cn);
OleDbDataReader dr;
dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
///
///组合表头
///
int FieldNumber = dr.FieldCount;
int ColWidth,Tmp = 0;
if(FieldNumber == 0)
Response.End();
ColWidth = (int)100/FieldNumber;
string TableHeader = "";
for(int i=0;i"+dr.GetName(i).ToString()+"";
else
TableHeader +=""+dr.GetName(i).ToString()+"";
Tmp+=ColWidth;
}
}
gridRow.InnerHtml=TableHeader;
int RowNumber = 1;
TableHeader = "";
while(dr.Read())
{
TableHeader += "
";
for(int i=0;i";
}
TableHeader += "
";
RowNumber++;
}
TableHeader += "
";
RowItem.Text=TableHeader;
cn.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
posted @
2006-05-29 09:13 CqRandy 阅读(283) |
评论 (0) |
编辑 收藏
WebForm2.aspx:
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="ChenFeng.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<div align="center"><form id="Form1" method="post" runat="server">
<asp:label id="Label1" runat="server" font-bold="true">
从当前页面打开新窗口,并把变量传递到新窗口的例子,可以多次打开提交。
</asp:label><br>
<br>
<asp:textbox id="TextBox1" runat="server" width="600px"></asp:textbox><br>
<br>
<asp:button id="Button1" runat="server" text="打开窗口" width="96px"></asp:button></form>
</div>
</body>
</HTML>
WebForm2.aspx.cs
using System;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace ChenFeng
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : Page
{
protected Label Label1;
protected TextBox TextBox1;
protected Button Button1;
protected HtmlForm Form1;
private void Page_Load(object sender, EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!IsClientScriptBlockRegistered("clientScript"))
{
string strScript = "<script>{"+"\r\n";
strScript += "function OpenWin(){" + "\r\n";
strScript += "var str=window.showModalDialog('WebForm3.aspx',document.Form1.TextBox1.value)" + "\r\n";
strScript += "if(str!=null) document.Form1.TextBox1.value=str" + "\r\n";
strScript += "}" + "\r\n";
strScript += "}</script>" + "\r\n";
RegisterClientScriptBlock("clientScript", strScript);
}
Button1.Attributes.Add("onclick", "OpenWin()");
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new EventHandler(this.Page_Load);
}
#endregion
}
}
WebForm3.axpx
<%@ Page language="c#" Codebehind="WebForm3.aspx.cs" AutoEventWireup="false" Inherits="ChenFeng.WebForm3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout" id="MyBody" runat="server">
<form id="Form1" method="post" runat="server">
<asp:label id="Label1" runat="server">请输入您的大名:</asp:label><br>
<br>
<asp:textbox id="TextBox1" runat="server" width="558"></asp:textbox><br>
<br>
<asp:button id="Button1" runat="server" text=" 提 交 "></asp:button></form>
</body>
</HTML>
WebForm3.aspx.cs
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ChenFeng
{
/// <summary>
/// WebForm3 的摘要说明。
/// </summary>
public class WebForm3 : Page
{
protected Label Label1;
protected TextBox TextBox1;
protected Button Button1;
protected System.Web.UI.HtmlControls.HtmlControl MyBody;
private void Page_Load(object sender, EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (IsPostBack)
{
string strScript = "<script>{" + "\r\n";
strScript += "window.parent.returnValue='" + TextBox1.Text.Replace("'", "\'") + "'" + "\r\n";
strScript += "window.parent.close()" + "\r\n";
strScript += "}</script>" + "\r\n";
if (! IsClientScriptBlockRegistered("clientScript"))
{
RegisterClientScriptBlock("clientScript", strScript);
}
}
if (! IsPostBack)
{
MyBody.Attributes.Add("onload", "document.Form1.TextBox1.value=window.parent.dialogArguments");
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new EventHandler(this.Page_Load);
}
#endregion
}
}
posted @
2006-05-29 09:08 CqRandy 阅读(764) |
评论 (0) |
编辑 收藏

2006年5月16日
//这是一个webservice
private AppUpdate.UpdateServ UpdateSvr;
private void button1_Click(object sender, System.EventArgs e)
{
if(LinkWebServices()==true)
{
this.label1.Text="连接服务器....... PASS";
if(CheckVer()==true)
{
this.label2.Text="检查最新版本并下载.......PASS";
}
else
{
this.label2.Text="检查最新版本并下载.......FAIL";
}
}
else
{
this.label1.Text="连接服务器.......FAIL";
}
}
//这是用来与升级服务器建立连接
private bool LinkWebServices()
{
try
{
UpdateSvr=new UpdateServ();
return true;
}
catch
{
return false;
}
}
//调用webservice用来检查是不是有最新的版本
private bool CheckVer()
{
string path =Application.StartupPath;
try
{
VersionCheck(path);
return true;
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
}
private void VersionCheck(string desPath)
{
try
{
#region 查看文件和目录
if(!desPath.EndsWith(@"\"))
desPath += @"\";
if(!System.IO.Directory.Exists(desPath))
{
System.IO.Directory.CreateDirectory(desPath);
}
string tempPath = desPath + @"tempDesPathCache\";
if(System.IO.Directory.Exists(tempPath))
{
System.IO.Directory.Delete(tempPath,true);
System.IO.Directory.CreateDirectory(tempPath);
}
else
System.IO.Directory.CreateDirectory(tempPath);
if(!System.IO.File.Exists(desPath + "UpdateConfig.xml"))
{
System.Xml.XmlDocument updateConfig = new System.Xml.XmlDocument();
updateConfig.LoadXml(@"<root></root>");
updateConfig.Save(desPath + "UpdateConfig.xml");
}
#endregion
System.Xml.XmlDocument serverXmlDoc = UpdateSvr.AppUpdateVertion();
System.Xml.XmlDocument localXmlDoc = new System.Xml.XmlDocument();
localXmlDoc.Load(desPath + "UpdateConfig.xml");
bool newVersionExist = false;
bool moduleExist = false;
System.Xml.XmlNode serverNode0 = serverXmlDoc.ChildNodes[0];
System.Xml.XmlNode localNode0 = localXmlDoc.ChildNodes[0];
foreach(System.Xml.XmlNode serverNode in serverNode0)
{
moduleExist = false;
foreach(System.Xml.XmlNode localNode in localNode0)
{
//找到对应模块
if(localNode.ChildNodes[0].InnerText == serverNode.ChildNodes[0].InnerText)
{
moduleExist = true;
//版本号判断
if(localNode.ChildNodes[1].InnerText.CompareTo(serverNode.ChildNodes[1].InnerText) < 0)
{
newVersionExist = true;
if(System.Configuration.ConfigurationSettings.AppSettings["NetStyle"].ToString()=="internet")
{
DownloadFile(serverNode.ChildNodes[2].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
}
else
{
DownloadFile(serverNode.ChildNodes[3].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
}
}
break;
}
}
//没找到对应模块
if(false == moduleExist)
{
if(System.Configuration.ConfigurationSettings.AppSettings["NetStyle"].ToString()=="internet")
{
DownloadFile(serverNode.ChildNodes[2].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
}
else
{
DownloadFile(serverNode.ChildNodes[3].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
}
}
}
//写入新UpdateConfig.xml升级完毕后替换
if(newVersionExist)
{
serverXmlDoc.Save(tempPath + "UpdateConfig.xml");
if(DialogResult.Yes == MessageBox.Show("有新版本,是否更新?","提示",MessageBoxButtons.YesNo))
{
string[] dirs = System.IO.Directory.GetFiles(tempPath, "*.*");
string fileName;
foreach (string dir in dirs)
{
fileName = ((dir.Split(Convert.ToChar(@"\")))[dir.Split(Convert.ToChar(@"\")).Length - 1]);
if(System.IO.File.Exists(desPath + fileName))
{
//TODO:可以支持备份以前版本
System.IO.File.Delete(desPath + fileName);
}
//TODO:如果系统正在运行,您得停止系统,至于如何停止,也许可以使用System.Diagnostics.Process
System.IO.File.Move(dir,desPath + fileName);
}
MessageBox.Show("升级完毕");
}
else
{
//TODO:可以支持重新提示升级
}
}
}
catch(Exception ex)
{
throw new Exception("升级失败,原因是:" + ex.Message,ex);
}
}
//下载最新的文件
private void DownloadFile(string source,string fileName)
{
try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();
myWebClient.DownloadFile(source,fileName);
}
catch(Exception ex)
{
throw new Exception("下载失败,原因是:" + ex.Message,ex);
}
}
webservices如下:
[WebMethod(Description = "取得更新版本")]
public string GetVer()
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("update/update.xml"));
XmlElement root = doc.DocumentElement;
return root.SelectSingleNode("version").InnerText;
}
[WebMethod(Description = "在线更新软件")]
public System.Xml.XmlDocument GetUpdateData()
{
//取得更新的xml模板内容
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("update/update.xml"));
XmlElement root = doc.DocumentElement;
//看看有几个文件需要更新
XmlNode updateNode = root.SelectSingleNode("filelist");
string path = updateNode.Attributes["sourcepath"].Value;
int count = int.Parse(updateNode.Attributes["count"].Value);
//将xml中的value用实际内容替换
for (int i = 0; i < count; i++)
{
XmlNode itemNode = updateNode.ChildNodes[i];
string fileName = path + itemNode.Attributes["name"].Value;
FileStream fs = File.OpenRead(Server.MapPath(fileName));
itemNode.Attributes["size"].Value = fs.Length.ToString();
BinaryReader br = new BinaryReader(fs);
//这里是文件的实际内容,使用了Base64String编码
itemNode.SelectSingleNode("value").InnerText = Convert.ToBase64String(br.ReadBytes((int)fs.Length), 0, (int)fs.Length);
br.Close();
fs.Close();
}
return doc;
}
再建一个xml
<?xml version="1.0" encoding="utf-8" ?>
<product>
<version>1.0.1818.42821</version>
<description>修正一些Bug</description>
<filelist count="7" sourcepath="./update/">
<item name="WinQp.exe" size="">
<value />
</item>
<item name="AccessDAL.dll" size="">
<value />
</item>
<item name="LocalBLL.dll" size="">
<value />
</item>
<item name="Model.dll" size="">
<value />
</item>
<item name="MyADO.dll" size="">
<value />
</item>
<item name="Common.dll" size="">
<value />
</item>
<item name="Excel.dll" size="">
<value />
</item>
</filelist>
</product>
放在服务器上
再新建 一个升级程序,在主程序下调用这个程序,升级程序内容为
if (!File.Exists(Application.StartupPath+"\\update.xml"))
{
MessageBox.Show("升级程序不能单独运行!");
Application.Exit();
}
System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in ps)
{
//MessageBox.Show(p.ProcessName.ToLower());
if (p.ProcessName.ToLower() == "qpwin")
{
if (!p.HasExited)
{
p.Kill();
p.WaitForExit();
}
break;
}
}
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + @"\update.xml");
XmlElement root = doc.DocumentElement;
XmlNode updateNode = root.SelectSingleNode("filelist");
string path = updateNode.Attributes["sourcepath"].Value;
int count = int.Parse(updateNode.Attributes["count"].Value);
for (int i = 0; i < count; i++)
{
XmlNode itemNode = updateNode.ChildNodes[i];
string fileName = itemNode.Attributes["name"].Value;
FileInfo fi = new FileInfo(fileName);
fi.Delete();
//File.Delete(Application.StartupPath + @"\" + fileName);
this.label1.Text = "正在更新: " + fileName + " (" + itemNode.Attributes["size"].Value + ") ...";
FileStream fs = File.Open(fileName, FileMode.Create, FileAccess.Write);
fs.Write(System.Convert.FromBase64String(itemNode.SelectSingleNode("value").InnerText), 0, int.Parse(itemNode.Attributes["size"].Value));
fs.Close();
}
label1.Text = "更新完成";
File.Delete(Application.StartupPath + @"\update.xml");
label1.Text = "正在重新启动应用程序...";
System.Diagnostics.Process.Start("qpwin.exe");
Close();
Application.Exit();
posted @
2006-05-16 11:17 CqRandy 阅读(473) |
评论 (0) |
编辑 收藏

2006年4月25日
在网站开发时,生成缩略图是一个非常常见和实用的功能.以前在asp里只能借助com组件实现,现在在.net里可以利用框架的强大的类库轻松实现.下面帖出完整的代码(带详细注释),参考了网上的一些文章及.net sdk相关内容.QQROOM网络家园的图片上传用到了所有的4种生成方式.
///<summary>
/// 生成缩略图
///</summary>
///<param name="originalImagePath">源图路径(物理路径)</param>
///<param name="thumbnailPath">缩略图路径(物理路径)</param>
///<param name="width">缩略图宽度</param>
///<param name="height">缩略图高度</param>
///<param name="mode">生成缩略图的方式</param>
publicstaticvoid MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)
{
Image originalImage = Image.FromFile(originalImagePath);
int towidth = width;
int toheight = height;
int x =0;
int y =0;
int ow = originalImage.Width;
int oh = originalImage.Height;
switch (mode)
{
case"HW"://指定高宽缩放(可能变形)
break;
case"W"://指定宽,高按比例
toheight = originalImage.Height * width/originalImage.Width;
break;
case"H"://指定高,宽按比例
towidth = originalImage.Width * height/originalImage.Height;
break;
case"Cut"://指定高宽裁减(不变形)
if((double)originalImage.Width/(double)originalImage.Height > (double)towidth/(double)toheight)
{
oh = originalImage.Height;
ow = originalImage.Height*towidth/toheight;
y =0;
x = (originalImage.Width - ow)/2;
}
else
{
ow = originalImage.Width;
oh = originalImage.Width*height/towidth;
x =0;
y = (originalImage.Height - oh)/2;
}
break;
default :
break;
}
//新建一个bmp图片
Image bitmap =new System.Drawing.Bitmap(towidth,toheight);
//新建一个画板
Graphics g = System.Drawing.Graphics.FromImage(bitmap);
//设置高质量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速度呈现平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//清空画布并以透明背景色填充
g.Clear(Color.Transparent);
//在指定位置并且按指定大小绘制原图片的指定部分
g.DrawImage(originalImage, new Rectangle(0, 0, towidth, toheight),
new Rectangle(x, y, ow,oh),
GraphicsUnit.Pixel);
try
{
//以jpg格式保存缩略图
bitmap.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(System.Exception e)
{
throw e;
}
finally
{
originalImage.Dispose();
bitmap.Dispose();
g.Dispose();
}
}
关键方法Graphics.DrawImage见ms-help://MS.NETFrameworkSDKv1.1.CHS/cpref/html/frlrfsystemdrawinggraphicsclassdrawimagetopic11.htm
posted @
2006-04-25 08:56 CqRandy 阅读(364) |
评论 (0) |
编辑 收藏