using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Configuration;
using MySql.Data.MySqlClient;
using MySql.Data;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Data.SqlClient;//
using CLS_BL;
using CLS_DL;
using CLS_PL;

namespace SUNWEB.Services
{
    /// <summary>
    /// Summary description for chartservice
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]

    [System.Web.Script.Services.ScriptService]  
    public class chartservice : System.Web.Services.WebService
    {

        BL_SELECT ObjSel = new BL_SELECT();
        BLCompany ObjBL = new BLCompany();
        PLCOMMON ObjPL = new PLCOMMON();
        BL_USER ObjUserBL = new BL_USER(); //This Object for All User and Page Related fuctions included 
        PLCUSTOMER ObjCustPL = new PLCUSTOMER();
        Int32 K = 0;
        Int32 L = 0;
        string ConStr = ConfigurationManager.ConnectionStrings["ConMysql"].ConnectionString;
        string ConStr_Rds = ConfigurationManager.ConnectionStrings["ConRDS"].ConnectionString;
        string Curr_Date = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        string Curr_DateOnly = System.DateTime.Now.ToString("yyyy-MM-dd");
        string YearAlone = DateTime.Now.Year.ToString();
        string Monthid = DateTime.Now.Month.ToString();
        DateTime MonthstartDt;
        MYSQLDB ObjMain = new MYSQLDB();
        DataTable DT = new DataTable();
        DataTable Dt2 = new DataTable();
        DataTable DtLicense = new DataTable();
        DataTable Dtt = new DataTable();
        DataTable DtLinechart = new DataTable();
        DataTable ReadResult = new DataTable();
        string UserId = string.Empty;
        string UserName = string.Empty;
        string PortalTypeId = string.Empty;
        string cd_Id = string.Empty;
        string Datapath = string.Empty;
        string cd_BranchAlias = string.Empty;
        string IsMultiBranch = string.Empty;
        string IsSuperAdmin = string.Empty;
        string Cd_BranchName = string.Empty;
        string Rcd_id = string.Empty;
        string RPortalid = string.Empty;
        // License Variables ..
        string PID = string.Empty;
        string Page_Acess = string.Empty;
        string Read_Acess = string.Empty;
        string Write_Acess = string.Empty;
        string Isdowld_Acess = string.Empty;
        // GTotal Sale : Variables 
        decimal GotSaleAmt;
        decimal JanAmt;
        decimal JanGTot;
        decimal FebAmt;
        decimal FebGTot;
        decimal MarAmt;
        decimal MarGTot;
        decimal AprAmt;
        decimal AprGTot;
        decimal MayAmt;
        decimal MayGTot;
        decimal JuneAmt;
        decimal JunGTot;
        decimal JulAmt;
        decimal JulGTot;
        decimal AugAmt;
        decimal AugGTot;
        decimal SepAmt;
        decimal SepGTot;
        decimal OctAmt;
        decimal OctGTot;
        decimal NovAmt;
        decimal NovGTot;
        decimal DecAmt;
        decimal DecGTot;
        string MonthName;


        DataTable DtCSun = new DataTable();
        string RBranchid = string.Empty;
        string RBranchNam = string.Empty;
        string RData_Constring = string.Empty;
        // DashboardVariable ;
        decimal TotMonthlyAmt;
        decimal TotaCurrAmt;
        DataTable DTFinalSalesData = new DataTable();
        DataTable DTFinalSalesAmt = new DataTable();
        DataTable DtResult = new DataTable();
        DataTable Dtadd = new DataTable();
       

        public class ChartEntity
        {
            public string Month { get; set; }
            public int amount { get; set; }
            public Boolean drilldown { get; set; }
        }
         
         [System.Web.Services.WebMethod(EnableSession = true)]
        
        public  List<ChartEntity> GetTotAmtByMonth( )
        {
            List<ChartEntity> MonthwiseAmt = new List<ChartEntity>();
            DataSet ds = new DataSet();
            DataTable Dt = new DataTable();

             Dt =(DataTable)Session["DtResult"] ;
         
            
            if (Dt != null)
            {
                if (Dt.Rows.Count > 0)
                {
                    if (Dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr  in Dt.Rows)
                        {
                            MonthwiseAmt.Add(new ChartEntity
                            {
                                Month = dr["Month"].ToString(),
                                amount = Convert.ToInt32(dr["TotalsalesAmt"]),
                                drilldown = true
                            });
                        }
                    }
                }
            }
            return MonthwiseAmt;
        }

       

    }
}
