[WebMethod(Description = "Webservice for generating category wise report in JSON form")] public string getCategoryWiseReport(string district) { string dist = "23"; district = dist; var con = new SqlConnection("data source=xxxxxx;initial catalog=xxxxxxx;integrated security=true"); StringBuilder JSON = new StringBuilder(); con.Open(); var cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "ReportSummery"; cmd.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable(); SqlDataAdapter ad = new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue("@district", district); cmd.ExecuteNonQuery(); ad.Fill(dt); //string ofc_code=dt.Rows[0][0].ToString(); //string ofc_desg = dt.Rows[0][1].ToString(); //string ofc_name = dt.Rows[0][2].ToString(); //string dep_name = dt.Rows[0][3].ToString(); //string total_comp = dt.Rows[0][4].ToString(); //string pending = dt.Rows[0][5].ToString(); //string desposed = dt.Rows[0][6].ToString(); //string interim = dt.Rows[0][7].ToString(); //string defaulter = dt.Rows[0][8].ToString(); JSON.Append("{"); JSON.Append("\"Report\":["); for (int i = 0; i <= (dt.Rows.Count - 1); i++) { for (int j = 0; j <= 8; j++) { JSON.Append("{"); JSON.Append("\"ofc_code\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"ofc_desg\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"ofc_name\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"dep_name\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"Total_complaint_recieved\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"Total_complaint_disposed\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"Total_complaint_pending\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"Total_complaint_interim\":\"" + dt.Rows[i][j].ToString() + "\", "); JSON.Append("\"Total_complaint_default\":\"" + dt.Rows[i][j].ToString() + "\", "); } if (JSON.ToString().EndsWith(",")) { JSON = JSON.Remove(JSON.Length - 1, 1); } JSON.Append("]}"); } con.Close(); return JSON.ToString(); //string s=ofc_code+","+ofc_desg+","+ofc_name+","+dep_name+","+total_comp+","+pending+","+desposed+","+interim+","+defaulter; //return s; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)