using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TABS.MailCarrier.WebSDK.Approval;

public partial class Approval_Options : System.Web.UI.Page
{
    protected override void InitializeCulture()
    {
        string defLang = WebUser.CurrentUser.UiLanguage;
        Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(defLang);
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(defLang);
        base.InitializeCulture();
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        WebUtil.SetMcCommonCss(Page.Header);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Page.Title = AppSetting.GetTitleInfo(Request).Title;
            ApprovalOptions options = new ApprovalOptions(WebUser.CurrentUser.DomainUserID);
            AbsenceCheckBox.Checked = options.GetAbsenceFlag();
            NotifyMailCheckBox.Checked = options.GetNoApprovalMailFlag();
        }
    }

    protected void ApplyButton_Click(object sender, EventArgs e)
    {
        ApprovalOptions options = new ApprovalOptions(WebUser.CurrentUser.DomainUserID);
        options.SetAbsenceFlag(AbsenceCheckBox.Checked);
        options.SetNoApprovalMailFlag(NotifyMailCheckBox.Checked);

        if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "Applied"))
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Applied", "Applied()", true);
    }
}