.net技术小知识点

1、repeater控件绑定时间非空判断

     

 <%#Convert.IsDBNull(Eval("Time_Ok")) ? "--" : Eval("Time_Ok")%>

2、aspx页面通过jquery选中设定值的下拉框

  var key=<%=locked %>;
  $("#sellcokId option[value='"+key+"']").attr("selected","selected"); 

3、jquery获取下拉框选中的值

     

 var id = $('#select_id option:selected').val();

 4、页面跳转时页面嵌套重叠问题解决方法

  if (window != window.top.window) {
            window.top.window.location.href = '/admin/login.aspx';
        }

 5、修改sql server 自增主键ID初始值

     DBCC CHECKIDENT ('Person',RESEED,100000000) 

 6、vs使用快捷键小集

      

        Ctrl+j 智能提示、Ctrl+e+d 对齐、 F6 生成解决方案、 Ctrl+shift+空格 显示方法参数

7、sql 根据时间查询

   

Sql Server中查询今天、昨天、本周、上周、本月、上月数据

在做Sql Server开发的时候有时需要获取表中今天、昨天、本周、上周、本月、上月等数据,这时候就需要使用DATEDIFF()函数及GetDate()函数了。
DATEDIFF ( datepart , startdate , enddate )
释义:计算时间差
datepare值:year | quarter | month | week | day | hour | minute | second | millisecond
startdate:开始日期
enddate :结束日期
GetDate()
释义:获取当前的系统日期

下面例子中表名为tablename,条件字段名为inputdate

查询今天

SELECT * FROM tablename where DATEDIFF(day,inputdate,GETDATE())=0

查询昨天

SELECT * FROM tablename where DATEDIFF(day,inputdate,GETDATE())=1

查询本周

SELECT * FROM tablename where datediff(week,inputdate,getdate())=0

查询上周

SELECT * FROM tablename where datediff(week,inputdate,getdate())=1

查询本月

SELECT * FROM tablename where DATEDIFF(month,inputdate,GETDATE())=0

查询上月

SELECT * FROM tablename where DATEDIFF(month,inputdate,GETDATE())=1

查询本季度的

select * from T_InterViewInfo where datediff(QQ,inputdate,getdate())=0

  

sqlserver中如何实现时间按月,日,小时分组查询
--按照月份统计
select count(id) cnt,datepart(mm,time) [Month]
from [table]
where [time] between '2007/09/08 09:10:43' and '2007/10/09 04:32:37'
group by datepart(mm,time)
--按照日统计
select count(id) cnt,datepart(dd,time) [Day]
from [table]
where time between '2007/09/08 09:10:43' and '2007/10/09 04:32:37'
group by datepart(dd,time)
--按照小时统计
select count(id) cnt,datepart(hh,time) [Hour]
from [table]
where [time] between '2007/09/08 09:10:43' and '2007/10/09 04:32:37'

group by datepart(hh,time)

==========================================================================

1、每年
select year(ordertime) AS '年',
sum(Total) '销售合计'
from order_list
group by year(ordertime)

2、每月
select year(ordertime) '年',
month(ordertime) '月',
sum(Total) '销售合计'
from order_list
group by year(ordertime),
month(ordertime)

3、每日
select year(ordertime) '年',
month(ordertime) '月',
day(ordertime) '日',
sum(Total) '销售合计'
from order_list
group by year(ordertime),
month(ordertime),
day(ordertime)

另外每日也可以这样:
select convert(char(8),ordertime,112) dt,
sum(Total) '销售合计'
from order_list
group by convert(char(8),ordertime,112)

另外,每月(年、日)的记录条数
select year(ordertime) '年',
month(ordertime) '月',
count(*) '销售记录'
from order_list
group by year(ordertime),

month(ordertime)

8、执行webapi项目命令

    

在cmd命令行窗口中,切换到webapi项目文件下面,输入 dotnet watch run 命令就可以将程序执行起来,就不用每一次修改完api接口,都要去重新启动项目
如(目录需要指定到具体的api项目根目录):D:project rxxxxwwapi dotnet watch run

 9、sql server maanger studio下载地址

  

https://docs.microsoft.com/zh-cn/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-2017

10、visual studio 老版本下载地址

https://visualstudio.microsoft.com/zh-hans/vs/older-downloads/

 11、使项目脱离svn管理

    

建一个记事本文件,然后吧这句话复制进去
for /r . %%a in (.) do @if exist "%%a.svn" rd /s /q "%%a.svn"
然后保存,在吧记事本文件从命名 叫 删除SVN信息.bat ,这时候要注意后缀名不是txt而是bat 了,然后双击这个批处理文件就可以解决
要在那个项目的根目录

 12、在安装是vs目录:D:installvs2017Common7IDE 里面有一个WcfTestClient.exe可执行文件,该程序可测试wcf测试客户端

 13、vscode快捷键

      

代码行向左或向右缩进:   Ctrl+[ 、 Ctrl+]

复制或剪切当前行/当前选中内容:   Ctrl+C 、 Ctrl+V

代码格式化:   Shift+Alt+F

向上或向下移动一行:   Alt+Up 或 Alt+Down

向上或向下复制一行:   Shift+Alt+Up 或 Shift+Alt+Down

在当前行下方插入一行:   Ctrl+Enter

在当前行上方插入一行:   Ctrl+Shift+Enter

14、webstorm快捷键

     

ctrl + / : 单行注释
ctrl + shift + / : 块注释
ctrl+alt+L 格式化代码
Ctrl+Shift+Up/Down 代码向上/下移动。
ctrl + d: 行复制
原文地址:https://www.cnblogs.com/wenghan/p/12573426.html