存档

作者存档

C#中常用JS语句

2010年5月28日 Kimi 2 条评论

有时候在开发中,经常输出一些js与客户端实现交互,虽然说是c#的其实好多js的,需要的朋友可以收藏下。
1. 输出语句 document.(“”); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document->html->(head,body)
4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById(“表单中元素的ID號”).name(或value)
6.一个小写转大写的JS: document.getElementById(“output”).value = document.getElementById(“input”).value.toUpperCase();
7.JS中的值类型:String,Number,Boolean,Null,Object,Function
8.JS中的字符型转换成数值型:parseInt(),parseFloat()
9.JS中的数字转换成字符型:(“” 变量)
10.JS中的取字符串长度是:(length)
11.JS中的字符与字符相连接使用 號.
12.JS中的比较操作符有:==等于,!=不等于,>,>=,<.<=
13.JS中声明变量使用:var来进行声明
14.JS中的判断语句结构:if(condition){}else{}
15.JS中的循环结构:for([initial expression];[condition];[upadte expression]) {inside loop}
16.循环中止的命令是:break
17.JS中的函数定义:function functionName([parameter],…){statement[s]}
18.当文件中出现多个form表单时.可以用document.forms[0],document.forms[1]来代替.
19.窗口:打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self
20.状態栏的设置:window.status=”字符”;
阅读全文…

Tags: ,
分类: Code 标签: ,

随便谈谈

2010年5月20日 Kimi 2 条评论

好久没发日志了,感觉最近的事情好多啊。那天大致的盘算了一下,从现在开始到学期末要做的事情实在是太多了,大大小小加起来不下于10件。首先是一堆公选课的论文,然后就是很纠结的几个大作业,再然后就是软考和即将到来的期末考试。谈到期末考试,虽然这学期要考试的科目很少,但一门网络估计就够哥受的。这学期的网络老师真是对他无语了,上课嘛一点激情没的,听着就想睡觉;课程设计嘛,人啊不出现的,就让两个研究生带着,那两学长自己还搞不明白什么东西,更别说辅导我们了。用Timmy的话说“上学期的操作系统,前半学期坐在后排导致上课没听懂多少,后半学期坐到前排(沙发的位置)感觉还不错,听懂了不少,最后考试也还考了个80几。这学期网络课堂堂课坐沙发,还是没听懂什么。”囧。估计考试要纠结了。

前几天为了.NET的大作业跟Timmy讨论了很长时间,还熬夜coding了两个晚上。第二天整个人累得跟什么似的,完全虚了。我想,这就是我后半辈子要过的生活吗?天呐!地啊!╮(╯▽╰)╭程序员的生活难道真的就是这样的吗?不过回过头来想想,现在这社会什么行业不辛苦啊,每个行业都有每个行业的特色嘛。(但熬夜这个特色哥有点受不鸟)貌似纠结完.NET,还要纠结J2EE。%>_<%

下午吃晚饭前,跟KC聊了很长时间,他很纠结他已经纠结了很长时间的事情。他说他还是不死心,不甘心就这么放下MC(为了营造和谐世界,就不说实名了,用代号吧!),他说他还要再搏一搏。作为兄弟,我当然支持他也希望他能成功。但我还是劝他不要冲动,最好能缓慢的把事情进行下去,这样对大家都好。他说他不想再等了,他不想再这样浑浑噩噩的混下去,早点做个了断也早点让自己摆脱这种生活。他说他所作的一些重大决定很大程度上是为了MC,现在却落空了。哎,怎么说呢?这种事情本来就很难说的,况且他是一个这么纠结的人,也做过那么多纠结的事。所以这种事情就让他自己去纠结吧,哥们只能在后方做做精神支援了。

阅读全文…

Tags: , , , ,
分类: 随笔 标签: , , , ,

根据数据库中宁波公园的经纬度信息在Google地图上标出每个公园的位置并连线

2010年5月6日 Kimi 没有评论

数据库中含有宁波一些公园的详细信息,包括经纬度。要求将经纬度信息读取出来并调用Google Map的API服务在地图上标识出这些公园的位置。刚开始时想通过一个函数将一个buffer流写如到一个xml中并保存的,但JavaScript中调用时可能是事先预读入了,所以每次执行时都提示错误,只有当第二次这个xml真正存在时执行才会有用。为了这个问题纠结了很久结果还是不行,于是采用老师今天课堂上展示的成品中用的方法,果然奏效了。-_-||
运行效果图:

draw.:

< %@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
< %@page import = "java.util.*"%>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Airport Locator</title>
</head>
<body>
<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATmoH83Ly9iQx1uFnEHAlDBTwM0brOpm-All5BF6PoaKBxRWWERS1Yg55rmr66zkZ8YxvBZy71GJpEw"
      type="text/javascript"></script>
<style>
	#map {
		border:		1px solid #000000;
		height:		600px;
		width:		1000px;
	}
 
</style>
<script type="text/javascript">
    //< ![CDATA[
        var map;
    	var markers = [];
        var point = [];
        var i = 0;
		$(document).ready(function() {
			if (GBrowserIsCompatible()) {
				// Initialize the map.
				map = new GMap2(document.getElementById("map"));
				map.addControl(new GLargeMapControl());
				map.setCenter(new GLatLng(29.873519444400,121.554127777800), 13);
                                map.addControl(new GMapTypeControl());
                                $.ajax({type:"GET",url:"writexml.jsp",dataType:"xml",
					success:function(data,textStatus) {
						$("marker",data).each(function() {
							// Attributes for each marker.
	            			var lat = parseFloat($(this).attr("lat"));
	            			var lng = parseFloat($(this).attr("lng"));
	            			point[i] = new GLatLng(lat,lng);
 
	            			var html = $("html",this).text();
                                        //alert("Hello");
	            			// Create the marker.
	            			var marker = new GMarker(point[i]);
	            			i = i+1;
					        GEvent.addListener(marker, "click", function() {
								marker.openInfoWindowHtml(html);
					        });
 
	            			map.addOverlay(marker);
						});
                                        var polyline = new GPolyline(point, "#FF0000", 10);
                                        map.addOverlay(polyline);
					},
 
					error:function(XMLHTTPRequest,textStatus,errorThrow){
						alert("There was an error retrieving the marker information.");
					}});
			}
		});
 
		$(document.body).unload(function() {
			if (GBrowserIsCompatible()) {
				GUnload();
			}
		});
   //]]>
</script>
<div id="map"></div>
</body>
</html>

阅读全文…

Tags: , ,
分类: Code 标签: , ,

编写数据库存储过程实现商品出库

2010年4月26日 Kimi 没有评论

数据库的表结构如下

存储过程ap_popWhpro脚本:

alter procedure ap_popWhpro
	@pro_id		int,
	@wh_id		int,
	@num		int,
	@sum		money	output
as
begin
	declare
		@pos1		int,
		@pos2		int,
		@totNum		int,
		@curNum		int,
		@curPrice	money,
		--@sum		money,
		@sqlCmd		nvarchar(200),
		@fldNum		varchar(10),
		@fldPrice	varchar(10)
	select @pos1 = pos1, @pos2 = pos2, @totNum = totNum
		from whproduct
		where pro_id = @pro_id and wh_id = @wh_id
	if @totNum &lt; @num 	begin 		return -1 	end 	set @sum = 0 	while @num &gt; 0
	begin
		if @pos1&gt;8
		begin
			set @pos1 = @pos1 % 8
		end
		set @fldNum = 'num' + Convert(varchar(2), @pos1)
		set @fldPrice = 'price' + Convert(varchar(2), @pos1)
		set @sqlCmd = 'select @curNum = ' + @fldNum + ',@curPrice = '+ @fldPrice +' from whproduct where pro_id = @pro_id and wh_id = @wh_id'
		exec sp_executesql @sqlCmd, N'@curNum int output,@curPrice int output,@wh_id int, @pro_id int',@curNum output,@curPrice output,@wh_id, @pro_id
		if @curNum &lt; @num
		begin
			set @num = @num - @curNum
			set @pos1 = @pos1 + 1
			set @sum = @sum + @curPrice*@curNum
			set @sqlCmd = 'update whProduct set ' + @fldNum + ' = 0 ' + ', totNum = totNum - ' + Convert(varchar(5), @curNum) + 'where pro_id = @pro_id and wh_id = @wh_id'
		end
		else
		begin
			set @sqlCmd = 'update whProduct set ' + @fldNum + ' = ' + Convert(varchar(5), @curNum - @num)
					+ ', totNum = totNum - ' + Convert(varchar(5), @num) + 'where  pro_id = @pro_id and wh_id = @wh_id'
			set @num = 0
			set @sum = @sum + @curPrice*(@curNum - @num)
			set @pos1 = @pos1 + 1
		end
		exec sp_executesql @sqlCmd, N'@wh_id int, @pro_id int', @wh_id, @pro_id
	end
	set @sqlCmd = 'update whProduct set pos1 = ' + Convert(varchar(2), @pos1-1)
			+ 'where  pro_id = @pro_id and wh_id = @wh_id'
	exec sp_executesql @sqlCmd, N'@wh_id int, @pro_id int', @wh_id, @pro_id
end

执行存储过程的脚本:

select * from whproduct
 
declare
	@total	money
execute ap_popWhpro 1001,102,20,@total output
select @total totalmoney
 
select * from whproduct

执行效果:
第一排是执行前表中的数据,第二排是出库商品的总金额,第三排是执行后表的数据

Tags: ,
分类: Code 标签: ,

Little Red Riding Hood

2010年4月26日 Kimi 没有评论

I am a little girl. My name was Little Red Riding Hood. I often wear a red cap. So they call me little red riding. Today, my grandma is ill. Mother asked me go to visit her and bring some cakes and some other foods. Mother told me do not leave the path. I wore my red cap and start my way.

On the way, I met a wolf, he said hello to me very friendly, I said hello to him too.

”Hi, little red riding hood, where are you going? Why you are alone?” He asked

”My grandma was ill, I go to visit her and bring her some foods, she will become well by eating these foods.” I said.

“Where is your grandma’s house?” asked he

“Not too far, just near the forest.”

“Oh! It’s good. I am going there too. Why don’t we go there together?” said he.

“Ok!”

He was very happy on our way. Suddenly, I realized that he is a bad man, mother have told me that he did a lot of bad things such as eat little babies. Maybe today I would be eaten by him. I should get rid of him by some ways.

I said to him:”Mr. Wolf. There are so many beautiful flowers, can you pick some for me taking to my grandma, she may be very happy after seeing these flowers.”

He said:”Eh. You do it. I will look after your things.”

“I am a little girl. I am very tired after walking so far. I am asking you to help me. ”

“Ok! But you should stay here without going anywhere.”

After he entered the forest. I ran away very quickly. When he found I have run away, he shouted at me. He asked me to stop and he will eat me if he reaches me. On the way, I saw a hunter, I asked him help me. He asked me to go to grandma’s home and hide somewhere. I ran to grandma’s home and hid in the cupboard with grandma. The hunter putted on my grandma’s clothes dressed him in her cap, laid himself in bed. The wolf came very soon. He shouted:” Open the door now.” The hunter got up and went to open the door. The wolf did not recognize that he is not my grandma and got in straight. He said: “Tell me where the little girl is, I will eat both of you. Or I will eat you first then find her and eat.” To his surprised, the “grandma” behind him said:”Put up your hands, and get down on your knees. I will kill you! I am a hunter!” ”Bang!” The wolf was killed by the hunter.

We get out of the cupboard and said thanks to him. Then he said BYEBYE to us and leaved away with the dead wolf. Grandma gets well after ate the foods.

What an interesting day!

Tags: ,
分类: English 标签: ,