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

📄 edithuo.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_Inputhuo : 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)
        {
            OleDbDataReader dr = GetinfobyID(Int32.Parse(Request.Params["ShowID"].ToString()));
            if (dr.Read())
            {
                txtbeizhu.Text = dr["Beizhu"].ToString();
                txtdaozhan.Text = dr["Daozhan"].ToString();
                txtdianfu.Text = dr["Dianfu"].ToString();
                txtfushi.Text = dr["Fushi"].ToString();
                txthuohao.Text = dr["Huohao"].ToString();
                txthuoming.Text = dr["Huoming"].ToString();
                txtjianshu.Text = dr["Jianshu"].ToString();
                txtlianhua.Text = dr["Lianhua"].ToString();
                txtlianren.Text = dr["Lianren"].ToString();
                txtlianzhi.Text = dr["Lianzhi"].ToString();
                txtyune.Text = dr["Yune"].ToString();
                txtzhongliang.Text = dr["Zhongliang"].ToString();
            }
        }
    }
    //保存货物信息
    private void Updateinfo(string sHuohao, string sHuoming, int nJianshu, string sZhongliang,
        string sDaozhan, decimal dYune, decimal dDianfu, string sFushi, string sLianren, string sLianhua,
        string sLianzhi, string sBeizhu,int nHuowuID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "UPDATE Huowu SET " +
            "Huohao='" + sHuohao + "'," +
            "Huoming='" + sHuoming + "'," +
            "Jianshu=" + nJianshu + "," +
            "Zhongliang='" + sZhongliang + "'," +
            "Daozhan='" + sDaozhan + "'," +
            "Yune=" + dYune + "," +
            "Dianfu=" + dDianfu + "," +
            "Fushi='" + sFushi + "'," +
            "Lianren='" + sLianren + "'," +
            "Lianhua='" + sLianhua + "'," +
            "Lianzhi='" + sLianzhi + "'," +
            "Beizhu='" + sBeizhu + "' 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();
        }

    }
    //取货物信息
    public OleDbDataReader GetinfobyID(int nHuoID)
    {
        string myConnectionString = ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING1"].ConnectionString + Server.MapPath("~") + ConfigurationManager.ConnectionStrings["OLEDBCONNECTIONSTRING2"].ConnectionString;
        OleDbConnection myConnection = new OleDbConnection(myConnectionString);
        string cmdText = "SELECT * FROM Huowu WHERE FaID=0 AND HuowuID=" + nHuoID;
        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;
    }
    //清空
    private void Clearstr()
    {
        txtbeizhu.Text = "";
        txtdaozhan.Text = "";
        txtdianfu.Text = "";
        txtfushi.Text = "";
        txthuohao.Text = "";
        txthuoming.Text = "";
        txtjianshu.Text = "";
        txtlianhua.Text = "";
        txtlianren.Text = "";
        txtlianzhi.Text = "";
        txtyune.Text = "";
        txtzhongliang.Text = "";
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Write("<Script>window.close()</Script>");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (txtyune.Text.Trim().Length < 1) txtyune.Text = "0";
        if (txtdianfu.Text.Trim().Length < 1) txtdianfu.Text = "0";
        string huohao = txthuohao.Text.ToString().Trim();
        string huoming = txthuoming.Text.ToString().Trim();
        int jianshu = Int32.Parse(txtjianshu.Text.ToString().Trim());
        string zhongliang = txtzhongliang.Text.ToString().Trim();
        string daozhan = txtdaozhan.Text.ToString().Trim();
        decimal yune = Convert.ToDecimal(txtyune.Text.ToString().Trim());
        decimal dianfu =Convert.ToDecimal(txtdianfu.Text.ToString().Trim());
        string fushi = txtfushi.Text.ToString().Trim();
        string lianren = txtlianren.Text.ToString().Trim();
        string lianhua = txtlianhua.Text.ToString().Trim();
        string lianzhi = txtlianzhi.Text.ToString().Trim();
        string beizhu = txtbeizhu.Text.ToString().Trim();
        int HuowuID = Int32.Parse(Request.Params["ShowID"].ToString());
        if (huohao.Length < 1)
        {
            Response.Write("<Script>alert('货号不为空!')</Script>");
            return;
        }
        Updateinfo(huohao, huoming, jianshu, zhongliang, daozhan, yune, dianfu, fushi, lianren, lianhua, lianzhi, beizhu,HuowuID);
        Response.Write("<Script>alert('修改数据成功!')</Script>");
        
    }
}

⌨️ 快捷键说明

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