using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                   Started Date  : 12-Aug-2007
* Module          : Reset Password                              Last Modified : 14-Aug-2007
* Programmer      : Janakaraj.P
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class System_Settings_Resetpassword_Popup : Base.BasePage
{
    #region VariableDeclaration
    ResourceManager rm;
    CultureInfo ci;
    int LevelID;
    DataSet ds = new DataSet();
    bool checkLevel;
    bool gcheckParentLevelExist;
    ShiftAllocationEvendata obj = new ShiftAllocationEvendata();
    #endregion
    #region PageLoad
    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"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        aspnetForm.Attributes.CssStyle.Add("Direction", rm.GetString("Direction", ci));
        LoadStrings(ci);
        loadcss();
        if (!IsPostBack)
        {
            btn_done1.Visible = false;
            hdnTxtField.Value = Request.QueryString["Txt"].ToString();
            string strSetAlert = "";
            strSetAlert = strSetAlert + "<script language='javascript'>";
            strSetAlert = strSetAlert + "SetAlertMessages_DeleteRestore('" + rm.GetString("Alert_ConfirmDelete") + "','" + rm.GetString("Alert_SelectItemsToDelete") + "','" + rm.GetString("Alert_ConfirmDeletePermanent") + "','" + rm.GetString("Alert_Areyousuretorestore") + "','" + rm.GetString("Alert_SelectItemsToRestore") + "','" + rm.GetString("Alert_SelectItemToForwarded") + "','" + rm.GetString("Alert_SelectItemToApproved") + "');";
            strSetAlert = strSetAlert + "</script>";
            Page.RegisterStartupScript("SetAlertMessages", strSetAlert);
        }
    }
    #endregion
    #region GridviewEvents
    protected void grv_Shift_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grv_Shift.PageIndex = e.NewPageIndex;
        shiftDataBind();
    }
    protected void grv_Shift_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex == 0)
        {
            HtmlInputRadioButton rdbID = new HtmlInputRadioButton();
            rdbID = (HtmlInputRadioButton)e.Row.FindControl("rdbID");
            rdbID.Checked = true;
            hdnEmployeeCodeId.Value = rdbID.Value;
        }
    }
    #endregion
    #region ButtonEvents
    protected void butGo_Click(object sender, EventArgs e)
    {
        Session["currentSession"] = Session["parentLevelId"];
        Session["parentLevelId"] = null;
        shiftDataBind();
        if (checkLevel == true)
        {
            return;
        }
        if (gcheckParentLevelExist == true)
        {
            btn_done1.Visible = true;
        }
        else
        {
            btn_done1.Visible = false;
            string strMsg;
            strMsg = "<script language='javascript'>";
            strMsg = strMsg + "alert('" + rm.GetString("Alert_Norecordsfound", ci) + "');";
            strMsg = strMsg + "</script>";
            Page.RegisterStartupScript("Display Message ShiftAllocationAdd", strMsg);
            divShift.Visible = false;
            return;
        }
    }
    #endregion
    #region UserDefinedFunctions
    //Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        grv_Shift.Columns[1].HeaderText = rm.GetString("email_EmployeeId", ci);
        grv_Shift.Columns[2].HeaderText = rm.GetString("email_EmployeeName", ci);
        butGo.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Go", ci);
        btn_done1.Text = "&nbsp;&nbsp;" + rm.GetString("btn_Ok", ci);
        lblFilter.Text = rm.GetString("lblFilter", ci);

    }
    private void loadcss()
    {
        CultureInfo ci;
        string source_Language;
        source_Language = Convert.ToString(Session["Session_ActiveLanguage"]);
        rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        ci = Thread.CurrentThread.CurrentCulture;
        //if Standard Demo
        htmlResetPass.Attributes.Add("dir", rm.GetString("Direction", ci));
        if (source_Language == "Resources.Resource_AR")
        {
            stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            stylecustom.Href = "../dist/css/custom-rtl.css";
            stylefonts.Href = "../dist/css/fonts.css";
            styleselect2.Href = "../plugins/select2/select2.min-rtl.css";
        }
        else
        {
            //htmlCity.Attributes.Add("dir", "rtl");
            //stylebootstrap.Href = "../bootstrap/css/bootstrap-rtl.min.css";
            //stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome-rtl.css";
            //styleAdminLTE.Href = "../dist/css/AdminLTE.min-rtl.css";
            //stylecustom.Href = "../dist/css/custom-rtl.css";
            //stylefonts.Href = "../dist/css/fonts.css";
            stylebootstrap.Href = "../bootstrap/css/bootstrap.min.css";
            stylefontawesome.Href = "../bootstrap/font-awesome/css/font-awesome.css";
            styleAdminLTE.Href = "../dist/css/AdminLTE.min.css";
            stylecustom.Href = "../dist/css/custom.css";
            stylefonts.Href = "../dist/css/fonts.css";
            styleselect2.Href = "../plugins/select2/select2.min.css";
        }
    }
    public void shiftDataBind()
    {
        Rpt_Common rptcommon = new Rpt_Common();
        string Level = "";
        LevelID = 0;
        if (Session["currentSession"] != null)
        {
            LevelID = Convert.ToInt32(Session["currentSession"]);
        }
        if (LevelID == 0)
        {
            grv_Shift.DataSourceID = "";
            grv_Shift.DataBind();
            lbl_Error.Text = rm.GetString("Alert_Selectallorganizationlevels", ci);
            checkLevel = true;
            btn_done1.Visible = false;
            return;
        }
        else
        {
            Level = rptcommon.getNodes(LevelID, Convert.ToString(Session["LevelRights"]));
            lbl_Error.Text = "";
        }
        ds = obj.SelectEmployee(Convert.ToInt32(Session["EmpAutoID"]), Level, Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["GradeLevel"]), Convert.ToInt32(LevelID));
        if (ds.Tables.Count > 0)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                grv_Shift.DataSource = ds.Tables[0];
                grv_Shift.DataBind();
                divShift.Visible = true;
                lbl_Error.Text = "";
                gcheckParentLevelExist = true;
            }
            else
            {
                btn_done1.Visible = false;
                gcheckParentLevelExist = false;
            }
        }
        else
        {
            gcheckParentLevelExist = false;
        }
    }
    #endregion
}