using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
public partial class Masters_TA_UI_Master_ReligionAdd : Base.BasePage
{
    #region Global variable
    ResourceManager objResourceManager;
    CultureInfo objCultureInfo;
    ReligionMaster objReligion = new ReligionMaster();
    cls_Common objCommon = new cls_Common();
    int intCount;
    int intEmployeeID = 0;
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    string strSetAlert;
    #endregion
    #region Page Load
    /// <summary>
    /// When page is loaded
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking
        base.Page_Load(sender, e);
        //get the culture info to set the language
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        intEmployeeID = Convert.ToInt32(Session["EmpAutoID"].ToString());
        objResourceManager = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        objCultureInfo = Thread.CurrentThread.CurrentCulture;
        // LoadStrings Function fills the Label from the Resource File
        LoadStrings(objCultureInfo);
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        //Set UserRights
        UserRights();
        txt_ReligionName.Focus();
        btn_save.OnClientClick = "if(Page_ClientValidate()) return confirm('" + objResourceManager.GetString("Alert_ConfirmSave", objCultureInfo) + "');return false;"; ;
        if (!IsPostBack)
        {
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "MaxLengthh('" + objResourceManager.GetString("Alert_MaximumLengthis", objCultureInfo) + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("MaxLengthh", strSetAlert);
            objCommon.menu("EmployeeMaster", "229");
        }
    }
    #endregion
    #region Button events
    /// <summary>
    /// To save religion
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_save_Click(object sender, EventArgs e)
    {
        string strreligion = string.Empty;
        strreligion = objReligion.InsertReligionDetails(txt_ReligionName.Text.Trim().Replace("'", "''"), txt_ReligionDescription.Text.Trim().Replace("'", "''"));
        //Response.Redirect("TA_UI_MasterLeaveTypeList.aspx");
        // base.MessageWithRedirect("Leave Type saved successfully", "TA_UI_MasterLeaveTypeList.aspx");
        if (strreligion == "-1")
        {
            base.Message(objResourceManager.GetString("Alert_ReligionAlreadyExists", objCultureInfo));
        }
        else
        {
            base.MessageWithRedirect(objResourceManager.GetString("Alert_Religionsavedsuccessfully", objCultureInfo), "TA_UI_Master_ReligionList.aspx");
        }
        //}
        //else
        //{
        //    //lblerror.Text = "Leave Type Already Exists";
        //    base.Message(objResourceManager.GetString("Alert_ReligionAlreadyExists", objCultureInfo));
    }
    /// <summary>
    /// To cancel add
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_cancel_Click(object sender, EventArgs e)
    {
        Response.Redirect("TA_UI_Master_ReligionList.aspx");
    }
    //Getting Information from resource file and display it in label
    #endregion
    #region user defined function
    /// <summary>
    /// Load label names
    /// </summary>
    /// <param name="objCultureInfo"></param>
    private void LoadStrings(CultureInfo objCultureInfo)
    {
        lbl_Header.Text = objResourceManager.GetString("EmployeeMaster_Religion", objCultureInfo);
        lbl_ReligionName.Text = objResourceManager.GetString("Caption_Religion", objCultureInfo);
        lbl_ReligionDescription.Text = objResourceManager.GetString("Caption_ReligionName", objCultureInfo);
        lbl_Man.Text = objResourceManager.GetString("IndicatesMandatoryFields", objCultureInfo);
        Req_Religion.ErrorMessage = objResourceManager.GetString("EmployeeMaster_EnterReligion", objCultureInfo);
        Req_Description.ErrorMessage = objResourceManager.GetString("EmployeeMaster_EnterReligionDescription", objCultureInfo);
        btn_save.Text = "&nbsp;&nbsp;" + objResourceManager.GetString("btn_Save", objCultureInfo);
        btn_cancel.Text = "&nbsp;&nbsp;" + objResourceManager.GetString("btn_Back", objCultureInfo);
    }
    /// <summary>
    /// 
    /// </summary>
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(229, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
        else
        {
            //   
        }
    }
    #endregion
}
