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

📄 supplylist.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 SupplyMag_SupplyList : 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='../Login.aspx';}</script>");
   }// 在此处放置用户代码以初始化页面
        if (!Page.IsPostBack)
        {


   
            this.searchbind();

        }
    }


    public void PagerButtonClick(Object sender, EventArgs e)
    {

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

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

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

    }

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

 

    string getsql()
    {
        string sql = "select * FROM ProducesKind ,Produces, SupplyList , Cklist, SupplyCompany , WorkersList where  ";
        string lei = this.DrDpSeaLei.SelectedValue.ToString().Trim();


        if (lei == "listid")
        {
            sql += "Supplylist.listid";
        }
		  if (lei == "Produceskind")
        {
            sql += "Produceskind.Produceskinds";
        }
		
        if (lei == "Producesname")
        {
            sql += "Produces.ProducesName";
        }
        if (lei == "rukutime")
        {
            sql += "Supplylist.ListDateTime";
        }

        if (lei == "workerid")
        {
            sql += "WorkersList.WorkerName";
        }
        if (lei == "supplycompany")
        {
            sql += "SupplyCompany.SupplyCompanyName";
		}
      

        sql += " like '%" + this.TbSeaDetail.Text.ToString().Trim() + "%' and Produces.ProducesKindId=ProducesKind.ProducesKindId and cklist.ckid=supplylist.ckid and workerslist.workerslistid=supplylist.workerslistid and supplylist.producesid=produces.producesid and supplycompany.supplyid=supplylist.supplyid";

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


        return sql;

    }

    void searchbind()
    {

        string SearchZt = getsql();
        if (SearchZt == "DefaultSearch")
        {
            string defaultsql = "SELECT * FROM ProducesKind ,Produces, SupplyList , Cklist, SupplyCompany , WorkersList where Produces.ProducesKindId=ProducesKind.ProducesKindId and cklist.ckid=supplylist.ckid and workerslist.workerslistid=supplylist.workerslistid and supplylist.producesid=produces.producesid and supplycompany.supplyid=supplylist.supplyid";
            this.GridView1.DataSource = DataBindingtest.DataBindsear(defaultsql);
            this.label1.Text = DataBindingtest.DataBindsear(defaultsql).Count.ToString();
      this.GridView1.DataBind();

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


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


        this.searchbind();

        this.Number();


    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string ckid = this.DropDownList1.SelectedValue.ToString();
        string supplycom = this.DropDownList2.SelectedValue.ToString();
        string producesid = this.DropDownList3.SelectedValue.ToString();
        string num = this.TextBox1.Text.ToString();
        string time = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

        string price = DataBindingtest.jinjia(producesid);
      

        string shouldfu =Convert.ToString(Convert.ToDouble(price)*Convert.ToInt32(num));
    
        string handlemag = this.DropDownList4.SelectedValue.ToString();
        string moreinfo = this.TextBox4.Text.ToString();

        string sql = "INSERT INTO [SupplyList] ([CkId], [SupplyId], [ProducesId], [NeedNum], [ListDateTime], [AffordMoney],[WorkersListId], [ListMoreInfo]) VALUES ('"+ckid+"','"+supplycom+"','"+producesid+"','"+num+"','"+time+"','"+shouldfu.Trim()+"','"+handlemag+"','"+moreinfo+"')";

       string res = DataBindingtest.operate(sql);
        if (res == "ok")
        {
            Response.Write("<script>alert('添加成功!')</script>");

        }
        else
        {
            Response.Write(res);
        }

        this.searchbind();
       
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;

        this.searchbind();
    }


   
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

        DropDownList ckname= (DropDownList)GridView1.Rows[GridView1.EditIndex].FindControl("Dpdckname");


        string sql = "UPDATE [SupplyList]  SET [CkId]='" +ckname.SelectedValue.ToString() + "',[ListMoreInfo]='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[9].Controls[0])).Text.ToString().Trim() + "' WHERE [ListId] = '" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "'";

        string res = DataBindingtest.operate(sql);

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

        }

        this.searchbind();

    }

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


        this.searchbind();
    }
    protected void GridView1_PageIndexChanged(object sender, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
    {

        this.GridView1.PageIndex = 0;

        this.GridView1.PageIndex = e.NewPageIndex;

        this.searchbind();
    }

   
}

⌨️ 快捷键说明

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