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_leavingcertificates : System.Web.UI.Page
{
    public static string constring = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    public static MySqlConnection con = new MySqlConnection(constring);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]

    public static object GetData(string certids)
    {
        string data = " ";

        using (MySqlConnection con = new MySqlConnection(constring))
        {
            using (MySqlCommand cmd = new MySqlCommand("SELECT inst.*,st.*,date_format(inst.issuedate,'%d-%m-%Y') as recptdate,yr.fromdate,yr.todate,class_master.class as clsname,division_master.division as divsnm,date_format(st.today,'%d-%m-%Y') as regdate,date_format(st.dob,'%d-%m-%Y') as dobdts,fee_category.feesname,date_format(inst.leavingdate,'%d-%m-%Y') as leavedt FROM add_certificates AS inst LEFT JOIN student_detail AS st ON inst.studids = st.id LEFT JOIN academic_year AS yr ON inst.yrsid = yr.id left join class_master ON inst.clsids  = class_master.id left join division_master on inst.divsid = division_master.id left join fee_category on st.castcategory = fee_category.id WHERE inst.id = '" + certids + "'", con))
            {
                if (con.State != ConnectionState.Open) { con.Open(); }
                DataSet ds = new DataSet();
                using (MySqlDataAdapter da = new MySqlDataAdapter(cmd))
                {
                    da.Fill(ds); con.Close();
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        data = JsonConvert.SerializeObject(ds.Tables[0]);
                    }


                }
            }
        }
        return data;
    }
}