⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pavilion.aspx.cs

📁 物业管理系统
💻 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.Collections;

public partial class admin_areafacility : System.Web.UI.Page
{
    public static string sql = "";
    BaseClass bc = new BaseClass();
    stringoperator stroper = new stringoperator();
   
   protected void Page_Load(object sender, EventArgs e)
    {
        
            if (Convert.ToString(Session["UID"]) == "")
            {
                Response.Redirect("login.aspx");

            }
           if(!IsPostBack)
           {
               this.bind();
           }
                

            

  }

    public void bind()
    {
        BaseClass bc = new BaseClass();

        string strsql = "select * from pavilion " + sql + "order by paID desc";
 


        bc.ExecGridView(GridView1, strsql);//绑定数据
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //e.Row.Cells[5].Text = (Convert.ToDateTime(e.Row.Cells[4].Text)).ToShortDateString();
            ((LinkButton)(e.Row.Cells[6].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_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
        //Response.Write(id);
        //Response.End();

        BaseClass bcc = new BaseClass();
        string sqlstr = "select count(*) from room where paID=" + id + "";
        int count = (int)bc.ExecCscalar(sqlstr);
        if (count > 0)
        {
            Response.Write("<script>alert('楼宇内有住户,请先删除房间!');location='room.aspx';</script>");
            return;
        }
       
        
        sqlstr = "delete from pavilion where paID=" + id + "";



        //Response.Write(sqlstr);
        //Response.End();



        if (bcc.ExecSql(sqlstr))
        {
            Response.Write("<script>alert('删除信息成功!');</script>");
            this.bind();
        }
        else
        {
            Response.Write("<script>alert('操作失败!');</script>");
            Response.Write("<script>alert('提示:该桩楼可能有住户,请先删除用户!');</script>");
        }
    }

    //编辑
    //protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    //{

    //    string id = this.GridView1.DataKeys[e.NewEditIndex].Value.ToString();
    //    Response.Write("<script>window.open('editpavilion.aspx?paID=" + id + "','','width=450,height=450')</script>");
    //    Response.Write("<script>location='javascript:history.go(-1)'</script>");

    //}

    //分页
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {


        this.GridView1.PageIndex = e.NewPageIndex;
        this.GridView1.DataBind();
       
    
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Hashtable htabel = new Hashtable();
        if (CheckBox1.Checked)
        {
            htabel.Add("Name", TextBox1.Text);
            // Response.Write(htabel["unitName"].GetType().ToString());
            //  Response.End();

        }
        //层数
        
        if (CheckBox2.Checked)
        {
            if (TextBox2.Text == "")
            {
                htabel.Add("layer", 0);
            }
            else
            {
                htabel.Add("layer", Convert.ToInt32(TextBox2.Text));
            }
           

        }
       //高度
        if (CheckBox3.Checked)
        {
            if (TextBox3.Text == "")
            {
                htabel.Add("high", 0);
            }
            else
            {
                htabel.Add("high", Convert.ToInt32(TextBox3.Text));
            }
        }
        //面积
        if (CheckBox4.Checked)
        {
            if (TextBox4.Text == "")//如果面积为空,则默认为0
            {
                htabel.Add("area", 0);
            }
            else
            {
                htabel.Add("area", Convert.ToInt32(TextBox4.Text));
            }
        }
       
        if (CheckBox6.Checked)
        {
            sql = stroper.GetConditionClause(htabel, true);
        }
        else
        {
            sql = stroper.GetConditionClause(htabel, false);
        }
        if (CheckBox5.Checked)
        {
            if (htabel.Count > 0)
            {
                sql = sql + " and buildDate between '" + TextBox5.Text + "' and '" + TextBox6.Text + "'";
            }
            else
            {
                sql = " where buildDate between '" + TextBox5.Text + "' and '" + TextBox6.Text + "'";
            }

        }
        

        // Response.Write(sql);
      //  Response.End();
        this.bind();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        sql = "";
        this.bind();
    }
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -