using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
using System.Web.UI;
using System.Web.UI.WebControls;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                        Started Date  : 12-Aug-2007
* Module          : Terminal Master                                  Last Modified : 14-Aug-2007
* Programmer      : 
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_TA_UI_Master_ProjectView : Base.BasePage
{
    #region "Variable Declaration"
    ResourceManager rm;
    CultureInfo ci;
    ProjectEventData objProjectEventData = new ProjectEventData();
    cls_Common objCommon = new cls_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    string Project_Id = "0";
    string gstrUserGroupName = string.Empty;
    #endregion
    #region PageLoad
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        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 (Session["UserGroupName"] != null)
        {
            gstrUserGroupName = Convert.ToString(Session["UserGroupName"]);
        }
        if (!IsPostBack)
        {
            LoadStrings(ci);
            loadcss();
            UserRights();
            if (Request.QueryString["Project_Id"] != null && Convert.ToString(Request.QueryString["Project_Id"]) != "")
            {
                Project_Id = Convert.ToString(Request.QueryString["Project_Id"]);
                LoadProjectDetails(Project_Id);
            }
        }
    }
    #endregion
    #region UserDefinedFunctions
    public void LoadProjectDetails(string ProjectId)
    {
        DataSet dsProject = new DataSet();
        dsProject = objProjectEventData.ViewProjectbyProjectId(Convert.ToInt32(ProjectId), Convert.ToInt32(Session["EmpAutoID"]));
        if (dsProject != null)
        {
            if (dsProject.Tables.Count > 0)
            {
                if (dsProject.Tables[0].Rows.Count > 0)
                {
                    lbl_ProjectCode1.Text = dsProject.Tables[0].Rows[0]["Project_Code"].ToString();
                    lbl_ProjectName1.Text = dsProject.Tables[0].Rows[0]["Project_Name"].ToString();
                    lbl_ClientName1.Text = dsProject.Tables[0].Rows[0]["Client_Name"].ToString();
                    lbl_ProjectDescription1.Text = dsProject.Tables[0].Rows[0]["Project_Description"].ToString();
                    lbl_Status1.Text = dsProject.Tables[0].Rows[0]["Project_Status"].ToString();
                    lbl_ProjectStartdate1.Text = dsProject.Tables[0].Rows[0]["Project_StartTime"].ToString();
                    lbl_ProjectEndDate1.Text = dsProject.Tables[0].Rows[0]["Project_EndTime"].ToString();
                    lblMandays.Text = dsProject.Tables[0].Rows[0]["Mandays"].ToString();
                    lblManHours.Text = dsProject.Tables[0].Rows[0]["ManHours"].ToString();
                    lblLevel.Text = dsProject.Tables[0].Rows[0]["LevelName"].ToString();
                }
                if (dsProject.Tables[1].Rows.Count > 0)
                {
                    gvTask.DataSource = dsProject.Tables[1];
                    gvTask.DataBind();
                }
            }

        }
    }
    private void LoadStrings(CultureInfo ci)
    {
        lbl_ProjectIdCode.Text = rm.GetString("Project_ProjectCode", ci);
        lbl_ProjectName.Text = rm.GetString("Project_Name", ci);
        lbl_ClientName.Text = rm.GetString("Project_ClientName", ci);
        lbl_ProjectDescription.Text = rm.GetString("Project_Description", ci);
        lbl_Status.Text = rm.GetString("Project_Status", ci);
        lbl_ProjectStartdate.Text = rm.GetString("Project_Startdate", ci);
        lbl_ProjectEndDate.Text = rm.GetString("Project_Enddate", ci);
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(283, Convert.ToInt32(Session["userGroup_Id"]), "");
        if (ds_Checkuser.Tables[0].Rows.Count > 0)
        {
            if (ds_Checkuser.Tables[0].Rows[0]["viewPrv"] == DBNull.Value || Convert.ToInt32(ds_Checkuser.Tables[0].Rows[0]["viewPrv"]) != 1)
            {
                Response.Redirect("TA_UI_Master_ProjectList.aspx");
            }
        }
        else
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }
    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;
        htmProject.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";
        }
        else
        {
            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";
        }
    }
    #endregion
}