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 manage_Editorder : System.Web.UI.Page
{
    int nResult = -1;
    protected void Page_Load(object sender, EventArgs e)
    {
        Loginjudge();
        if (Request.Params["ShowID"] != null)
        {
            if (Int32.TryParse(Request.Params["ShowID"].ToString(), out nResult) == false) { return; }
            ShoworderByID(nResult);
        }
    }
    //显示order
    private void ShoworderByID(int nOrderID)
    {
        SqlDataReader dr = GetorderByID(nOrderID);
        if (dr.Read())
        {
            txtTitle.Text = dr["Title"].ToString();
            txtContent.Text = dr["Content"].ToString();
            txtDanwei.Text = dr["Lxdw"].ToString();
            txtName.Text = dr["Lxr"].ToString();
            txtPhone.Text = dr["Lxdh"].ToString();
        }
        dr.Close();
    }
    //按ID取订单信息
    public SqlDataReader GetorderByID(int nOrderID)
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYCONNECTIONSTRING"].ConnectionString);
        string cmdText = "SELECT * FROM Myorder WHERE OrderID=" + nOrderID;
        SqlCommand myCommand = new SqlCommand(cmdText, myConnection);
        SqlDataReader dr = null;
        try
        {
            myConnection.Open();
            dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        }
        catch (SqlException ex)
        {
            throw new Exception(ex.Message, ex);
        }
        return dr;
    }
    private void Loginjudge()
    {
        if (Session["Login"] == null)
        {
            Response.Redirect("Error.aspx");
        }
        else
        {
            if (Session["Login"] != "pass")
            {
                Response.Redirect("Error.aspx");
            }

        }
    }
}
