public string Add(string key, string content)
 {
     string mess = "";
     string temp = HttpContext.Current.Server.HtmlEncode(content);
     Language_content languagecontent = new Language_content();
     languagecontent.SetFile(HttpContext.Current.Session["namePath_file_language_content"].ToString());
     mess = languagecontent.InsertRecord(key, temp);
     ResetLanguageShow();
     if (mess.Equals(""))
     {
         HttpContext.Current.Application[HttpContext.Current.Session["namePath_file_language_content"].ToString()] = null;
         if (!SetApp())
         {
             Response.Redirect("Default.aspx?menu=lang");
         }
     }
     else
         if (mess.Equals("FileNoEixts"))
         {
             mess = "File ngôn ngữ đã bị xóa. Không thể thêm mới nội dung.";
             HttpContext.Current.Session["language_content_dynamic"] = null;
             HttpContext.Current.Application[HttpContext.Current.Session["namePath_file_language_content"].ToString()] = null;
         }
     return mess;
 }
    public string Delete(string id_delete)
    {
        string str = "";
        HttpContext.Current.Session["id_delete"] = id_delete;
        string file_name = HttpContext.Current.Session["namePath_file_language_content"].ToString();
        Language_content language_content = new Language_content();
        language_content.SetFile(file_name);
        if (language_content.IsExitsFile())
        {

            string[] id = new string[50];
            if (id_delete.Length > 0)
            {
                try
                {
                    string str_where = id_delete.Substring(0, id_delete.Length - 1);
                    id = str_where.Split(',');
                    XmlTextReader reader = new XmlTextReader(file_name);
                    XmlDocument doc = new XmlDocument();
                    doc.Load(reader);
                    reader.Close();

                    //Select the cd node with the matching title
                    XmlNode cd;
                    XmlElement root = doc.DocumentElement;
                    for (int i = 0; i < id.Length; i++)
                    {
                        cd = root.SelectSingleNode("/langs/lang[key='" + id[i] + "']");
                        if (cd != null)
                        {
                            root.RemoveChild(cd);
                        }
                        //save the output to a file
                    }
                    doc.Save(file_name);
                    str = "";
                    ResetLanguageShow();
                    HttpContext.Current.Application[HttpContext.Current.Session["namePath_file_language_content"].ToString()] = null;
                    if (!SetApp())
                    {
                        Response.Redirect("Default.aspx");
                    }
                }
                catch (Exception ex)
                {
                    //Response.Write(ex.ToString());
                    str = "Quyền cập nhật file đã khóa. Không thể xóa bỏ nội dung.. ";
                }
            }
            else
            {
                str = "Bạn phải chọn nội dung muốn xóa";
            }
            return str;
        }
        else
        {
            str = "File ngôn ngữ đã bị xóa. Không thể xóa bỏ nội dung.";
            HttpContext.Current.Session["language_content_dynamic"] = null;
            HttpContext.Current.Application[HttpContext.Current.Session["namePath_file_language_content"].ToString()] = null;
            return str;
        }
    }
    public string[] ShowData_Search(int action)
    {
        //cau hinh trang hien thi
        string err = "";
        Language_content language_content = new Language_content();
        language_content.SetFile(HttpContext.Current.Session["namePath_file_language_content"].ToString());
        if (language_content.IsExitsFile())
        {
            if (HttpContext.Current.Session["language_content_dynamic_search"] != null)
            {
                try
                {
                    string keysearch = HttpContext.Current.Session["keysearch"].ToString();
                    CDynamicviewHelperXmlLanguageContent dynamic = (CDynamicviewHelperXmlLanguageContent)HttpContext.Current.Session["language_content_dynamic_search"];
                    nav = (XPathNavigator)HttpContext.Current.Application[HttpContext.Current.Session["namePath_file_language_content"].ToString()];
                    XPathNodeIterator nodes = nav.Select("/langs/lang[contains(key,'" + keysearch + "')]");
                    dynamic.SetNumberRecord(nodes.Count);
                    dynamic.SetNavigator(nav);
                    dynamic.SetStringSeach(keysearch);
                }
                catch (Exception ex) { Response.Write(ex.ToString()); }
            }
        }
        else
        {
            CDynamicviewHelperXmlLanguageContent dynamic = new CDynamicviewHelperXmlLanguageContent();
            dynamic.SetNumberRecord(0);
            dynamic.SetStringSeach("");
            dynamic.ReSetCurrentPage();
            HttpContext.Current.Session["language_content_dynamic_search"] = dynamic;
            err = "File ngôn ngữ đã bị xóa. Không tìm kiếm nội dung.";
        }

        string[] arrStr = new string[6];
        string str = "";
        if (HttpContext.Current.Session["language_content_dynamic_search"] != null)
        {
            CDynamicviewHelperXmlLanguageContent dynamic = (CDynamicviewHelperXmlLanguageContent)HttpContext.Current.Session["language_content_dynamic_search"];
            if (action == 1)
            {
                dynamic.FirstPage();
            }
            else if (action == 2)
            {
                dynamic.PreviousPage();
            }
            else if (action == 3)
            {
                dynamic.NextPage();
            }
            else if (action == 4)
            {
                dynamic.LastPage();
            }
            else
            {
                dynamic.ReSetCurrentPage();
            }
            string page = "Trang:" + dynamic.GetCurrentPage().ToString() + "/" + dynamic.GetPages().ToString();
            arrStr[0] = page;
            arrStr[2] = dynamic.GetIsFirstPage().ToString();
            arrStr[3] = dynamic.GetIsLastPage().ToString();
            arrStr[4] = dynamic.GetNumberRecord().ToString();
            ArrayList list = dynamic.GetNodeShow(Edit_language_content);
            int count = list.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    str = list[i].ToString();
                }
            }
        }
        arrStr[1] = str;
        arrStr[5] = err;
        return arrStr;
    }
 public string FileExits(string Path)
 {
     string err = "";
     Language_content language_content = new Language_content();
     language_content.SetFile(Path);
     if (language_content.IsExitsFile())
     {
         err = "";
     }
     else
     {
         err = "File ngôn ngữ đã bị xóa. Không tìm kiếm nội dung.";
     }
     return err;
 }