工作笔记2
2015-08-24 19:03
267 查看
1、js的$('#form1').serialize()方法可以把表单中的元素转成一串参数
2、数据库有三种锁机制:共享锁、排它锁(其他进程不能读也不能改)、更新锁(其他进程可以读不能改,将来会升级为排它锁)和意向锁(作为标志,告诉其他进行表中有记录被锁,需等待)
1)一个资源上不能同时共存共享锁和排它锁,但可以共存两个共享锁;
2)T1:
begin tran
update table set column1='hello' where id=10
T2:
begin tran
update table set column1='world' where id=20
如果Id是主键,则上述的两个事务不会产生死锁,他们会根据索引直接定位到该记录然后加排它锁
如果Id不是主键没有索引,则会产生死锁,因为T1执行时会给Id=10的记录加排它锁,T2再执行会首
先进行全表扫描试图找到Id=20的记录,因为表中有了排它锁,所以全表扫描进行不下去就会等待
3、为了解决死锁,引入了更新锁:
更新锁的意思是:“我现在只想读,你们别人也可以读,但我将来可能会做更新操作,我已经获取了从共享锁(用来读)到排他锁(用来更新)的资格”。一个事务只能有一个更新锁获此资格。
4、arguments包含所有参数,可以点出来具体的参数
5、用MVC自带的Attribute验证太麻烦(比较两个字段的大小就不好判断了),前台绑定必须是强类型视图TextBoxFor(m=>m.value),此时不能对value字段进行类型转换,因为模板的字段仅用于展示
6、后退事件:history.go(-1);
7、图片刷新需要加个随机参数 Math.random()
<img id="image" src="/Content/images/statistic/LineChart.jpeg?r=0.48441014741547406">
8、把枚举转换成字典:
ViewData["resultlist"] = typeof(ServiceConfig.SERVICE_RESULT).ToDictionary().Select(s => new
SelectListItem() { Text = s.Key,Value = s.Value}).ToList<SelectListItem>()
9、a标签的href属性需要指定http:,若未指定则默认是http://localhost(中文的标点符号":"无法识别,会当做未指定协议名称来处理)
10、<a href="data:image/jpg;base64,code"/>64位编码显示图片流,高版本浏览器支持
11、代码配置开启目录浏览
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
12、js计算时间差
13、decimal类型的数据初始化:decimal price=0m;
14、数据库可以修改自增长的id
SET IDENTITY_INSERT notice on
insert into notice(id,title) values(17,'淘宝订单自动发货说明')
SET IDENTITY_INSERT notice off
15、查看EF报错的具体信息:
System.Data.Entity.Validation.DbEntityValidationException,最简单的就是
1、Install-Package EntityFramework
2、Enable-Migrations -Force
3、Add-Migration actionName
4、Update-Database -Force
注意:1) Enable-Migrations -StartUpProjectName ProjectName (如果在“Package Manager Console”中选择了默认项目可以不设置“-StartUpProjectName”参数;如果多次执行此命令可以添加-Force参数。)
2)Update-Database -TargetMigration 201404240917497_SetDateCreatedToNullable (复原到指定版本201404240917497_SetDateCreatedToNullable)
3) Get-Migrations 获取Migration的记录
参考:http://www.cnblogs.com/libingql/p/3330880.html http://www.bkjia.com/Asp_Netjc/1007458.html
19、ActiveX控件打印
20、
2、数据库有三种锁机制:共享锁、排它锁(其他进程不能读也不能改)、更新锁(其他进程可以读不能改,将来会升级为排它锁)和意向锁(作为标志,告诉其他进行表中有记录被锁,需等待)
1)一个资源上不能同时共存共享锁和排它锁,但可以共存两个共享锁;
2)T1:
begin tran
update table set column1='hello' where id=10
T2:
begin tran
update table set column1='world' where id=20
如果Id是主键,则上述的两个事务不会产生死锁,他们会根据索引直接定位到该记录然后加排它锁
如果Id不是主键没有索引,则会产生死锁,因为T1执行时会给Id=10的记录加排它锁,T2再执行会首
先进行全表扫描试图找到Id=20的记录,因为表中有了排它锁,所以全表扫描进行不下去就会等待
3、为了解决死锁,引入了更新锁:
更新锁的意思是:“我现在只想读,你们别人也可以读,但我将来可能会做更新操作,我已经获取了从共享锁(用来读)到排他锁(用来更新)的资格”。一个事务只能有一个更新锁获此资格。
4、arguments包含所有参数,可以点出来具体的参数
5、用MVC自带的Attribute验证太麻烦(比较两个字段的大小就不好判断了),前台绑定必须是强类型视图TextBoxFor(m=>m.value),此时不能对value字段进行类型转换,因为模板的字段仅用于展示
6、后退事件:history.go(-1);
7、图片刷新需要加个随机参数 Math.random()
<img id="image" src="/Content/images/statistic/LineChart.jpeg?r=0.48441014741547406">
8、把枚举转换成字典:
ViewData["resultlist"] = typeof(ServiceConfig.SERVICE_RESULT).ToDictionary().Select(s => new
SelectListItem() { Text = s.Key,Value = s.Value}).ToList<SelectListItem>()
9、a标签的href属性需要指定http:,若未指定则默认是http://localhost(中文的标点符号":"无法识别,会当做未指定协议名称来处理)
10、<a href="data:image/jpg;base64,code"/>64位编码显示图片流,高版本浏览器支持
11、代码配置开启目录浏览
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
12、js计算时间差
function checkDate() { var date1 = Date.parse(new Date($("#staTime").val().replace(/-/g, "/"))); //开始时间 var date2 = Date.parse(new Date($("#endTime").val().replace(/-/g, "/"))); //结束时间 var date3 = date2 - date1; //时间差的毫秒数 //计算出相差天数 var days = Math.floor(date3 / (24 * 3600 * 1000)); if (days>2) { $.growl.warning({ message: "日期间隔超过两天,请重新选择", title: '提示' }); return false; } return true; }
13、decimal类型的数据初始化:decimal price=0m;
14、数据库可以修改自增长的id
SET IDENTITY_INSERT notice on
insert into notice(id,title) values(17,'淘宝订单自动发货说明')
SET IDENTITY_INSERT notice off
15、查看EF报错的具体信息:
System.Data.Entity.Validation.DbEntityValidationException,最简单的就是
try { // 写数据库 } catch (DbEntityValidationException dbEx) { } 16、设置默认选中 select标签 $('#select').val(['select1','select2']) radio标签 $(':radio').val(['radio1','radio2']) checkbox标签 $(':checkbox').val(['checkbox1','checkbox2']) 17、金额转成大写
//金额转成大写 function ConvertDX(num) { var strOutput = ""; var strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分'; num += "00"; var intPos = num.indexOf('.'); if (intPos >= 0) num = num.substring(0, intPos) + num.substr(intPos + 1, 2); strUnit = strUnit.substr(strUnit.length - num.length); for (var i = 0; i < num.length; i++) strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1); return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元"); };
18、Code First模式创建数据库:
1、Install-Package EntityFramework
2、Enable-Migrations -Force
3、Add-Migration actionName
4、Update-Database -Force
注意:1) Enable-Migrations -StartUpProjectName ProjectName (如果在“Package Manager Console”中选择了默认项目可以不设置“-StartUpProjectName”参数;如果多次执行此命令可以添加-Force参数。)
2)Update-Database -TargetMigration 201404240917497_SetDateCreatedToNullable (复原到指定版本201404240917497_SetDateCreatedToNullable)
3) Get-Migrations 获取Migration的记录
参考:http://www.cnblogs.com/libingql/p/3330880.html http://www.bkjia.com/Asp_Netjc/1007458.html
19、ActiveX控件打印
<script> var printer; $(function () { if (request("p") != "true") { if (document.all.print_ocx.object != null) { try { printer = document.getElementById("print_ocx"); printer.SET_LICENSES("上海商为电子商务有限公司", "E6F8119E6EE17DEFD00A1ECF1E83CA26", "", ""); } catch (e) { alert("没有安装打印控件"); window.open("http://www.lodop.net/uploads/file/sample/install_lodop32.zip"); } } } }) function printView() { printer.PRINT_INIT("12"); printer.SET_PRINT_PAGESIZE(1, 0, 0, "A4"); printer.ADD_PRINT_URL(10, 10, 765, 270, 'http://' + window.location.host + "/PayOrderNew/DetailsPrint/@Model.id"); printer.PREVIEW(); } function print() { printer.PRINT_INIT("12"); printer.SET_PRINT_PAGESIZE(1, 0, 0, "A4"); printer.ADD_PRINT_URL(10, 10, 765, 270, 'http://' + window.location.host + "/PayOrderNew/DetailsPrint/@Model.id"); printer.print(); } </script> <object id="print_ocx" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0" height="0"></object>
20、
相关文章推荐
- 深入理解MVC与MVP
- 云时代的分布式数据库:阿里分布式数据库服务DRDS
- UVA 568 - Just the Facts
- IOS UITextView自适应高度
- 总线设备驱动模型——platform篇
- poj2503
- IOS UITextView自适应高度
- CSS 之 光进入光
- 安卓程序国际化,手机屏幕适配器
- 腾讯龙界启示录 v2.1.0 安卓版
- mac 常用 终端命令
- HDU 1286 找新朋友【欧拉函数 最基础应用】
- 1083. List Grades
- windows应用程序双机调试方法
- Qt QTreeWidget 树形结构实现
- python嵌套dict的深度遍历合并
- zen-Coding在Notepad++中的使用
- android gif 动画播放
- http的状态响应码
- 链式A+B