using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MySql.Data.MySqlClient;
using System.Configuration;
using System.Web.Services;
using Newtonsoft.Json;
using System.Web.Script.Serialization;
public partial class module_incomeprint : System.Web.UI.Page
{
    public static string constring = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    public static MySqlConnection con = new MySqlConnection(constring);
    public static DateTime date1; public static DateTime date2;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]

    public static object GetData(string reptsids)
    {
        string data = " ";
       
        using (MySqlConnection con = new MySqlConnection(constring))
        {
            using (MySqlCommand cmd = new MySqlCommand("select  incomeentry.*,incomasters.incomes as incname,date_format(incomeentry.paydate,'%d-%m-%Y') as recptdate,class_master.class as clsname,academic_year.fromdate,academic_year.todate,division_master.division as divsname,semistertbl.semnos as semisternm,student_detail.title as stitles,student_detail.fname,student_detail.mname,student_detail.lname,incomeentry.studid as incstudid from incomeentry left join incomasters on  incomeentry.incomeheads = incomasters.id left join class_master on incomeentry.classes = class_master.id left join academic_year on incomeentry.yreasid = academic_year.id  left join division_master on incomeentry.divsid =  division_master.id left join semistertbl on incomeentry.semids = semistertbl.id left join student_detail on incomeentry.studid = student_detail.studid where incomeentry.recptnos = '" + reptsids + "' GROUP BY incomeentry.id order by incomeentry.id desc", con))
            {
                if (con.State != ConnectionState.Open) { con.Open(); }
                DataTable dt = new DataTable();
                using (MySqlDataAdapter da = new MySqlDataAdapter(cmd))
                {
                    da.Fill(dt); con.Close();
                    if (dt.Rows.Count > 0)
                    {
                        data = JsonConvert.SerializeObject(dt);
                    }


                }
            }
        }
        return data;
    }
}