📄 homechargefee.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class admin_areafacility : System.Web.UI.Page
{
public static string sql = "";
BaseClass bc = new BaseClass();
protected void Page_Load(object sender, EventArgs e)
{
if (Convert.ToString(Session["UID"]) == "")
{
Response.Redirect("login.aspx");
}
if (!IsPostBack)
{
bc.ExecDropDownList(ddlPavilion, "select * from pavilion", "Name", "paID");//楼宇
bc.ExecDropDownList(ddlCell, "select * from type where type='DY'", "name", "code");//单元
this.bind();
}
}
public void bind()
{
string strsql = "select * from v_homefee "+sql+" order by ID desc";//视图中查询
bc.ExecGridView(GridView1, strsql);//绑定数据
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = e.Row.Cells[6].Text.ToString();
int not = Convert.ToInt32(id);
if (not == 0)
{
e.Row.Cells[6].Text = "<font color=red>已结款</font>";
((Button)(e.Row.Cells[10].Controls[0])).Enabled = false;
((LinkButton)(e.Row.Cells[8].Controls[0])).Enabled = false;
}
else
{
e.Row.Cells[6].Text = id;
}
e.Row.Cells[3].Text = Convert.ToDateTime(e.Row.Cells[3].Text).ToShortDateString();
((LinkButton)(e.Row.Cells[9].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#99ccff';this.Style.color='buttontext';this.Style.cursor='default';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';this.style.color='';");
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.GridView1.PageIndex = e.NewPageIndex;
this.bind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string ownerid = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
//Response.Write(id);
//Response.End();
BaseClass bcc = new BaseClass();
string sqlstr = "delete from homeChargeFee where ID='" + ownerid + "'";
if (bcc.ExecSql(sqlstr))
{
Response.Write("<script>alert('删除信息成功!');</script>");
this.bind();
}
else
{
Response.Write("<script>alert('操作失败!');</script>");
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
string id = this.GridView1.DataKeys[e.NewEditIndex].Value.ToString();
Response.Redirect("edithomechargefee.aspx?ID=" + id);
// Response.Write("<script>window.open('edithomechargefee.aspx?ID=" + id + "','','width=450,height=450')</script>");
// Response.Write("<script>location='javascript:history.go(-1)'</script>");
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
Response.Write("<script>window.open('open.aspx?id=" + id + "','','width=380,height=200,scrollbars=no')</script>");
}
protected void ddlPavilion_SelectedIndexChanged(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
sql = " where left(code," + pavID.Length + ")='" + pavID + "'";
this.bind();
}
//选择单元后执行
protected void ddlCell_SelectedIndexChanged(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
string cellID = ddlCell.SelectedItem.Value;
string left = pavID + cellID;
int leftlenth = left.Length;
sql = " where left(code," + leftlenth + ")='" + left + "'";
this.bind();
}
//根据楼宇+单元+层数=查找
protected void Button2_Click(object sender, EventArgs e)
{
string pavID = ddlPavilion.SelectedItem.Value;
string cellID = ddlCell.SelectedItem.Value;
string left = pavID + cellID;
int leftlenth = left.Length;
string floor;
int num = Convert.ToInt32(TextBox1.Text);
if (num < 10)
{
floor = "0" + num.ToString();
}
else
{
floor = num.ToString();
}
sql = " where left(code," + leftlenth + ")='" + left + "' and substring(code," + (leftlenth + 1) + "," + floor.Length + ")='" + floor + "'";
this.bind();
}
protected void Button3_Click(object sender, EventArgs e)
{
sql = "";
this.bind();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -