using System;
using System.Data;
using System.Globalization;
using System.Resources;
using System.Threading;
public partial class Masters_PenaltyPercentage : Base.BasePage
{
    #region Global Variable Declaration
    int CompanyID;
    ResourceManager rm;
    CultureInfo ci;
    string ConcatenateString = string.Empty;
    DataSet ds_Checkuser = new DataSet();
    Cls_CheckUser objCheckUser = new Cls_CheckUser();
    #endregion
    #region Page Load Event
    protected override void Page_Load(object sender, EventArgs e)
    {
        GC.Collect();
        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 (!IsPostBack)
        {
            UserRights();
            if (Request.QueryString["CompanyID"] != null && Request.QueryString["CompanyID"] != "")
            {
                CompanyID = Convert.ToInt32(Request.QueryString["CompanyID"].ToString());
                GenerateControls(CompanyID);
            }
        }
    }
    #endregion
    private void UserRights()
    {
        ds_Checkuser = objCheckUser.checkRights(270, Convert.ToInt32(Session["userGroup_Id"]), "addPrv");
        if (ds_Checkuser.Tables[0].Rows.Count == 0)
        {
            Response.Redirect("MasterLandingPage.aspx");
        }
    }

    #region User Defined Functions
    protected void GenerateControls(int CompanyId)
    {
        CategoryEventData objcat = new CategoryEventData();
        DataSet ds = new DataSet();
        ds = objcat.GetPenaltyPercentageDetails(CompanyId);
        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        if (ds.Tables[0].Rows[0]["StartTime1"] != DBNull.Value)
                            ConcatenateString += Convert.ToString(ds.Tables[0].Rows[0]["StartTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["EndTime1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["EndTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["StartTime2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["StartTime2"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["EndTime2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["EndTime2"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["StartTime3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["StartTime3"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["EndTime3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["EndTime3"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[0]["Day1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day1"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day2"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day3"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day4"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day4"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day5"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day5"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day6"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day6"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day7"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day7"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day8"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day8"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day9"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day9"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day10"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day10"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day11"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day11"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[0]["Day12"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Day12"]);
                        else
                            ConcatenateString += "$0";
                    }
                    else if (i == 1)
                    {
                        if (ds.Tables[0].Rows[1]["StartTime1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["StartTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["EndTime1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["EndTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["StartTime2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["StartTime2"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["EndTime2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["EndTime2"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["StartTime3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["StartTime3"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["EndTime3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["EndTime3"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[1]["Day1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day1"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day2"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day3"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day4"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day4"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day5"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day5"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day6"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day6"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day7"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day7"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day8"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day8"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day9"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day9"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day10"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day10"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day11"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day11"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[1]["Day12"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[1]["Day12"]);
                        else
                            ConcatenateString += "$0";
                    }
                    else
                    {
                        if (ds.Tables[0].Rows[2]["StartTime1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["StartTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[2]["EndTime1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["EndTime1"]);
                        else
                            ConcatenateString += "$00:00";
                        if (ds.Tables[0].Rows[2]["Day1"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["Day1"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[2]["Day2"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["Day2"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[2]["Day3"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["Day3"]);
                        else
                            ConcatenateString += "$0";
                        if (ds.Tables[0].Rows[2]["Day4"] != DBNull.Value)
                            ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[2]["Day4"]);
                        else
                            ConcatenateString += "$0";
                    }
                }
            }
            else
            {
                Response.Clear();
                Response.Write("Fail");
                Response.End();
            }
        }
        else
        {
            Response.Clear();
            Response.Write("Fail");
            Response.End();
        }
        Response.Write(ConcatenateString);
        Response.End();
    }
    #endregion
}