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_EmailSchedule_GetWeekMonthData : Base.BasePage
{
    int Frequency = 0;
    string DayFrom = "";
    string DayTo = "";
    int Prev_DateFrom = 0;
    int Prev_DateTo = 0;
    ResourceManager rm;
    CultureInfo ci;
    string ConcatenateString = string.Empty;
    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 (Request.QueryString["Frequency"] != null && Request.QueryString["Frequency"] != "")
        {
            Frequency = Convert.ToInt32(Request.QueryString["Frequency"]);
        }
        if (Request.QueryString["DayFrom"] != null && Request.QueryString["DayFrom"] != "")
        {
            DayFrom = Convert.ToString(Request.QueryString["DayFrom"]);
        }
        if (Request.QueryString["DayTo"] != null && Request.QueryString["DayTo"] != "")
        {
            DayTo = Convert.ToString(Request.QueryString["DayTo"]);
        }
        if (Request.QueryString["Prev_DateFrom"] != null && Request.QueryString["Prev_DateFrom"] != "")
        {
            Prev_DateFrom = Convert.ToInt32(Request.QueryString["Prev_DateFrom"]);
        }
        if (Request.QueryString["Prev_DateTo"] != null && Request.QueryString["Prev_DateTo"] != "")
        {
            Prev_DateTo = Convert.ToInt32(Request.QueryString["Prev_DateTo"]);
        }
        getValue(Frequency, DayFrom, DayTo, Prev_DateFrom, Prev_DateTo);
    }
    private void getValue(int Frequency, string DayFrom, string DayTo, int DateFrom, int DateTo)
    {
        EmailConfiguration getEmailData = new EmailConfiguration();
        DataSet ds = new DataSet();
        ds = getEmailData.GetSampleWeekDays(Frequency, DayFrom, DayTo, Prev_DateFrom, Prev_DateTo);
        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Fromdate"] != DBNull.Value)
                {
                    ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Fromdate"]);
                }
                if (ds.Tables[0].Rows[0]["Todate"] != DBNull.Value)
                {
                    ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["Todate"]);
                }
                if (ds.Tables[0].Rows[0]["frequency"] != DBNull.Value)
                {
                    ConcatenateString += "$" + Convert.ToString(ds.Tables[0].Rows[0]["frequency"]);
                }
            }
            else
            {
                Response.Clear();
                Response.Write("Fail");
                Response.End();
            }
        }
        else
        {
            Response.Clear();
            Response.Write("Fail");
            Response.End();
        }
        Response.Write(ConcatenateString);
        Response.End();
    }
}
