using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Threading;
using System.Reflection;
using System.Resources;
using DevExpress.Web;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                                          Started Date  : 24-July-2007
* Module          : Payroll Process                                                    Last Modified : 20-Aug-2007
* Programmer      : Kumuthini.L
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          : \\windev\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
****************************************************************************************************************************/
public partial class Transactions_TA_UI_Transactions_MonthClosure : Base.BasePage
{
    #region "Variable Declaration"
    ResourceManager rm;
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    cls_Common objCommon = new cls_Common();
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        base.Page_Load(sender, e);
        grv_MonthClosure.Styles.CssFilePath = Convert.ToString(Session["GridCSS"]);
        //Session.LCID = 1033;
        // Get the culture info to set the language
        if (!Page.IsPostBack)
        {
            base.CheckPages(0);
            objCommon.menu("ExportTran", "27");
        }
        CultureInfo ci;
        if (Session["Session_ActiveLanguage"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            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;
            LoadStrings(ci);
        }
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        // Set UserRights
        UserRights();
    }
    #endregion
    #region ButtonEvents
    // Add Button - Click Event
    protected void btn_add_Click(object sender, EventArgs e)
    {
        // Redirects the Page to the Payroll Process Add Page 
        Response.Redirect("TA_UI_Transactions_MonthClosureAdd.aspx");
    }
    #endregion
    #region UserDefinedFunctions
    // Getting Information from resource file and display it in label
    private void LoadStrings(CultureInfo ci)
    {
        lbl_Header.Text = rm.GetString("UserGroups_MonthClosure", ci);
        btn_add.Text = "&nbsp;" + rm.GetString("btn_Add", ci);
        grv_MonthClosure.Columns[1].Caption = rm.GetString("LevelDetails_LevelName", ci);
        grv_MonthClosure.Columns[2].Caption = rm.GetString("PayrollProcess_StartDate", ci);
        grv_MonthClosure.Columns[3].Caption = rm.GetString("PayrollProcess_EndDate", ci);
        grv_MonthClosure.Columns[4].Caption = rm.GetString("MonthClosure_Date", ci);
    }
    private void UserRights()
    {
        try
        {
            ds_Checkuser = objCheckUser.checkRights(27, Convert.ToInt32(Session["userGroup_Id"]), "");
            if (ds_Checkuser.Tables[0].Rows.Count > 0)
            {
                if (ds_Checkuser.Tables[0].Rows[0]["addPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["addPrv"]) == 1)
                {
                    this.btn_add.Visible = true;
                }
                else
                {
                    this.btn_add.Visible = false;
                }
                if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] != DBNull.Value && Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) == 1)
                {
                    this.grv_MonthClosure.Columns[5].Visible = true;
                }
                else
                {
                    this.grv_MonthClosure.Columns[5].Visible = false;
                }              
            }
            else
            {
                Response.Redirect("TransactionLandingPage.aspx");
            }
        }
        catch
        {
            //
        }
    }
    #endregion
    #region GridviewEvents
    protected void grv_MonthClosure_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridViewTableRowEventArgs e)
    {
        if (e.RowType == GridViewRowType.Data)
        {
            //string lbl = Convert.ToString(e.GetValue("MonthClosure_StartDate"));
            //if (lbl != "")
            //{
            //    lbl = (Convert.ToDateTime(lbl)).ToString(Session["MDateFormat"].ToString());
            //    e.Row.Cells[1].Text = lbl;
            //}
            //string lbl1 = Convert.ToString(e.GetValue("MonthClosure_EndDate"));
            //if (lbl1 != "")
            //{
            //    lbl1 = (Convert.ToDateTime(lbl1)).ToString(Session["MDateFormat"].ToString());
            //    e.Row.Cells[2].Text = lbl1;
            //}
            //string lbl2 = Convert.ToString(e.GetValue("MonthClosure_ClosingDate"));
            //if (lbl2 != "")
            //{
            //    lbl2 = (Convert.ToDateTime(lbl2)).ToString(Session["MDateFormat"].ToString());
            //    e.Row.Cells[3].Text = lbl2;
            //}
        }
    }
    #endregion
}
