62,071
社区成员
发帖
与我相关
我的任务
分享
protected void gvNewsList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:" + e.Row.Cells[0].Text.Trim() + "第" + e.Row.Cells[1].Text.Trim() + "年,第" + e.Row.Cells[2].Text.Trim() + "个季度的上报信息吗?')");
//第5列加上一个弹出模态窗口showModalDialog('left.aspx?type={0}',window,'dialogHeight:330px; dialogWidth: 500px;dialogTop:px; dialogLeft:px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No','alwaysRaised= yes')
((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "javascript:return showModalDialog('bfzxcopy.aspx?sbji=" + e.Row.Cells[2].Text.Trim() + "&sbyear=" + e.Row.Cells[1].Text.Trim() + "',window,'dialogHeight:330px; dialogWidth: 500px;dialogTop:px; dialogLeft:px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:No','alwaysRaised= yes') ");
}
}
}
Page.RegisterStartScript("<script>alert('提示框');</script>");
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="bfzxcopy.aspx.cs" Inherits="Manage_bfzxcopy" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>将指定季度copy为新的季度:</title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
width: 24px;
}
</style>
<base target ="_self" />
</head>
<body>
<form id="form1" runat="server" action="">
<div>
<table class="style1">
<tr>
<td class="style2">
</td>
<td>
您确定想将:<asp:Label ID="Label1" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
,<asp:Label ID="Label2" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
年,第<asp:Label ID="Label3" runat="server" Text="Label"
style="color: #0000FF; font-weight: 700"></asp:Label>
季度的数据复制到下述季度吗?</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="DropDownList1" ErrorMessage="请选择年度" InitialValue="请选择年度"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="DropDownList2" ErrorMessage="请选择季度" InitialValue="请选择季度"></asp:RequiredFieldValidator>
<br />
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="确定" onclick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="取消" onclick="Button2_Click" />
</td>
</tr>
<tr>
<td class="style2">
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Manage_bfzxcopy : System.Web.UI.Page
{
//modify by wll 2012 3.13
CommonClass CC = new CommonClass();
protected void Page_Load(object sender, EventArgs e)
{
//if (!IsPostBack)
//{
if (Session["nameyh"] == null && Session["pwdyh"] == null) //
{
Response.Redirect("Login.aspx"); //将页面重新定向到登录页面中
}
//}
Label1.Text = Session["nameyh"].ToString();
Label2.Text = Request.QueryString["sbyear"].ToString();
Label3.Text = Request.QueryString["sbji"].ToString();
//====2
DateTime tnow = DateTime.Now;//现在时间
ArrayList AlYear, yesYear;
AlYear = new ArrayList();
yesYear = new ArrayList();
int j;
for (j = 2011; j <= 2016; j++)
AlYear.Add(j);
//====3 季度是 1 2 3 4共计四个季度
ArrayList AlMonth;
AlMonth = new ArrayList();
for (j = 1; j <= 4; j++)
AlMonth.Add(j);
//====4
DropDownList1.DataSource = AlYear;
DropDownList1.DataBind();//DropDownList1绑定年
//DropDownList1选择当前年
DropDownList1.SelectedValue = tnow.Year.ToString();
DropDownList1.Items.Insert(0, new ListItem("请选择年度", "请选择年度"));
DropDownList2.DataSource = AlMonth;
DropDownList2.DataBind();//DropDownList2绑定季
DropDownList2.Items.Insert(0, new ListItem("请选择季度", "请选择季度"));
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write(" <script >window.close(); </script > ");
}
protected void Button1_Click(object sender, EventArgs e)
{
string str_sbdwname = this.Label1.Text.Trim(); //单位名称
string str_sbyear = this.DropDownList1.SelectedValue.ToString().Trim(); //年
string str_sbji = this.DropDownList2.SelectedValue.ToString().Trim(); //季
string SqlStr = "select * from tb_sb where sbdwname='" + str_sbdwname + "' and sbyear='" + str_sbyear + "' and sbji='" + str_sbji + "'";
Response.Write(""+ SqlStr +"");
SqlConnection con = CC.GetConnection();
con.Open();//打开数据库连接
SqlCommand amd = new SqlCommand(SqlStr, con);
SqlDataReader dr = amd.ExecuteReader();
if (dr.Read()) //如果有数据,则显示 此数据已有!
{
//yesYear.Add(dr["sbyear"].ToString());//
//Response.Write(CC.MessageBox("" + dr["sbyear"].ToString() + ""));
//sDescription.InnerHtml = "注意," + dr["sbyear"].ToString() + "年,第" + dr["sbji"].ToString() + "季度的数据您已上报!请选择别的年度和季度。";
Response.Write(CC.MessageBox("恭喜!页。"));
}
else
{
//sDescription.InnerHtml = "";
Response.Write(CC.MessageBox("恭喜!" + str_sbji + "2页。"));
Response.Write(""+ str_sbji+"");
}
dr.Close();
con.Close();
}
}
遮罩层样式
.black_overlay
{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color:Gray;
z-index: 1001;
-moz-opacity: 0.6;
opacity: .80;
filter: alpha(opacity=50);
}
<script language="javascript" type="text/javascript">
function ShowDiv() {
G('showDiv').style.display = 'block';
G('fade').style.display = 'block';
G('fade').style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + 'px';
}
function CloseDiv() {
G('showDiv').style.display = 'none';
G('fade').style.display = 'none'
}
function CheckForm() {
if (G("txtDepName").value.replace(/\s/g, "") == "") {
alert("名称不能为空!");
G("txtDepName").focus();
return false;
}
return true;
}
</script>
+++++++++++++++++++++++++++++++
<a href="javascript:ShowDiv();"><img src="../images/add.gif" border="0" />添加部门</a>
遮罩层
<div id="fade" class="black_overlay"></div>
弹出层
<div id="showDiv" style="width: 500px; display:none">
<table width="500px" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4">
<p class="title2">
<span>部门信息</span><img src="../images/close.jpg" onclick="CloseDiv();" alt="关闭" width="14"
height="14" /></p>
</td>
</tr>
<tr>
<td align="right">
<font color='red'>*</font>名称:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtDepName"></asp:TextBox>
</td>
<td align="right">
上级单位
</td>
<td align="left">
<asp:DropDownList runat="server" ID="dlDep" DataTextField="DepName" DataValueField="DepID">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right">
简称:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtJC"></asp:TextBox>
</td>
<td align="right">
排序号:
</td>
<td align="left">
<asp:TextBox runat="server" ID="txtPX" Width="50px" onKeyPress="OnlyDouble(this.value);"
Text="0"> </asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
禁用:
</td>
<td align="left">
<asp:CheckBox runat="server" ID="chkIsNotUse" Text=""></asp:CheckBox>
</td>
</tr>
<tr>
<td align="center" colspan="4">
<p class="WBbg">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="imgSave_Click" OnClientClick="return CheckForm();">
<img src="../images/save.gif" border="0" onclick="return CheckForm();"/>保存</asp:LinkButton>
</p>
</td>
</tr>
</table>
</div>