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_ReligionEdit : Base.BasePage
{
    #region Global variables
    ResourceManager objResourceManager;
    CultureInfo objCultureInfo;
    ReligionMaster objReligion = new ReligionMaster();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    DataSet ds_Religion = new DataSet();
    cls_Common objCommon = new cls_Common();
    int intReligion;
    int intCount, intEmployeeID;
    string gstrUserGroupName = string.Empty;
    string strSetAlert;
    #endregion
    #region page load
    /// <summary>
    /// 
    /// </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();
        gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        txt_religion.Focus();
        intReligion = Convert.ToInt32(Request.QueryString["Id"].ToString());
        if (!IsPostBack)
        {
            LoadLeaveType(intReligion);
            btn_save.OnClientClick = "if(Page_ClientValidate()) return confirm('" + objResourceManager.GetString("Alert_ConfirmSave", objCultureInfo) + "');return false;"; ;
            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 user defined function
    /// <summary>
    /// 
    /// </summary>
    /// <param name="id"></param>
    private void LoadLeaveType(int intid)
    {
        ds_Religion = objReligion.SelectReligionDetailsById(intid, gstrUserGroupName);
        if (ds_Religion.Tables[0].Rows.Count > 0)
        {
            txt_religion.Text = ds_Religion.Tables[0].Rows[0]["Name"].ToString();
            txt_ReliguionDesc.Text = ds_Religion.Tables[0].Rows[0]["Description"].ToString();
        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="objCultureInfo"></param>
    private void LoadStrings(CultureInfo objCultureInfo)
    {
        lbl_HeaderReligion.Text = objResourceManager.GetString("EmployeeMaster_Religion", objCultureInfo);
        lbl_Religion.Text = objResourceManager.GetString("EmployeeMaster_Religion", objCultureInfo);
        lbl_Des.Text = objResourceManager.GetString("Caption_ReligionName", objCultureInfo);
        lbl_Man.Text = objResourceManager.GetString("IndicatesMandatoryFields", objCultureInfo);
        Req_Religion.ErrorMessage = objResourceManager.GetString("EmployeeMaster_EnterReligion", objCultureInfo);
        Req_Desc.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"]), "modifyPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
        else
        {
            //   
        }
    }
    #endregion
    #region buttons
    /// <summary>
    /// To save
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_save_Click(object sender, EventArgs e)
    {
        string strReligionUpdate = string.Empty;
        strReligionUpdate = objReligion.UpdateReligionDetails(txt_religion.Text.Trim().Replace("'", "''"), txt_ReliguionDesc.Text.Trim().Replace("'", "''"), intReligion);
        if (strReligionUpdate == "-1")
        {
            base.Message(objResourceManager.GetString("Alert_ReligionAlreadyExists", objCultureInfo));
        }
        else
        {
            string strRedirectPage = "TA_UI_Master_ReligionList.aspx";
            base.MessageWithRedirect(objResourceManager.GetString("Alert_Religionmodifiedsuccessfully", objCultureInfo), strRedirectPage);
        }
    }
    /// <summary>
    /// To cancel
    /// </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
}
