using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
public partial class System_Settings_SystemSetting_DatabaseInformation : System.Web.UI.Page
{
    #region VariableDeclaration
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    ResourceManager rm;
    DataSet dsDbInfo = new DataSet();
    ResetPwd objRs = new ResetPwd();
    cls_Common objClassCommon = new cls_Common();
    #endregion
    #region PageLoad
    protected void Page_Load(object sender, EventArgs e)
    {
        //Call to a function to implement the UserRights
        if (!IsPostBack)
        {
            objClassCommon.menu("Others", "109");
        }
        UserRights();
        loadDatabaseInfo();
        //get the culture info to set the language
        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;
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        LoadStrings(ci);       
    }
    #endregion
    #region UserDefinedFunctions
    private void loadDatabaseInfo()
    {
        dsDbInfo = objRs.DatabaseInformation();
        if (dsDbInfo.Tables.Count > 0)
        {
            if (dsDbInfo.Tables[0].Rows.Count > 0)
            {
                lblDBVersion.Text = Convert.ToString(dsDbInfo.Tables[0].Rows[0]["DatabaseVersionName"]);
                lblApplicationVersion.Text = Convert.ToString(dsDbInfo.Tables[0].Rows[0]["ApplicationVersionName"]);
            }
        }
        string strDecryptedConnectionString = string.Empty;
        strDecryptedConnectionString = Cryptographys.Cryptography.GetDecryptedConnectionString();
        string[] strDBInfo = strDecryptedConnectionString.Split(';');
        string[] strDBServer = strDBInfo[0].Split('=');
        lblServerNameData.Text = Convert.ToString(strDBServer[1]);
        string[] strDBName = strDBInfo[1].Split('=');
        lblDBNameData.Text = Convert.ToString(strDBName[1]);
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(109, 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("SystemLandingPage.aspx");
            }
        }
        else
        {
            Response.Redirect("SystemLandingPage.aspx");
        }
    }
    private void LoadStrings(CultureInfo ci)
    {
        lbl_Header.Text = rm.GetString("System_DatabaseInformation", ci);
        lblServerName.Text = rm.GetString("Server_Name", ci);
        lblDatabaseName.Text = rm.GetString("DBDatabaseName", ci);
        lblVersionName.Text = rm.GetString("VersionName", ci);
        lblApplicationVersionName.Text = rm.GetString("ApplicationVersionName", ci);
    }
    #endregion
}