コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ConnectDatabase alayer = new ConnectDatabase();
            SqlDataReader   reader;
            int             num = 0;
            string          GroupNo, MenuName = "", ImagePath, MenuPrice, MenuDescription, Mode;

            if (Request.QueryString["Menu_Name"] != null)
            {
                MenuName = Request.QueryString["Menu_Name"];
            }
            if (Request.QueryString["Menu_Group"] != null)
            {
                GroupNo            = Request.QueryString["Menu_Group"];
                Label_Groupno.Text = GroupNo;
                num = Convert.ToInt32(GroupNo.ToString());
            }
            reader = alayer.GetAllMenuTableFromDB(num, MenuName);
            if (reader != null)
            {
                while (reader.HasRows)
                {
                    MenuName  = reader.GetName(0);
                    MenuPrice = reader.GetName(1);

                    while (reader.Read())
                    {
                        MenuName        = reader.GetString(0);
                        MenuPrice       = reader.GetString(1);
                        ImagePath       = reader.GetString(2);
                        MenuDescription = reader.GetString(3);

                        ImagePath       = ImagePath.Trim();
                        MenuDescription = MenuDescription.Trim();

                        Label3.Text             = MenuName;
                        Image1.ImageUrl         = ImagePath;
                        txtMenuName.Text        = MenuName;
                        txtMenuPrice.Text       = MenuPrice;
                        Session["ImagePath"]    = ImagePath;
                        txtMenuDescription.Text = MenuDescription;
                    }
                    reader.NextResult();
                }
            }
            else
            {
                Response.Write("<script>alert('Can not get data from database');window.location='ViewUserPage.aspx';</script>");
                return;
            }
            reader.Close();
        }