using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TABS.MailCarrier.WebSDK.Mail;
using TABS.MailCarrier.WebSDK;

public partial class Mail_PermitSend_DecideSend : System.Web.UI.Page
{
    protected string _clId = "";
    protected string _actionButtonText = "";
    protected string _listPageParams;
    protected string _delegateName = "";

    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_Load(object sender, EventArgs e)
    {
        _clId = WebParam.GetStrParamValue("clid");
        _listPageParams = string.Format("mode={0}&page={1}&delegate={2}", WebParam.GetStrParamValue("mode"), WebParam.GetIntParamValue("page"), WebParam.GetStrParamValue("delegate"));
        if (!IsPostBack)
        {
            Page.Title = AppSetting.GetTitleInfo(Request).Title;

            string validKey1 = "delegate=" + _clId;
            string validKey2 = "clid=" + _clId;

            if (Session[validKey1] != null && (bool)Session[validKey1])
            {
                _delegateName = WebUser.CurrentUser.Name;
                InitUI();
                return;
            }
            if (Session[validKey2] != null && (bool)Session[validKey2])
            {
                _delegateName = "";
                InitUI();
                return;
            }
            Response.Redirect("~/Error.aspx?code=0");
        }
    }

    private void InitUI()
    {
        if (WebParam.GetStrParamValue("cmd") == "approve")
        {
            actionToolButton.Attributes["onclick"] = "Approve()";
            _actionButtonText = (string)GetLocalResourceObject("Approve");
        }
        else
        {
            actionToolButton.Attributes["onclick"] = "Reject()";
            _actionButtonText = (string)GetLocalResourceObject("Reject");
        }
    }
}