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

📄 bigcustomers.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;

public partial class CustomersMag_BigCustomers : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["flag"] == null)
        {
            Response.Write("<script language=JavaScript>{window.alert('网络超时或你还未登录,请重新登陆!');window.location.href='admin_login.aspx';}</script>");
        }// 在此处放置用户代码以初始化页面
       

        if (!IsPostBack)
        {



            this.searchbind();

        }
    }


    public void PagerButtonClick(Object sender, EventArgs e)
    {

        String CommandArgument = ((LinkButton)sender).CommandArgument;

        switch (CommandArgument)
        {
            case ("Next"):
                if (GridView2.PageIndex < (GridView2.PageCount - 1))
                    GridView2.PageIndex++;
                break;
            case ("前一项"):
                if (GridView2.PageIndex > 0)
                    GridView2.PageIndex--;
                break;
            case ("最后一项"):
                GridView2.PageIndex = (GridView2.PageCount - 1);
                break;
            case ("X"):
                GridView2.PageIndex = (Convert.ToInt32(No.Text) - 1);
                break;
            default:

                GridView2.PageIndex = Convert.ToInt32(CommandArgument);
                break;
        }
        this.searchbind();

    }

    void Number()
    {
        lblCurrentIndex.Text = (GridView2.PageIndex + 1).ToString();
        lblPageCount.Text = GridView2.PageCount.ToString();
    }



    string getsql()
    {
        string sql = "select * from BigCustoms where ";
        string lei = this.DrDpSeaLei.SelectedValue.ToString().Trim();


        if (lei == "bigctid")
        {
            sql += "BigCustoms.BigCustomsId";
        }
        if (lei == "bigctBigCustomsname")
        {
            sql += "BigCustoms.BigCustomsName";
        }
        if (lei == "bigctmanager")
        {
            sql += "BigCustoms.BigCustomsManager";
        }

        if (lei == "bigctphone")
        {
            sql += "BigCustoms.BigCustomsPhone";
        }
        if (lei == "bigctaddress")
        {
            sql += "BigCustoms.BigCustomsAddress";
        }
        sql += " like '%" + this.TbSeaDetail.Text.ToString().Trim() + "%'";

        if (lei == "all")
        {
            sql = "DefaultSearch";
        }


        return sql;

    }

    void searchbind()
    {

        string SearchZt = getsql();
        if (SearchZt == "DefaultSearch")
        {
            string defaultsql = "select * from  BigCustoms";
            this.GridView2.DataSource = DataBindingtest.DataBindsear(defaultsql);
            this.label1.Text = DataBindingtest.DataBindsear(defaultsql).Count.ToString();


            this.GridView2.DataBind();




        }
        else
        {
            this.GridView2.DataSource = DataBindingtest.DataBindsear(SearchZt);
            this.label1.Text = DataBindingtest.DataBindsear(SearchZt).Count.ToString();
            this.GridView2.DataBind();
        }
        this.Number();
    }


    protected void BtSearch_Click(object sender, System.EventArgs e)
    {
        this.GridView2.PageIndex = 0;


        this.searchbind();

        this.Number();


    }








    protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView2.EditIndex = e.NewEditIndex;

        this.searchbind();
    }
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

        string sql = "delete from BigCustoms where BigCustomsId=" + GridView2.DataKeys[(int)e.RowIndex].Value.ToString();



        string res = DataBindingtest.operate(sql);

        if (res == "ok")
        {
            Response.Write("<script>alert('删除成功!')</script>");
            GridView2.EditIndex = -1;
        }
        else
        {
            Response.Write(res);

        }
        this.searchbind();

    }
    protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        DropDownList BigCustomsmag = (DropDownList)GridView2.FindControl("DropDownList1");


        string sql = "update BigCustoms set BigCustoms.BigCustomsName='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "',BigCustoms.BigCustomsManager='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim() + "',BigCustoms.BigCustomsPhone='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',BigCustoms.BigCustomsAddress='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + "',BigCustoms.BigCustomsMoreInfo='" + ((TextBox)(GridView2.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + "' where BigCustoms.BigCustomsId='" + GridView2.DataKeys[e.RowIndex].Value.ToString() + "'";

        string res = DataBindingtest.operate(sql);

        if (res == "ok")
        {
            Response.Write("<script>alert('编辑成功!')</script>");
            GridView2.EditIndex = -1;
        }
        else
        {
            Response.Write(res);

        }

        this.searchbind();

    }

    protected void GridView2_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView2.EditIndex = -1;

        this.searchbind();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        
        string BigCustomsname = this.TextBox2.Text.ToString().Trim();
        string BigCustomsMag = this.TextBox3.Text.ToString().Trim();
        string BigCustomsphone = this.TextBox4.Text.ToString().Trim();
        string BigCustomsaddress = this.TextBox5.Text.ToString().Trim();
        string BigCustomsmoreinfo = this.TextBox6.Text.ToString().Trim();
        string sql = "insert into [BigCustoms]([BigCustomsName],[BigCustomsManager],[BigCustomsPhone],[BigCustomsAddress],[BigCustomsMoreInfo]) values ('" + BigCustomsname + "','" + BigCustomsMag + "','" + BigCustomsphone + "','" + BigCustomsaddress + "','" + BigCustomsmoreinfo + "')";
        string res = DataBindingtest.operate(sql);
        if (res == "ok")
        {
            Response.Write("<script>alert('添加成功!')</script>");

        }
        else
        {
            Response.Write(res);
        }

        this.searchbind();
    }


    protected void GridView2_PageIndexChanged(object sender, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {

        this.GridView2.PageIndex = 0;

        this.GridView2.PageIndex = e.NewPageIndex;

        this.searchbind();
    }
}

⌨️ 快捷键说明

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