个人随笔-20070621关键代码-2
1.获取最大id
2.在已经得到表的情况下 用gridview对其进行筛选 排序得到最大值
(1). 定义列时必须注意System.Int32
3.曾经年轻时代的代码 连接数据方法,添加删除修改等
4.保留小数的几中种方法
5.function 中调用后台 变量
6.透明flash
5.function 中调用后台 变量
6.透明flash
7.div 弹出窗口
8.加个外框
9.0823Membership 所设计到的代码
10.string[] 与ArrayList 的转换 并且判断是否包含某个 字段
=======================获取最大id
8.加个外框
9.0823Membership 所设计到的代码
10.string[] 与ArrayList 的转换 并且判断是否包含某个 字段
=======================获取最大id
string getid = "select max(sp_id) from SoppingBag";//sp_id 类型为int 型的列,SoppingBag:数据表名
public static int GetMax_id(string strcmd)//获取留言反馈 数据库中的 最大 ID
{
string CString="integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
SqlConnection Conn=new SqlConnection(CString);//创建连接对象
{
string CString="integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
SqlConnection Conn=new SqlConnection(CString);//创建连接对象
int index;
System.Data.SqlClient.SqlCommand cmd = new SqlCommand();
cmd.CommandText = strcmd;
cmd.Connection = Conn;
Conn.Open();
object re = cmd.ExecuteScalar();
Conn.Close();
index = Convert.ToInt32(re);
return index;
}
System.Data.SqlClient.SqlCommand cmd = new SqlCommand();
cmd.CommandText = strcmd;
cmd.Connection = Conn;
Conn.Open();
object re = cmd.ExecuteScalar();
Conn.Close();
index = Convert.ToInt32(re);
return index;
}
====================在已经得到表的情况下 用gridview对其进行筛选 排序得到最大值
static int GetMaxId(DataTable dt)
{
int s = 0;
DataView dv = dt.DefaultView;
dv.Sort = "ProductId DESC";//ProductId 为列名
s =Convert.ToInt32(dv[0].Row["ProductId"]);
return s + 1;
}
{
int s = 0;
DataView dv = dt.DefaultView;
dv.Sort = "ProductId DESC";//ProductId 为列名
s =Convert.ToInt32(dv[0].Row["ProductId"]);
return s + 1;
}
定义列时必须注意System.Int32
DataColumn column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.AllowDBNull = false;
column.Caption = "ProductId";
column.ColumnName = "ProductId";
column.DataType = System.Type.GetType("System.Int32");
column.AllowDBNull = false;
column.Caption = "ProductId";
column.ColumnName = "ProductId";
=========================曾经年轻时代的代码 连接数据方法,添加删除修改等
public static DataSet gungunDb(string Table)
{
string ConnString = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
string CmdString= "select * from "+Table;
SqlConnection conn = new SqlConnection (ConnString);
conn.Open();
SqlDataAdapter Ada =new SqlDataAdapter(CmdString,conn);
DataSet ds = new DataSet();
Ada.Fill(ds);
conn.Close();
return ds;
}
public static int UpdateInsertDelete(string CmdString)
{
string ConnString = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
SqlConnection conn = new SqlConnection (ConnString);
conn.Open();
SqlCommand cmd = new SqlCommand (CmdString,conn);
cmd.ExecuteNonQuery();
conn.Close();
return 0;
}
================== 保留小数的几中种方法
方法--:
decimal de = Math.Round(2.123456465m,2);
TextBox1.Text = de.ToString();
二:
double de = 2.123456465;
Response.Write (de.ToString("N5"));//这里n5表示保留5位小数
double de = 2.123456465;
Response.Write (de.ToString("0.000000"));//这里00000表示保留5位小数
=====================视频播放
<object id="player" width="200" height="200" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param name="AutoStart" value="-1" />
<param name="Balance" value="0" />
<param name="Enabled" value="-1" />
<param name="EnableContextMenu" value="-1" />
<param name="Url" value="要显示的图片或者视频文件地址" />
<param name="PlayCount" value="10" />
<param name="Rate" value="1" />
<param name="CurrentPosition" value="0" />
<param name="CurrentMarker" value="0" />
<param name="DefaultFrame" value="" />
<param name="stretchToFit" value="0" />
<param name="volume" value="50" />
<param name="mute" value="0" />
<param name="uiMode" value="None" />
<param name="windowlessVideo" value="0" />
<param name="fullScreen" value="0" />
<param name="enableErrorDialogs" value="-1" />
<!--是否自动播放-->
<!--调整左右声道平衡,同上面旧播放器代码-->
<!--播放器是否可人为控制-->
<!--是否启用上下文菜单-->
<!--播放的文件地址-->
<!--播放次数控制,为整数-->
<!--播放速率控制,1为正常,允许小数,1.0-2.0-->
<!--控件设置:当前位置-->
<!--控件设置:当前标记-->
<!--显示默认框架-->
<!--是否按比例伸展-->
<!--默认声音大小0%-100%,50则为50%-->
<!--是否静音-->
<!--播放器显示模式:Full显示全部;mini最简化;None不显示播放控制,只显示视频窗口;invisible全部不显示-->
<!--如果是0可以允许全屏,否则只能在窗口中查看-->
<!--开始播放是否自动全屏-->
<!--是否启用错误提示报告-->
</object>
============== 得到一个字符串中 某个字符的个数
string str = "fdsfds/fdsfd/s//fd/sfds/sfds";
int i = str.Split('/').Length - 1;
{
string ConnString = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
string CmdString= "select * from "+Table;
SqlConnection conn = new SqlConnection (ConnString);
conn.Open();
SqlDataAdapter Ada =new SqlDataAdapter(CmdString,conn);
DataSet ds = new DataSet();
Ada.Fill(ds);
conn.Close();
return ds;
}
public static int UpdateInsertDelete(string CmdString)
{
string ConnString = "integrated security=SSPI;data source=.;persist security info=False;initial catalog=gunrunning";
SqlConnection conn = new SqlConnection (ConnString);
conn.Open();
SqlCommand cmd = new SqlCommand (CmdString,conn);
cmd.ExecuteNonQuery();
conn.Close();
return 0;
}
================== 保留小数的几中种方法
方法--:
decimal de = Math.Round(2.123456465m,2);
TextBox1.Text = de.ToString();
二:
double de = 2.123456465;
Response.Write (de.ToString("N5"));//这里n5表示保留5位小数
double de = 2.123456465;
Response.Write (de.ToString("0.000000"));//这里00000表示保留5位小数
=====================视频播放
<object id="player" width="200" height="200" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param name="AutoStart" value="-1" />
<param name="Balance" value="0" />
<param name="Enabled" value="-1" />
<param name="EnableContextMenu" value="-1" />
<param name="Url" value="要显示的图片或者视频文件地址" />
<param name="PlayCount" value="10" />
<param name="Rate" value="1" />
<param name="CurrentPosition" value="0" />
<param name="CurrentMarker" value="0" />
<param name="DefaultFrame" value="" />
<param name="stretchToFit" value="0" />
<param name="volume" value="50" />
<param name="mute" value="0" />
<param name="uiMode" value="None" />
<param name="windowlessVideo" value="0" />
<param name="fullScreen" value="0" />
<param name="enableErrorDialogs" value="-1" />
<!--是否自动播放-->
<!--调整左右声道平衡,同上面旧播放器代码-->
<!--播放器是否可人为控制-->
<!--是否启用上下文菜单-->
<!--播放的文件地址-->
<!--播放次数控制,为整数-->
<!--播放速率控制,1为正常,允许小数,1.0-2.0-->
<!--控件设置:当前位置-->
<!--控件设置:当前标记-->
<!--显示默认框架-->
<!--是否按比例伸展-->
<!--默认声音大小0%-100%,50则为50%-->
<!--是否静音-->
<!--播放器显示模式:Full显示全部;mini最简化;None不显示播放控制,只显示视频窗口;invisible全部不显示-->
<!--如果是0可以允许全屏,否则只能在窗口中查看-->
<!--开始播放是否自动全屏-->
<!--是否启用错误提示报告-->
</object>
============== 得到一个字符串中 某个字符的个数
string str = "fdsfds/fdsfd/s//fd/sfds/sfds";
int i = str.Split('/').Length - 1;
string path = "/node";
string rootpath = "SiteMap";
for (int j = 0; j < i; j++)
{
rootpath = rootpath + path;
}
Response.Write(rootpath);
============== function 中调用后台 变量
function getpet () {
string rootpath = "SiteMap";
for (int j = 0; j < i; j++)
{
rootpath = rootpath + path;
}
Response.Write(rootpath);
============== function 中调用后台 变量
function getpet () {
var birthyear = <%= i %> ;
}
后代的定义
public int i = 1986;
=============透明flash
<embed src=images/revengeboy.swf wmode=transparent width=700 height=87>
}
后代的定义
public int i = 1986;
=============透明flash
<embed src=images/revengeboy.swf wmode=transparent width=700 height=87>
==========div 弹出窗口
==============在存储过程中 定义表变量
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
div 弹出窗口
==============在存储过程中 定义表变量
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[Pagination_Revengeboy]
(@startIndex INT,
@pageSize INT,
@WhichID varchar(16),
@TableName nvarchar(50)
)
AS
declare @Tab nvarchar(50)
declare @sql varchar(200)
set @Tab= @TableName
set @sql = 'WITH tablelist AS (SELECT ROW_NUMBER() OVER (ORDER BY Tmp.'+ @WhichID+' DESC) AS Row, * from '+ @Tab +' as Tmp)
SELECT * FROM tablelist WHERE Row between '+cast(@startIndex as varchar(20)) +' and '+ cast(@startIndex + @pageSize -1 as varchar(20))
begin
exec (@sql)
print @sql
end
==============加个外框
<fieldset style="height: 191px; padding-bottom:6px; padding-top:4px; width: 340px;"><legend><span>
<asp:Label ID="lbCompanyInfors" runat="server" Text="revengeboy"></asp:Label></span></legend>
内容
</fieldset>
=========0823Membership 所设计到的代码
后台代码
前台代码
(@startIndex INT,
@pageSize INT,
@WhichID varchar(16),
@TableName nvarchar(50)
)
AS
declare @Tab nvarchar(50)
declare @sql varchar(200)
set @Tab= @TableName
set @sql = 'WITH tablelist AS (SELECT ROW_NUMBER() OVER (ORDER BY Tmp.'+ @WhichID+' DESC) AS Row, * from '+ @Tab +' as Tmp)
SELECT * FROM tablelist WHERE Row between '+cast(@startIndex as varchar(20)) +' and '+ cast(@startIndex + @pageSize -1 as varchar(20))
begin
exec (@sql)
print @sql
end
==============加个外框
<fieldset style="height: 191px; padding-bottom:6px; padding-top:4px; width: 340px;"><legend><span>
<asp:Label ID="lbCompanyInfors" runat="server" Text="revengeboy"></asp:Label></span></legend>
内容
</fieldset>
=========0823Membership 所设计到的代码
后台代码
后台代码
前台代码
前台代码
=========string[] 与ArrayList 的转换 并且判断是否包含某个 字段
string[] ListRoles = Roles.GetAllRoles();
ArrayList al = new ArrayList(ListRoles);
if (al.Contains(RolesName))
{
//Response.Write("已存在"+RolesName);
}
else
{
//Response.Write("不存在" + RolesName);
Roles.CreateRole(RolesName);
}
posted on 2007-06-21 18:09 RevengeBoy 阅读(366) 评论(0) 编辑 收藏 举报