using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class EditPageContents : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Btn_Edit_Click(object sender, EventArgs e)
    {
        UDF_SetBtnStates(false, true, true , false);
        TextBox2.Text = UDF_GetPageContent(int.Parse(Drp_PageNames.SelectedValue.ToString()));
    }

    private String UDF_GetPageContent(int int_PageID)
    {
        String Str_PageContent = String.Empty;
        Class_tblPageContents tblPgCnt = new Class_tblPageContents(int_PageID);
        tblPgCnt.UDF_GetPageContent();
        Str_PageContent = tblPgCnt.Str_PagesContent;
        return Str_PageContent;
    }

    private void UDF_SaveChanges(int int_PageID)
    {
        String Str_PageContent = String.Empty;
        Str_PageContent = TextBox2.Text.Trim();
        Class_tblPageContents tblPgCnt = new Class_tblPageContents(int_PageID , Str_PageContent);
        tblPgCnt.UDF_SavePageContent();
        UDF_EditorClear();
    }

    private void UDF_SetBtnStates(Boolean Bln_BtnEdt, Boolean Bln_BtnSave, Boolean Bln_BtnCancel , Boolean Bln_ComboBax)
    {
        Btn_Edit.Enabled = Bln_BtnEdt;
        Btn_Save.Enabled = Bln_BtnSave;
        Btn_Cancel.Enabled = Bln_BtnCancel;
        Drp_PageNames.Enabled = Bln_ComboBax;
    }
    protected void Btn_Save_Click(object sender, EventArgs e)
    {
        UDF_SaveChanges(int.Parse(Drp_PageNames.SelectedValue.ToString()));
        UDF_SetBtnStates(true, false, false , true);
        Lbl_Message.Text = "تغییرات با موفقیت اعمال شد.";
    }
    protected void Btn_Cancel_Click(object sender, EventArgs e)
    {
        UDF_SetBtnStates(true, false, false , true);
        Lbl_Message.Text = "عملیات لغو شد.";
        UDF_EditorClear();
    }

    protected void UDF_EditorClear()
    {
        TextBox2.Text = "";
    }

}
