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

📄 load.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.Data.SqlClient;

public partial class load : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
         if(Session["name"]==null)
         {

             Response.Redirect("blank.htm");
        }
        if (!IsPostBack)
        {
            cooktb leibie = new cooktb();
            DataSet ds = leibie.leibie();
            dropleibie.DataSource = ds;
            dropleibie.DataTextField = "leibie_name";
            dropleibie.DataBind();
            dropleibie.Items.Insert(0, new ListItem("请选择", "请选择"));
            droppinmin.Items.Insert(0, new ListItem("请选择", "请选择"));
            ds.Dispose();
            try
            {
                cooktb data = new cooktb();
                DataSet dsdata = data.loaddata(this.droppinmin.SelectedItem.Text);
                this.dlinfo.DataSource = dsdata;
                this.dlinfo.DataBind();
                dsdata.Dispose();
            }
            catch (Exception ex)
            { 
            }
          
        }
        loaddata bind = new loaddata();
        DataSet dsload = bind.getload(Session["name"].ToString());
        gdvwdata.DataSource = dsload.Tables[0].DefaultView;
        gdvwdata.DataBind();
    }
    protected void dropleibie_SelectedIndexChanged(object sender, EventArgs e)
    {
       
        cooktb pinmin = new cooktb();
        DataSet ds = pinmin.pinmin(this.dropleibie.SelectedItem.Text);
        droppinmin.DataSource = ds;
        droppinmin.DataTextField = "order_PM";
        droppinmin.DataBind();
           ds.Dispose();

        cooktb data = new cooktb();
        DataSet dsdata = data.loaddata(this.droppinmin.SelectedItem.Text);
        this.dlinfo.DataSource = dsdata;
        this.dlinfo.DataBind();
        dsdata.Dispose();

        cooktb guige = new cooktb();
        string GG = guige.GG(this.droppinmin.SelectedItem.Text);
        this.txtGG.Text = GG;
     
      
    }
    protected void droppinmin_SelectedIndexChanged(object sender, EventArgs e)
    {
        cooktb guige = new cooktb();
        string GG = guige.GG(this.droppinmin.SelectedItem.Text);
        this.txtGG.Text = GG;

        cooktb data = new cooktb();
        DataSet dsdata = data.loaddata(this.droppinmin.SelectedItem.Text);
        this.dlinfo.DataSource = dsdata;
        this.dlinfo.DataBind();
        dsdata.Dispose();

        
    }
    protected void txtsuoxie_TextChanged(object sender, EventArgs e)
    {
         this.droppinmin.Items.Clear();
        cooktb search = new cooktb();
        SqlDataReader dr = search.search(this.txtsuoxie.Text, this.dropleibie.SelectedItem.Text);
        while (dr.Read())
        {
            droppinmin.Items.Add(dr.GetValue(0).ToString());
        }
        try
        {
            if (this.droppinmin.SelectedItem.Text == "")
            {
                this.txtGG.Text = "";
            }
            else
            {
                cooktb gg = new cooktb();
                string strGG = gg.GG(this.droppinmin.SelectedItem.Text);
                this.txtGG.Text = strGG;
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void imgadd_Click(object sender, ImageClickEventArgs e)
    {
        if (this.droppinmin.SelectedItem.Text != "" && this.txtGG.Text != "")
        {
            loaddata insert = new loaddata();
            insert.insert(this.dropleibie.SelectedItem.Text, this.droppinmin.SelectedItem.Text, this.txtGG.Text, getadd(), Session["name"].ToString());

            loaddata bind = new loaddata();
            DataSet dsload = bind.getload(Session["name"].ToString());
            gdvwdata.DataSource = dsload.Tables[0].DefaultView;
            gdvwdata.DataBind();
        }
        else
        {
            Response.Write("<script>alert('请选中添加的数据')</script>");
        }
    }
    private string getadd()//获得帐号所在的具体地址
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
        conn.Open();
        SqlCommand cmd = new SqlCommand("getadd", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter para = new SqlParameter("@user_UID", SqlDbType.NVarChar, 50);
        para.Value = Session["name"].ToString();
        cmd.Parameters.Add(para);
        string stradd = cmd.ExecuteScalar().ToString();
        conn.Close();
        conn.Dispose();
        return stradd;
    }
    protected void imgreturn_Click(object sender, ImageClickEventArgs e)
    {
        this.Response.Redirect("batches.aspx");
    }
    protected void gdvwdata_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string id = gdvwdata.DataKeys[e.RowIndex].Value.ToString();
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
        conn.Open();
        SqlCommand cmd = new SqlCommand("delete_load", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlParameter para = new SqlParameter("@load_id", SqlDbType.Int);
        para.Value = Convert.ToInt16(id);
        cmd.Parameters.Add(para);
        cmd.ExecuteNonQuery();
        conn.Close();
        conn.Dispose();

        loaddata bind = new loaddata();
        DataSet dsload = bind.getload(Session["name"].ToString());
        gdvwdata.DataSource = dsload.Tables[0].DefaultView;
        gdvwdata.DataBind();
       
    }
}

⌨️ 快捷键说明

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