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.Resources;
using System.Globalization;
using System.Threading;
public partial class Masters_TA_UI_Master_NoDaysDeduction_Configuration : Base.BasePage
{
    PayrollConfiguration_Angler objpayroll = new PayrollConfiguration_Angler();
    ResourceManager rm;
    CultureInfo ci;
    cls_Common objClassCommon = new cls_Common();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    DataSet ds_Checkuser = new DataSet();
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        //Set UserRights
        // UserRights();
        site.SiteMapProvider = Convert.ToString(Session["SiteMapProvider"]);
        if (!Page.IsPostBack)
        {
            objClassCommon.menu("Configuration", "185");
            hdfLateEntry.Value = Convert.ToString(Session["ITimeFormat"]);
            LoadConfigurationDetails();
        }
        //string source_Language;
        //source_Language = Session["Session_ActiveLanguage"].ToString();
        //rm = new ResourceManager(source_Language, System.Reflection.Assembly.Load("App_GlobalResources"));
        //ci = Thread.CurrentThread.CurrentCulture;
        //LoadStrings(ci);
    }
    private void LoadStrings(CultureInfo ci)
    {
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
            int ArmisSettingId, LateEntrySettingId, WorkHoursSettingId = 0;
            LateEntrySettingId = objpayroll.InsertPayrollConfiguration_LateEntry(Convert.ToInt16(TimeSpan.Parse(TxtLateIN1.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN2.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue1.Text),
              Convert.ToInt16(TimeSpan.Parse(TxtLateIN3.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN4.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue2.Text), Convert.ToInt16(TimeSpan.Parse(TxtLateIN5.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN6.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue3.Text),
              Convert.ToInt16(TimeSpan.Parse(TxtLateIN7.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN8.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue4.Text), Convert.ToInt16(TimeSpan.Parse(TxtLateIN9.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN10.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue5.Text),
              Convert.ToInt16(TimeSpan.Parse(TxtLateIN11.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtLateIN12.Text).TotalMinutes), Convert.ToDecimal(TxtLateInValue6.Text));
            // Armis table detail not included while saving the operation., dont consider it.
            ArmisSettingId = objpayroll.InsertPayrollConfiguration_Armis(Convert.ToInt16(TimeSpan.Parse(TxtArmis1.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtArmis2.Text).TotalMinutes), Convert.ToDecimal(TxtArmisValue1.Text),
                   Convert.ToInt16(TimeSpan.Parse(TxtArmis3.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtArmis4.Text).TotalMinutes), Convert.ToDecimal(TxtArmisValue2.Text), Convert.ToInt16(TimeSpan.Parse(TxtArmis5.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtArmis6.Text).TotalMinutes), Convert.ToDecimal(TxtArmisValue3.Text),
                   Convert.ToInt16(TimeSpan.Parse(TxtArmis7.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtArmis8.Text).TotalMinutes), Convert.ToDecimal(TxtArmisValue4.Text), Convert.ToInt16(TimeSpan.Parse(TxtArmis9.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtArmis10.Text).TotalMinutes), Convert.ToDecimal(TxtArmisValue5.Text));
            WorkHoursSettingId = objpayroll.InsertPayrollConfiguration_WorkHours(Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs1.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs2.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue1.Text),
                Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs3.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs4.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue2.Text), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs5.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs6.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue3.Text),
                Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs7.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs8.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue4.Text), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs9.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs10.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue5.Text),
                Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs11.Text).TotalMinutes), Convert.ToInt16(TimeSpan.Parse(TxtWorkHrs12.Text).TotalMinutes), Convert.ToDecimal(TxtWorkHrsValue6.Text));
            if (LateEntrySettingId != 0 && ArmisSettingId != 0 && LateEntrySettingId != 0)
            {
                string str = "alert('Armis, LateEntry, WorkHours deduction days configuration saved successfully.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
            }
            else
            {
                string str = "alert('Error on saving the configuration settings.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alertBox", str, true);
            }
        }
    }
    protected void LoadConfigurationDetails()
    {
        DataSet ds = new DataSet();
        ds = objpayroll.GetConfigurationDetails();
        if (ds.Tables[0].Rows.Count > 0)
        {
            TxtLateIN1.Text = ds.Tables[0].Rows[0]["StartTime1"].ToString();
            TxtLateIN2.Text = ds.Tables[0].Rows[0]["EndTime1"].ToString();
            TxtLateInValue1.Text = ds.Tables[0].Rows[0]["Day1"].ToString();
            TxtLateIN3.Text = ds.Tables[0].Rows[0]["StartTime2"].ToString();
            TxtLateIN4.Text = ds.Tables[0].Rows[0]["EndTime2"].ToString();
            TxtLateInValue2.Text = ds.Tables[0].Rows[0]["Day2"].ToString();
            TxtLateIN5.Text = ds.Tables[0].Rows[0]["StartTime3"].ToString();
            TxtLateIN6.Text = ds.Tables[0].Rows[0]["EndTime3"].ToString();
            TxtLateInValue3.Text = ds.Tables[0].Rows[0]["Day3"].ToString();
            TxtLateIN7.Text = ds.Tables[0].Rows[0]["StartTime4"].ToString();
            TxtLateIN8.Text = ds.Tables[0].Rows[0]["EndTime4"].ToString();
            TxtLateInValue4.Text = ds.Tables[0].Rows[0]["Day4"].ToString();
            TxtLateIN9.Text = ds.Tables[0].Rows[0]["StartTime5"].ToString();
            TxtLateIN10.Text = ds.Tables[0].Rows[0]["EndTime5"].ToString();
            TxtLateInValue5.Text = ds.Tables[0].Rows[0]["Day5"].ToString();
            TxtLateIN11.Text = ds.Tables[0].Rows[0]["StartTime6"].ToString();
            TxtLateIN12.Text = ds.Tables[0].Rows[0]["EndTime6"].ToString();
            TxtLateInValue6.Text = ds.Tables[0].Rows[0]["Day6"].ToString();
        }
        if (ds.Tables[1].Rows.Count > 0)
        {
            TxtArmis1.Text = ds.Tables[1].Rows[0]["StartTime1"].ToString();
            TxtArmis2.Text = ds.Tables[1].Rows[0]["EndTime1"].ToString();
            TxtArmisValue1.Text = ds.Tables[1].Rows[0]["Day1"].ToString();
            TxtArmis3.Text = ds.Tables[1].Rows[0]["StartTime2"].ToString();
            TxtArmis4.Text = ds.Tables[1].Rows[0]["EndTime2"].ToString();
            TxtArmisValue2.Text = ds.Tables[1].Rows[0]["Day2"].ToString();
            TxtArmis5.Text = ds.Tables[1].Rows[0]["StartTime3"].ToString();
            TxtArmis6.Text = ds.Tables[1].Rows[0]["EndTime3"].ToString();
            TxtArmisValue3.Text = ds.Tables[1].Rows[0]["Day3"].ToString();
            TxtArmis7.Text = ds.Tables[1].Rows[0]["StartTime4"].ToString();
            TxtArmis8.Text = ds.Tables[1].Rows[0]["EndTime4"].ToString();
            TxtArmisValue4.Text = ds.Tables[1].Rows[0]["Day4"].ToString();
            TxtArmis9.Text = ds.Tables[1].Rows[0]["StartTime5"].ToString();
            TxtArmis10.Text = ds.Tables[1].Rows[0]["EndTime5"].ToString();
            TxtArmisValue5.Text = ds.Tables[1].Rows[0]["Day5"].ToString();
        }
        if (ds.Tables[2].Rows.Count > 0)
        {
            TxtWorkHrs1.Text = ds.Tables[2].Rows[0]["StartTime1"].ToString();
            TxtWorkHrs2.Text = ds.Tables[2].Rows[0]["EndTime1"].ToString();
            TxtWorkHrsValue1.Text = ds.Tables[2].Rows[0]["Day1"].ToString();
            TxtWorkHrs3.Text = ds.Tables[2].Rows[0]["StartTime2"].ToString();
            TxtWorkHrs4.Text = ds.Tables[2].Rows[0]["EndTime2"].ToString();
            TxtWorkHrsValue2.Text = ds.Tables[2].Rows[0]["Day2"].ToString();
            TxtWorkHrs5.Text = ds.Tables[2].Rows[0]["StartTime3"].ToString();
            TxtWorkHrs6.Text = ds.Tables[2].Rows[0]["EndTime3"].ToString();
            TxtWorkHrsValue3.Text = ds.Tables[2].Rows[0]["Day3"].ToString();
            TxtWorkHrs7.Text = ds.Tables[2].Rows[0]["StartTime4"].ToString();
            TxtWorkHrs8.Text = ds.Tables[2].Rows[0]["EndTime4"].ToString();
            TxtWorkHrsValue4.Text = ds.Tables[2].Rows[0]["Day4"].ToString();
            TxtWorkHrs9.Text = ds.Tables[2].Rows[0]["StartTime5"].ToString();
            TxtWorkHrs10.Text = ds.Tables[2].Rows[0]["EndTime5"].ToString();
            TxtWorkHrsValue5.Text = ds.Tables[2].Rows[0]["Day5"].ToString();
            TxtWorkHrs11.Text = ds.Tables[2].Rows[0]["StartTime6"].ToString();
            TxtWorkHrs12.Text = ds.Tables[2].Rows[0]["EndTime6"].ToString();
            TxtWorkHrsValue6.Text = ds.Tables[2].Rows[0]["Day6"].ToString();
        }
    }
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(185, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
        else
        {
            //   
        }
    }
}
