using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
/****************************************************************************************************************************
* Project Name    : TimeCheck                                         Started Date  : 12-Aug-2007
* Module          : Organisation Levels                               Last Modified : 19-July-2007
* Programmer      : Senthil Kumar NP
* Current Storage : \\Angler56\Projects\Inprogress\SCREEN1206\code\Time_AttendanceApp
* BackUp          :
****************************************************************************************************************************/
public partial class Masters_TA_UI_Master_LevelModify : Base.BasePage
{
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objCommon = new cls_Common();
    protected override void Page_Load(object sender, EventArgs e)
    {
        // session checking and reset date format
        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;
        try
        {
            if (!IsPostBack)
            {
                getLevelDetails();
                btn_save.OnClientClick = "if(Page_ClientValidate()) return confirm('" + rm.GetStream("Alert_ConfirmSave", ci) + "?');return false;";
                objCommon.menu("OrgSettings", "6");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex);
        }
    }
    protected void getLevelDetails()
    {
        org_levelsEventData selectLevel = new org_levelsEventData();
        DataSet dsLev = new DataSet();
        dsLev = selectLevel.selectLevelDetails(Convert.ToInt32(Session["orgLevelid"]), Convert.ToString(Session["UserGroupName"]), Convert.ToString(Session["LevelRights"]), Convert.ToInt32(Session["parentLevelId"]));
        if (dsLev.Tables[0].Rows.Count > 0)
        {
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["levelName"]) != ""))
            {
                this.lblHead.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["levelName"]) + " Details";
                this.txtLevelName.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["levelName"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["description"]) != ""))
            {
                this.txtDescription.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["description"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["city"]) != ""))
            {
                this.txtCity.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["city"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["state"]) != ""))
            {
                this.txtState.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["state"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["country"]) != ""))
            {
                this.txtCountry.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["country"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["zip"]) != ""))
            {
                this.txtZip.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["zip"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["phone1"]) != ""))
            {
                this.txtPhone1.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["phone1"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["phone2"]) != ""))
            {
                this.txtPhone2.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["phone2"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["fax1"]) != ""))
            {
                this.txtFax.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["fax1"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["fax2"]) != ""))
            {
                this.txtMobile.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["fax2"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["email"]) != ""))
            {
                this.txtEmail.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["email"]);
            }
            if ((Convert.ToString(dsLev.Tables[0].Rows[0]["webAddress"]) != ""))
            {
                this.txtWeb.Text = Convert.ToString(dsLev.Tables[0].Rows[0]["webAddress"]);
            }
        }
    }
    protected void btn_save_Click(object sender, EventArgs e)
    {
        org_levelsEventData lvModi = new org_levelsEventData();
        lvModi.ModifyLevel(Convert.ToInt32(Session["orgLevelid"]), this.txtLevelName.Text, this.txtDescription.Text, this.txtCity.Text, this.txtState.Text, this.txtCountry.Text, this.txtZip.Text, this.txtPhone1.Text, this.txtPhone2.Text, this.txtFax.Text, this.txtMobile.Text, this.txtEmail.Text, this.txtWeb.Text);
        int tid = Convert.ToInt32(Session["orgLevelid"]);
        Session["orgLevelid"] = null;
        Response.Redirect("TA_UI_Master_LevelDetails.aspx?tid=" + tid + "&sid=" + Session.SessionID);
    }
    protected void btn_cancel_Click(object sender, EventArgs e)
    {
        int tid = Convert.ToInt32(Session["orgLevelid"]);
        Session["orgLevelid"] = null;
        Response.Redirect("TA_UI_Master_LevelDetails.aspx?tid=" + tid + "&sid=" + Session.SessionID);
    }
}
