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;
using System.Xml;
using System.IO;

public partial class WTOSYSadmin_Products_AJAXddl : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string msg = Request.QueryString["ddlFl"].Trim();
        //int msg = 10000001;
        SqlConnection conn = CDatabase.wtoconn();
        conn.Open();
        SqlCommand smd = new SqlCommand("select * from SmallProductAttribute where BigAttributeId=" + msg + " and attvalue='novalue'", conn);
        SqlDataReader sdr = smd.ExecuteReader();
        string xmlstr = "";
        while (sdr.Read())
        {
            xmlstr += sdr.GetString(1).Trim() + "|";
        }

        sdr.Close();

        string[] sArray = xmlstr.Split('|');
        string xmlstr2 = "<?xml version='1.0' encoding='UTF-8' ?>";
        xmlstr2 += "<bodyfl>";

        for (int i = 0; i < sArray.Length - 1; i++)
        {
            SqlCommand smd2 = new SqlCommand("select * from SmallProductAttribute where SmallAttribute='" + sArray[i].ToString() + "' and  attvalue<>'novalue'", conn);
            SqlDataReader sdr2 = smd2.ExecuteReader();

            xmlstr2 += "<xmldl value='" + sArray[i].ToString() + "'>";

            while (sdr2.Read())
            {
                xmlstr2 += "<xmlxl>" + sdr2.GetString(6).ToString() + "</xmlxl>";

            }
            xmlstr2 += "</xmldl>";
            smd2.Dispose();
            sdr2.Dispose();

        }
        xmlstr2 += "</bodyfl>";
        conn.Close();



        Response.Write(xmlstr2);
        //XmlDocument xmldoc = new XmlDocument(); //创建空的XML文档


        //xmldoc.LoadXml(xmlstr2);
        //string picPath = Server.MapPath("..\\Products\\XMLp\\");
        //string filed = "bookstore.xml";
        //string strNewPath = GetSaveFilePath(picPath) + GetExtension(filed);
        //xmldoc.Save(picPath + strNewPath); //保存
        //Response.Write(strNewPath);


      
    }



    //#region 创建文件夹并重命名
    //private string GetExtension(string fileName)
    //{
    //    int startPos = fileName.LastIndexOf(".");
    //    string ext = fileName.Substring(startPos, fileName.Length - startPos);
    //    return ext;
    //}
    //private string GetSaveFilePath(string picname)
    //{
    //    DateTime dateTime = DateTime.Now;
    //    string yearStr = dateTime.Year.ToString(); ;
    //    string monthStr = dateTime.Month.ToString();
    //    string dayStr = dateTime.Day.ToString();
    //    string hourStr = dateTime.Hour.ToString();
    //    string minuteStr = dateTime.Minute.ToString();
    //    string dir = dateTime.ToString("\\yyyyMMdd");
    //    if (!Directory.Exists(picname + dir))
    //    {
    //        Directory.CreateDirectory(picname + dir);
    //    }
    //    return dir + dateTime.ToString("\\\\yyyyMMddhhmmssffff");
    //}
    //#endregion
  

}
