打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET简单整理收藏(1)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1945  更新时间:2009/4/23 10:39:15  文章录入:mintao  责任编辑:mintao
D noWrap>
<asp:dropdownlist id="DropDownList1" runat="server" Width="48px" AutoPostBack="True"></asp:dropdownlist>
</TD>
<TD noWrap width="5"></TD>
<TD noWrap>
<asp:label id="Label3" runat="server" ForeColor="White" Width="15px">页</asp:label>
</TD>
<TD noWrap width="5"></TD>
<TD noWrap>
</TD>
</TR>
</TABLE>
//传参
private void DataGrid1_ItemDataBound_4(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
 //特效
 if(e.Item.ItemIndex!=-1)
 {
  int orderid=e.Item.ItemIndex+1;
  e.Item.Cells[0].Text=orderid.ToString();    

e.Item.Attributes.Add("onmouseover","this.setAttribute(''''BKC'''',this.style.backgroundColor);this.style.backgroundColor=''''#3a6ea5''''

");
  e.Item.Attributes .Add("onmouseout","this.style.backgroundColor=this.getAttribute(''''BKC'''');");
  if(e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.Item)
  {
  //弹出一个完整的IE窗口   

e.Item.Attributes.Add("onclick","window.open(''''message.aspx?actid="+e.Item.Cells[1].Text+"'''');");    

//e.Item.Attributes.Add("onclick","window.open(''''detail.aspx?ID="+e.Item.Cells[1].Text+"'''',''''newwin'''',''''width=750,height=600,scrol

lbars=yes,top=50,left=50'''');");
  }
 }
}
Response.Write("<script>window.open(''''excel.aspx'''',''''_blank'''');</" + "script>");
this.linkdb();
//
string sql="select * from VIEW_USRACT WHERE ACTID=''''"+Session["strmta"].ToString()+"''''";
SqlCommand cmd=new SqlCommand(sql,conn);
try
{
 SqlDataReader dr=cmd.ExecuteReader();
 if(dr.Read())
 {  
  this.ACTIDtext.Text=dr[0].ToString();
  this.USRNAMEtext.Text=dr[1].ToString();
 }
}
//添加
sql="insert into ContList()

values(''''"+this.txtactid.Text.Trim()+"'''',''''"+count.ToString()+"'''',''''"+this.txtCName.Text.Trim()+"'''',''''"+this.txtCRank.Text.Trim()+"''''

,''''"+this.txtCphone1.Text.Trim()+"'''',''''"+this.txtCphone2.Text.Trim()+"'''',''''"+this.txtHdPhone.Text.Trim()+"'''',''''"+this.txtHmPhone.Tex

t.Trim()+"'''',''''"+this.txtContBP.Text.Trim()+"'''',''''"+this.txtCmemo.Text.Trim()+"'''',''''"+sqlstr+"'''')";
SqlCommand  myCommand=new SqlCommand(sql,conn);
myCommand.ExecuteNonQuery();
//修改
string sql1="";
sql1="update ContList set RouteID=''''"+sqlstr+"'''' where ActID=''''"+this.txtactid.Text.Trim()+"''''";
SqlCommand  cmd=new SqlCommand(sql1,conn);
cmd.ExecuteNonQuery();
//调用存储过程
SqlCommand cmd1=new SqlCommand("PRO_PLANALME",conn);
cmd1.CommandType = CommandType.StoredProcedure; 
cmd1.Parameters.Add("@aa",this.txtactid.Text.Trim());
cmd1.ExecuteNonQuery();
//
if(this.Page.IsValid)
{
 try
 {
  this.Response.Write("<script>alert(''''添加成功'''');</script>");
 }
 catch(Exception E)
 {
  this.Response.Write(E.ToString());
  this.Response.Write("<script>alert(''''添加不成功'''');</script>");
 }
 finally
 {
  conn.Close();
 }
}
else
{
 this.Response.Write("<script>alert(''''修改不成功'''');</script>");
}
 
private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
{//姓名(txtCName)
 try
 {
  int byteCount=System.Text.Encoding.Default.GetByteCount(this.txtCName.Text.Trim());
  if(byteCount>10)
  {
   args.IsValid=false;
   return;
  }
 }
 catch(Exception)
 {
 }
 args.IsValid=true;
}
//修改               

UPDATE ContList set CName=@CName WHERE (ContID=@ContID AND ActID=@ActID)"; 
SqlCommand cmd=new SqlCommand(sql,conn);
cmd.Parameters.Add(new SqlParameter("@ActID",SqlDbType.VarChar));
cmd.Parameters["@ActID"].Value="000004";
//序号
cmd.Parameters.Add(new SqlParameter("@ContID",SqlDbType.VarChar));
cmd.Parameters["@ContID"].Value=this.Request.Params["ContID"].ToString();
cmd.ExecuteNonQuery();

//删除
this.Response.Write("<script language=''''javascript''''>");
this.Response.Write("aa=window.confirm(''''您确定要删除联系人'''');");
this.Response.Write("if(aa==false){");
this.Response.Write("window.location.href=''''contlist.aspx''''");
this.Response.Write("}");
this.Response.Write("if(aa==true)");
this.Response.Write("{");
this.Response.Write("window.location.href=''''del_cont.aspx''''");
this.Response.Write(" } "); 
this.Response.Write("</script>");

string sql="";
sql="delete from ContList where ContID=''''"+this.Session["ContID"].ToString()+"'''' AND ActID=''''000004''''";
SqlCommand  cmd=new SqlCommand(sql,conn);
SqlCommand cmd1=new SqlCommand("PRO_PLANALMEVT_INTOPLANALMEVTGET",conn);
cmd1.CommandType = CommandType.StoredProcedure; 
cmd1.Parameters.Add("@ACTID","000004"); 
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
this.Response.Write("<script>alert(''''删除成功'''')</script>");       

this.Response.Write("<script>window.location.href=''''contlist.aspx''''</script>");

//打印

<style>
 BODY { SCROLLBAR-BASE-COLOR: #99ccff }
</style>
<style media="print">
.Noprint { DISPLAY: none }
UNKNOWN { PAGE-BREAK-AFTER: always }
</style>
<style>
.style_td { BORDER-RIGHT: #ffffff 0px solid; BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM:

#000000 1px solid }
.style_tab { BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #000000 2px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM:

#000000 1px solid }
.NOPRINT { FONT-SIZE: 9pt; FONT-FAMILY: "宋体" }
</style>

<TD align="center"><!--#include file="print.html" --><FONT face="宋体"></FONT></TD>

<center class="Noprint">
<p>
<OBJECT id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" width="0" VIEWASTEXT>
</OBJECT>
<input type="button" value="打印" onclick="document.all.WebBrowser.ExecWB(6,1)"> <input type="button" value="直接打印"

onclick="document.all.WebBrowser.ExecWB(6,6)">
<input type="button" value="页面设置" onclick="document.all.WebBrowser.ExecWB(8,1)">
<input type="button" value="打印预览" onclick="document.all.WebBrowser.ExecWB(7,1)">
</p>
</center>
//取得IP地址
string hostIP=System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].ToString();


上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口