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

📄 showorder.aspx.cs

📁 asp.net 的某物流管理系统 MIS 系统
💻 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.OleDb;

public partial class include_Showhuo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["Leaveword"].ToString() != "pass")
            {
                Response.Redirect("../Default.aspx");
            }

        }
        catch
        {
            Response.Redirect("../Default.aspx");
        }
        if (!Page.IsPostBack)
        {
            Addorderdrp();
            Button deleteBtn = (Button)delBtn;
            deleteBtn.Attributes.Add("onclick", "return confirm('将永久删除此运单下的所有货物,你确定删除?');");
        }
    }
      
   
    protected void HuoGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        HuoGridView.PageIndex = e.NewPageIndex;
        Bindgridview();
    }
    //绑定控件
    private void Bindgridview()
    {
        DataSet ds = Gethuobyorder(drpOrder.SelectedItem.Text.ToString().Trim());
        HuoGridView.DataSource = ds.Tables["aa"].DefaultView;
        HuoGridView.DataBind();
    }
    //填充运单下拉框
    private void Addorderdrp()
    {
        DataSet ds = Getallorder();
        drpOrder.Items.Clear();
        drpOrder.Items.Add(new ListItem("选择运单号", "选择运单号"));
        for (int i = 0; i < ds.Tables["aa"].DefaultView.Count; i++)
        {
            drpOrder.Items.Add(new ListItem(ds.Tables["aa"].Rows[i][1].ToString(), ds.Tables["aa"].Rows[i][0].ToString()));
        }
    }
    //取全部运单
    public DataSet Getallorder()
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM Myorder ORDER BY Createdate DESC";
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(cmdText, myConnection);
        try
        {
            myConnection.Open();
            da.Fill(ds, "aa");
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
        return ds;
    }
    //按ID读运单信息
    public OleDbDataReader GetorderbyID(int nOrderID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM Myorder WHERE OrderID="+nOrderID;
        OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
        OleDbDataReader dr = null;
        try
        {
            myConnection.Open();
            dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        return dr;
    }
    //取发货信息按运单号
    public DataSet Gethuobyorder(string sOrdernum)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM Huowu WHERE FaID=1 AND Ordernum='" + sOrdernum + "' ORDER BY Createdate DESC";
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(cmdText, myConnection);
        try
        {
            myConnection.Open();
            da.Fill(ds, "aa");
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
        return ds;
    }
    //删除指定定单
    private void DelorderbyID(int nOrderID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "DELETE FROM Myorder WHERE OrderID=" + nOrderID;
        OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
    }

    protected void drpOrder_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (drpOrder.SelectedIndex == 0)
        {
            Bindgridview();
            lblorderdate.Text = "";
            lblYundan.Text = "";
            txtBeizhu.Text = "";
            txtChepai.Text = "";
            txtJiedian.Text = "";
            txtJieren.Text = "";
            txtJiezhen.Text = "";
            txtJiezhi.Text = "";
            txtSidi.Text = "";
            txtSihua.Text = "";
            txtSiming.Text = "";
            delBtn.Visible = false;
            return;
        }
        //显示此运单全部货物
        Bindgridview();
        //显示此运单相关信息
        OleDbDataReader dr=GetorderbyID(Int32.Parse(drpOrder.SelectedValue.ToString()));
        if(dr.Read())
        {
            lblYundan.Text = dr["Ordernum"].ToString();
            lblorderdate.Text = dr["Createdate"].ToString();
                txtBeizhu.Text = dr["Beizhu"].ToString();
                txtChepai.Text = dr["Chepai"].ToString();
                txtJiedian.Text = dr["Jiehua"].ToString();
                txtJieren.Text = dr["Jieren"].ToString();
                txtJiezhen.Text = dr["Jiezhen"].ToString();
                txtJiezhi.Text = dr["Jiezhi"].ToString();
                txtSidi.Text = dr["Sidi"].ToString();
                txtSihua.Text = dr["Sihua"].ToString();
                txtSiming.Text = dr["Siming"].ToString();
        }
        delBtn.Visible = true;
    }
    protected void HuoGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName.ToString())
        {
            case "exit":
                Exitorder(Int32.Parse(e.CommandArgument.ToString()));
                Bindgridview();
                break;
            default:
                break;
        }
    }
    //返回收货单
    private void Exitorder(int nHuowuID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "UPDATE Huowu SET FaID=0 WHERE HuowuID=" + nHuowuID;
        OleDbCommand myCommand = new OleDbCommand(cmdText, myConnection);
        try
        {
            myConnection.Open();
            myCommand.ExecuteNonQuery();
        }
        catch (OleDbException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        finally
        {
            myConnection.Close();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        DelorderbyID(Int32.Parse(drpOrder.SelectedValue.ToString()));
        delBtn.Visible = false;
        drpOrder.SelectedIndex = 0;
        Addorderdrp();
        Bindgridview();
    }
}

⌨️ 快捷键说明

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