using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;using System.Text;
using System.IO;
using System.Data; public partial class DownloadItem_CmdExeItem : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
Btn_Commit_BCF.Attributes.Add("OnClick", "javascript:return confirm('您确定提交吗?!');"); } }
protected void Btn_search_BCF_Click(object sender, EventArgs e)
{
InitData();
rpt_BCF_DataBinds();
TotalControls = Rpt_BCF.Items.Count;
for (int i = ; i < TotalControls; i++)
{
(Rpt_BCF.Items[i].FindControl("DropDownList1") as DropDownList).Enabled = false; }
}
protected void Rpt_BCF_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
(e.Item.FindControl("DropDownList1") as DropDownList).SelectedValue = DDL_Seach_City.SelectedItem.Value;
}
}
protected void Btn_addline_BCF_Click(object sender, EventArgs e)
{
DataTable dt = CopyFormData();
Random rd_year = new Random(), rd_month = new Random(), rd_date = new Random();
string datestr = rd_year.Next(, ).ToString("d4") + "/" + rd_month.Next(, ).ToString("d2") + "/" + rd_date.Next(, ).ToString("d2");
DataRow dr = dt.NewRow(); dr["HIDUKE"] = datestr;//DateTime.Now.Date.ToString();
dr["PV_CNT"] = -;
dr["CL_CNT"] = -;
dt.Rows.Add(dr); ViewState.Add("Data", dt); rpt_BCF_DataBinds();
for (int i = ; i < TotalControls; i++)
{
(Rpt_BCF.Items[i].FindControl("DropDownList1") as DropDownList).Enabled = false;
(Rpt_BCF.Items[i].FindControl("TextBox2") as TextBox).Enabled = false;
(Rpt_BCF.Items[i].FindControl("Btn_repcld") as Button).Enabled = false; } Btn_search_BCF.Enabled = false; }
private void Phl_table_addline(int num)
{
//for (int i = 0; i < num; i++)
//{
TableRow tr;
TableCell tc;
DropDownList ddl_citydynamic;
ListItem li;
Calendar cld;
TextBox Tbox_date, Tbox_pvno, Tbox_clno;
Button Btn_chosedate;
//if(IsPostBack)
//{ tr = new TableRow(); tc = new TableCell();
ddl_citydynamic = new DropDownList();
li = new ListItem("请xx", "-1");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
li = new ListItem("xxx", "");
ddl_citydynamic.Items.Add(li);
tc.Controls.Add(ddl_citydynamic);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_date = new TextBox();
Btn_chosedate = new Button();
Btn_chosedate.Text = "▼";
tc.Controls.Add(Tbox_date);
tc.Controls.Add(Btn_chosedate);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_pvno = new TextBox();
tc.Controls.Add(Tbox_pvno);
tr.Cells.Add(tc); tc = new TableCell();
Tbox_clno = new TextBox();
tc.Controls.Add(Tbox_clno);
tr.Cells.Add(tc); tc = new TableCell();
tr.Cells.Add(tc); //tbl_BCF.Rows.Add(tr);
//} }
protected int CurrentItem
{
get
{
return ViewState["CurrentItem"] == null ? : (int)(ViewState["CurrentItem"]);
}
set
{
ViewState["CurrentItem"] = value;
}
}
protected int TotalControls
{
get
{
return ViewState["TotControls"] == null ? : (int)(ViewState["TotControls"]);
}
set
{
ViewState["TotControls"] = value;
}
}
protected void rpt_BCF_DataBinds()
{
Rpt_BCF.DataSource = ViewState["Data"] as DataTable;
Rpt_BCF.DataBind();
}
protected DataTable CopyFormData()
{
DataTable dt = (ViewState["Data"] as DataTable).Clone(); foreach (RepeaterItem ri in Rpt_BCF.Items)
{
DataRow dr = dt.NewRow(); dr["xxx"] = (ri.FindControl("TextBox1") as TextBox).Text; dt.Rows.Add(dr);
} return dt;
} protected void InitData()
{
DateTime time = DateTime.Now; DataTable dt = new DataTable(); StringBuilder sb = new StringBuilder();
sb.Append("select xxx,xxx,xxx,xxx from 00 where "); if (DDL_Seach_City.SelectedItem.Text != "请选择")
sb.Append("xxx='" + DDL_Seach_City.SelectedItem.Text + "' and ");
if (TBox_Datebegin.Text.Length == && TBox_Dateend.Text.Length == )
sb.Append("xxx>='" + TBox_Datebegin.Text + "' and xxx<='" + TBox_Dateend.Text + "' and ");
else if (TBox_Datebegin.Text.Length == )
sb.Append("xxx='" + TBox_Datebegin.Text + "' and "); if (sb.Length <= )
{ }
else
{ string sqlstr = sb.ToString().Substring(, sb.Length - );
BCF bcfr = new BCF();
dt = bcfr.search_BCF(sqlstr);
} ViewState.Add("Data", dt);
}
protected void Btn_repcld_Click(object sender, EventArgs e)
{
RepeaterItem rptItem = ((Button)sender).Parent as RepeaterItem;
CurrentItem = rptItem.ItemIndex;
Div_Cld_common.Style["Display"] = "Block";
}
protected void Cld_common_SelectionChanged(object sender, EventArgs e)
{
(Rpt_BCF.Items[CurrentItem].FindControl("TextBox2") as TextBox).Text = Cld_common.SelectedDate.ToShortDateString();
Div_Cld_common.Style["Display"] = "None";
}
}
前台:
<div class="new_area_BCF">
<table style="width: 900px; text-align: center; align-self: center;">
<tr>
<td class="auto-style1">
<asp:Label ID="Label1" runat="server" Text="城市"></asp:Label><asp:DropDownList ID="DDL_Seach_City" runat="server">
<asp:ListItem Text="请选择" Value="-1"></asp:ListItem>
<asp:ListItem Text="xx" Value="1"></asp:ListItem>
<asp:ListItem Text="xx" Value="2"></asp:ListItem>
<asp:ListItem Text="xx" Value="3"></asp:ListItem>
<asp:ListItem Text="xx" Value="4"></asp:ListItem>
<asp:ListItem Text="xx" Value="5"></asp:ListItem>
</asp:DropDownList></td> <td style="text-align: right;" class="auto-style1">
<asp:Label ID="Label2" runat="server" Text="日期"></asp:Label>
<asp:TextBox ID="TBox_Datebegin" runat="server"></asp:TextBox>
<asp:Button ID="Btn_Datebegin" runat="server" Text="▼" OnClick="Btn_Datebegin_Click" />~
</td>
<td style="text-align: left;" class="auto-style1">
<asp:TextBox ID="TBox_Dateend" runat="server"></asp:TextBox>
<asp:Button ID="Btn_Dateend" runat="server" Text="▼" OnClick="Btn_Dateend_Click" />
</td>
<td class="auto-style1">
<asp:Button ID="Btn_search_BCF" runat="server" Text="检索" OnClick="Btn_search_BCF_Click" /><asp:Button ID="Btn_addline_BCF" OnClick="Btn_addline_BCF_Click" runat="server" Text="+" />
</td>
<td class="auto-style1"></td>
</tr>
<tr>
<td></td>
<td style="text-align: right;">
<asp:Calendar ID="Cld_begin" Visible="false" runat="server" OnSelectionChanged="Cld_begin_SelectionChanged"></asp:Calendar>
</td>
<td style="text-align: left;">
<asp:Calendar ID="Cld_end" Visible="false" runat="server" OnSelectionChanged="Cld_end_SelectionChanged"></asp:Calendar>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="5">
<asp:Repeater ID="Rpt_BCF" runat="server" OnItemDataBound="Rpt_BCF_ItemDataBound">
<HeaderTemplate>
<table class="Rpt_table_BCF">
<tr>
<th>xx</th>
<th>xx</th>
<th>xx</th>
<th>xx</th>
<th></th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="tr_white_BCF">
<td>
<asp:DropDownList ID="DropDownList1" runat="server" OnDataBinding="DropDownList1_DataBinding">
<asp:ListItem Text="请选择" Value="-1"></asp:ListItem>
<asp:ListItem Text="xxx" Value="1"></asp:ListItem>
<asp:ListItem Text="xxx" Value="2"></asp:ListItem>
<asp:ListItem Text="xxx" Value="3"></asp:ListItem>
<asp:ListItem Text="xxx" Value="4"></asp:ListItem>
<asp:ListItem Text="xxx" Value="5"></asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" Text='<%#Eval("xxx")%>' Visible="false" runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox2" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox><asp:Button ID="Btn_repcld" OnClick="Btn_repcld_Click" runat="server" Text="▼" /></td>
<td>
<asp:TextBox ID="TextBox3" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox4" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td></td>
</tr>
</ItemTemplate>
<%--<AlternatingItemTemplate>
<tr class="tr_black_BCF">
<td><%#Eval("xxx")%></td>
<td><%#Eval("xxx")%></td>
<td>
<asp:TextBox ID="TextBox1" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
<asp:TextBox ID="TextBox2" Text='<%#Eval("xxx")%>' runat="server"></asp:TextBox></td>
<td>
</td>
</tr>
</AlternatingItemTemplate>--%>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<div id="Div_Cld_common" runat="server">
<asp:Calendar ID="Cld_common" runat="server" OnSelectionChanged="Cld_common_SelectionChanged"></asp:Calendar>
</div>
</td> </tr>
<tr>
<td colspan="5" style="text-align: right;">
<asp:Button ID="Btn_Commit_BCF" runat="server" Text="提交" OnClick="Btn_Commit_BCF_Click" /></td> </tr>
<tr><td><p>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</p></td></tr>
</table>
</div>