コード例 #1
0
    private void Them_quang_cao()
    {
        //them bao quang cao
        XmlDocument Tai_lieu  = new XmlDocument();
        XmlElement  Quang_cao = null;

        Tai_lieu.Load(Server.MapPath("QUANG_CAO.xml"));
        Quang_cao = Tai_lieu.DocumentElement;

        XmlElement Thong_tin = Tai_lieu.CreateElement("ThongTin");

        Thong_tin.SetAttribute("Ten", Request["Ten_quang_cao"]);
        Thong_tin.SetAttribute("DiaChi", Request["Dia_chi"]);
        if (Request["Logo"] != null)
        {
            Thong_tin.SetAttribute("Logo", Request["Logo"]);
        }
        Thong_tin.SetAttribute("Website", Request["Website"]);
        Thong_tin.SetAttribute("TinhTrang", Request["Tinh_trang"]);
        //Thong_tin.SetAttribute("TrangXuatHien", Request["WebsiteTheHien"]);

        Quang_cao.AppendChild(Thong_tin);
        Tai_lieu.Save(Server.MapPath("QUANG_CAO.xml"));

        //them vao tung website
        string website_the_hien = Request["WebsiteTheHien"].ToString();

        string[]    arr       = website_the_hien.Split('-');
        XmlDocument Tai_lieu1 = new XmlDocument();
        XmlElement  website   = null;

        Tai_lieu1.Load(Server.MapPath("WEBSITE.xml"));
        website = Tai_lieu1.DocumentElement;

        for (int i = 0; i < arr.Length; i++)
        {
            foreach (XmlElement Thong_tin1 in website.ChildNodes)
            {
                if (Thong_tin1.GetAttribute("Ten").CompareTo(arr[i]) == 0)
                {
                    XmlElement _quangcao = Tai_lieu1.CreateElement("QuangCao");
                    _quangcao.SetAttribute("Ten", Request["Ten_quang_cao"]);
                    Thong_tin1.AppendChild(_quangcao);
                }
                if (Thong_tin1.ChildNodes.Count >= 4)
                {
                    Thong_tin1.SetAttribute("TinhTrang", "0");
                }
            }
        }

        Tai_lieu1.Save(Server.MapPath("WEBSITE.xml"));

        Session["Ten_quang_cao"] = Request["Ten_quang_cao"];

        XL_THE Kq = new XL_THE("Goc");

        XL_CHUOI.XuatXML(Response, Kq.Chuoi());
    }
コード例 #2
0
    private void Cap_nhat_thong_tin()
    {
        XmlDocument Tai_lieu  = new XmlDocument();
        XmlElement  Quang_cao = null;

        Tai_lieu.Load(Server.MapPath("QUANG_CAO.xml"));
        Quang_cao = Tai_lieu.DocumentElement;

        foreach (XmlElement Thong_tin in Quang_cao.ChildNodes)
        {
            if (Thong_tin.GetAttribute("Ten").CompareTo(Session["Ten_cong_ty"]) == 0)
            {
                Session["Ten_cong_ty"] = Request["Ten_cong_ty"];

                Thong_tin.SetAttribute("Ten", Request["Ten_cong_ty"]);
                Thong_tin.SetAttribute("DiaChi", Request["Dia_chi"]);
                Thong_tin.SetAttribute("Website", Request["Website"]);

                //Thong_tin.SetAttribute("TrangXuatHien", Request["WebsiteTheHien"]);
                string      website_the_hien = Request["WebsiteTheHien"].ToString();
                string[]    arr       = website_the_hien.Split('-');
                XmlDocument Tai_lieu1 = new XmlDocument();
                XmlElement  website   = null;
                Tai_lieu1.Load(Server.MapPath("WEBSITE.xml"));
                website = Tai_lieu1.DocumentElement;

                String      strExp  = "//WEBSITE//ThongTin//QuangCao[@Ten='" + Thong_tin.GetAttribute("Ten") + "']";
                XmlNodeList nodeAdv = website.SelectNodes(strExp);
                foreach (XmlNode node in nodeAdv)
                {
                    XmlNode parent = node.ParentNode;
                    parent.RemoveChild(node);
                }

                for (int i = 0; i < arr.Length; i++)
                {
                    foreach (XmlElement Thong_tin1 in website.ChildNodes)
                    {
                        if (Thong_tin1.GetAttribute("Ten").CompareTo(arr[i]) == 0)
                        {
                            XmlElement _quangcao = Tai_lieu1.CreateElement("QuangCao");
                            _quangcao.SetAttribute("Ten", Request["Ten_cong_ty"]);
                            Thong_tin1.AppendChild(_quangcao);
                        }
                    }
                }
                Tai_lieu1.Save(Server.MapPath("WEBSITE.xml"));
                ////////////////////////////////////////////////////////////////////////////

                if (Request["Logo"] != null)
                {
                    Thong_tin.SetAttribute("Logo", Request["Logo"]);
                }

                Thong_tin.SetAttribute("TinhTrang", Request["Tinh_trang"]);

                Tai_lieu.Save(Server.MapPath("QUANG_CAO.xml"));
                XL_THE Kq = new XL_THE("Goc");
                XL_CHUOI.XuatXML(Response, Kq.Chuoi());

                break;
            }
        }
    }