• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C#基础知识小结

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
设置操作系统日期格式

//公司电脑各式各样的都有,里面的设置也有很多不统一的,我们做软件一般会从系统中获取一些数据,比如日期时间,
//环境变量的路径参数,可以用批处理文件达到我们所想要的目的,也可以用C#代码 也可以使用批处理,拷贝到新建文本里面另存为 时间修复.reg 即可
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\International]
"iCountry"="86"
"iCurrDigits"="2"
"iCurrency"="0"
"iDate"="2"
"iDigits"="2"
"iLZero"="0"
"iMeasure"="0"
"iNegCurr"="2"
"iTime"="1"
"iTLZero"="1"
"Locale"="00000804"
"s1159"="上午"
"s2359"="下午"
"sCountry"="中华人民共和国"
"sCurrency"="¥"
"sDate"="-"
"sDecimal"="."
"sLanguage"="CHS"
"sList"=","
"sLongDate"="yyyy-MM-dd"
"sShortDate"="yyyy-MM-dd"
"sThousand"=","
"sTime"=":"
"sLongDate16"="dddd', 'MMMM' 'dd', 'yyyy"
"iTimePrefix"="0"
"iCentury"="0"
"iDayLZero"="1"
"iMonLZero"="1"
"iChinaYear"="0"
"iCalendar"="1"
"sTimeFormat"="HH:mm:ss"
"sMonDecimalSep"="."
"sMonThousandSep"=","
"iNegNumber"="1"
"sNativeDigits"="0123456789"
"NumShape"="1"
"iCalendarType"="1"
"iFirstDayOfWeek"="6"
"iFirstWeekOfYear"="0"
"sGrouping"="3;0"
"sMonGrouping"="3;0"
"sPositiveSign"=""
"sNegativeSign"="-"

[HKEY_CURRENT_USER\Control Panel\International\Geo]
"Nation"="45"
View Code

 

)]
        public static extern int GetSystemDefaultLCID();
        [DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA")]
        public static extern int SetLocaleInfo(int Locale, int LCType, string lpLCData);
        public const int LOCALE_SLONGDATE = 0x20;
        public const int LOCALE_SSHORTDATE = 0x1F;
        public const int LOCALE_STIME = 0x1003;

        public void SetDateTimeFormat()
        {
            try
            {
                int x = GetSystemDefaultLCID();
                SetLocaleInfo(x, LOCALE_STIME, "HH:mm:ss");        //时间格式  
                SetLocaleInfo(x, LOCALE_SSHORTDATE, "yyyy-MM-dd");   //短日期格式    
                SetLocaleInfo(x, LOCALE_SLONGDATE, "yyyy-MM-dd");   //长日期格式   
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }  

 

SQL 动态添加查找条件
if object_id('test')> 0 drop table test
 
create table test 
(id int primary key ,
name nvarchar(111))
 
 
insert test 
select 1,'施瓦辛格'
union all select 2,'陈道明'
 
select * from test
 
 
ALTER proc tSDFSDFest
@name nvarchar(20) = null
as
begin
--等于
select * from test where name =  
case when @name is null OR @NAME = '' then  name else @name end
--相似
select * from test where name LIKE 
case when @name is null OR @NAME = '' then  name else  '%'+@name+'%' end
end
 
 
exec tSDFSDFest 
exec tSDFSDFest '陈道明'
exec tSDFSDFest '陈道'

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
c#写入cookie。js获取发布时间:2022-07-14
下一篇:
C#简单反射实现winform左侧树形导航,右侧切换内容发布时间:2022-07-14
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap