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

📄 areafacility.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();
              Button6.Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')");

            }

        
      
    }

    public void bind()
    {

        bc.ExecDropDownList(DropDownList1, "select * from type where type = 'Area'", "Name", "code");
        string strsql = "select * from v_areafac "+sql+"order by ID desc";
       

      

     
        bc.ExecGridView(GridView1, strsql);//绑定数据
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {


           // ((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_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        this.bind();
    }
  
    
   //删除记录
    
    //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 = "delete from areaFacility where ID='" + id + "'";
    //    if (bcc.ExecSql(sqlstr))
    //    {
    //        Response.Write("<script>alert('删除信息成功!');</script>");
    //        this.bind();
    //    }
    //    else
    //    {
    //        Response.Write("<script>alert('操作失败!');</script>");
    //    }
    //}
    protected void Button1_Click(object sender, EventArgs e)
    {
        Hashtable htabel = new Hashtable(); 
        if (CheckBox1.Checked)
        {
            htabel.Add("unitName", TextBox1.Text);
           // Response.Write(htabel["unitName"].GetType().ToString());
          //  Response.End();

        }
        if (CheckBox2.Checked)
        {
            htabel.Add("mainHead", TextBox2.Text);

        }
        if (CheckBox3.Checked)
        {
            htabel.Add("contactPerson", TextBox3.Text);
        }
        if (CheckBox4.Checked)
        {
            htabel.Add("tel", TextBox4.Text);
        }
        if (CheckBox5.Checked)
        {
            htabel.Add("typeID", Convert.ToInt32(DropDownList1.SelectedValue));
        }
        if (CheckBox6.Checked)
        {
            sql = stroper.GetConditionClause(htabel,true);
        }
        else
        {
            sql = stroper.GetConditionClause(htabel,false);
        }
        
        //Response.Write(sql);
       //Response.End();
        this.bind();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        sql = "";
        this.bind();
    }
    //全选
    protected void Button3_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
            chkSelect.Checked = true;
        }

    }
    //反选
    protected void Button4_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
            chkSelect.Checked = !chkSelect.Checked;
        }
    }
   //取消
    protected void Button5_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
            chkSelect.Checked = false;
        }
    }
    //删除
    protected void Button6_Click(object sender, EventArgs e)
    {
        ArrayList sqltrans = new ArrayList();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox chkSelect = (CheckBox)GridView1.Rows[i].FindControl("chkSelect");
            if (chkSelect.Checked)
            {
                string str = ((Label)GridView1.Rows[i].FindControl("labID")).Text;
                string sqlstr = "delete from areafacility where ID=" + str;
               
                sqltrans.Add(sqlstr);
            }
          

        }
        //foreach (string item in sqltrans)
        //{
        //    Response.Write(item + "</br>");

        //}
        //Response.End();
        if (bc.ExecSQLTrans(sqltrans))
        {
            Response.Write("<script>alert('删除信息成功!');</script>");
            this.bind();
        }
        else
        {
            Response.Write("<script>alert('操作失败!');</script>");
            return;
        }
    }
}

⌨️ 快捷键说明

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