<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Masters.aspx.cs" MasterPageFile="~/MasterPage.Master"
Inherits="KrishiCardPortal.Report1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script language="javascript" type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "inline";
img.src = "../Images/minus.png"
}
else {
div.style.display = "none";
img.src = "../Images/plus.png"
}
}
</script>
<link href="../Style.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<div id="sidebar" style="float: left">
<div id="vertialmenu">
<ul>
<li><a href="Reports.aspx">
<asp:ImageButton ID="ImageButton1" Style="position: relative; vertical-align: middle;"
ImageUrl="~/Images/right_round.png" runat="server" /> <span>Search</span></a></li>
<li><a href="Masters.aspx">
<asp:ImageButton ID="ImageButton2" Style="position: relative; vertical-align: middle;"
ImageUrl="~/Images/right_round.png" runat="server" /> <span>Masters</span></a></li>
<li><a href='FamilyMembers.aspx'>
<asp:ImageButton ID="ImageButton3" Style="position: relative; vertical-align: middle;"
ImageUrl="~/Images/right_round.png" runat="server" /> <span>Family Members</span></a></li>
<li><a href='FarmerType.aspx'>
<asp:ImageButton ID="ImageButton4" Style="position: relative; vertical-align: middle;"
ImageUrl="~/Images/right_round.png" runat="server" /> <span>Farmer Type</span></a></li>
<li><a href="BankDetails.aspx">
<asp:ImageButton ID="ImageButton5" Style="position: relative; vertical-align: middle;"
ImageUrl="~/Images/right_round.png" runat="server" /> <span>Bank Deatils</span></a></li>
</ul>
</div>
</div>
<div style="margin-left: 160px; margin-top: 50px" align="center">
<asp:GridView ID="gvParentGrid" runat="server" CellPadding="3" EnableModelValidation="True"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
DataKeyNames="dist_no" OnRowDataBound="gvParentGrid_RowDataBound">
<AlternatingRowStyle BackColor="white" ForeColor="#284775" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("dist_no") %>');">
<img id="imgdiv<%# Eval("dist_no") %>" width="12px" border="0" src="../Images/plus.png"
alt="*" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="District" DataField="dist_name" />
<asp:BoundField HeaderText="Mandals" DataField="mandals_count" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("dist_no") %>" style="display: none; position: relative; left: 12px; overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" CellPadding="2"
GridLines="None" OnRowDataBound="gvChildGrid_RowDataBound" DataKeyNames="dist_no,mand_no">
<HeaderStyle BackColor="#2680a2" Font-Bold="true" ForeColor="White"/>
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="white" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"))%>');">
<img id="imgdiv<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"))%>" width="12px"
border="0" src="../Images/plus.png" alt="*" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Mandal" DataField="mand_name" />
<asp:BoundField HeaderText="Panchayats" DataField="panchayats_count" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"))%>" style="display: none;
position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvChildGridPanch" runat="server" AutoGenerateColumns="false" BorderColor="#df5015"
CellPadding="2" GridLines="None" DataKeyNames="dist_no,mand_no,Panchayat_no"
OnRowDataBound="gvChildGridPanch_RowDataBound">
<HeaderStyle BackColor="#2680a2" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="white" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"),"", Eval("Panchayat_no"))%>');">
<img id="imgdiv<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"),"", Eval("Panchayat_no"))%>"
width="12px" border="0" src="../Images/plus.png" alt="*" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Panchyat" DataField="panchyat_name" />
<asp:BoundField HeaderText="Total Enrolments" DataField="enrolments_count" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# string.Concat(Eval("dist_no"), "", Eval("mand_no"),"", Eval("Panchayat_no"))%>"
style="display: none; position: relative; left: 15px; overflow: auto;" align="center">
<asp:GridView ID="gvChildGridPanch" runat="server" AutoGenerateColumns="false" BorderColor="#df5015"
CellPadding="2" GridLines="None">
<HeaderStyle BackColor="#2680a2" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="white" />
<Columns>
<asp:BoundField HeaderText="Kisan Card No" DataField="kissan_card_no" />
<asp:BoundField HeaderText="Kisan Name" DataField="kisanname" />
</Columns>
<%--<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" ForeColor="White" Font-Bold="True" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="LightGoldenrodYellow" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />--%>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<%--<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" ForeColor="White" Font-Bold="True" />
<HeaderStyle BackColor="#2580A2 " Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />--%>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<%--<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" ForeColor="White" Font-Bold="True" />
<HeaderStyle BackColor="#9999" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />--%>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="center" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
<br />
<br />
</div>
<div>
</div>
</asp:Content>
===================================================================
Code Behind:
==========
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql;
using MySql.Data.MySqlClient;
using MySql.Data;
using System.Data;
using System.Configuration;
namespace KrishiCardPortal
{
public partial class Report1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
MySqlCommand cmd = new MySqlCommand("P_Get_Reports_Masters", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Session["allresult"] = ds;
con.Close();
gvParentGrid.DataSource = ds.Tables[0];
gvParentGrid.DataBind();
}
protected void gvParentGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv = (GridView)e.Row.FindControl("gvChildGrid");
int DistId = Convert.ToInt32(gvParentGrid.DataKeys[e.Row.RowIndex].Value);
DataSet ds = (DataSet)Session["allresult"];
ds.Tables[1].DefaultView.RowFilter = "dist_no='" + DistId + "'";
gv.DataSource = ds.Tables[1];
gv.DataBind();
}
}
protected void gvChildGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv = (GridView)sender;
GridView gv1 = (GridView)e.Row.FindControl("gvChildGridPanch");
int distno = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Values["dist_no"]);
int mandno = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Values["mand_no"]);
DataSet ds = (DataSet)Session["allresult"];
ds.Tables[2].DefaultView.RowFilter = "dist_no = " + distno + " AND mand_no = " + mandno + "";
gv1.DataSource = ds.Tables[2];
gv1.DataBind();
}
}
protected void gvChildGridPanch_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv = (GridView)sender;
GridView gv1 = (GridView)e.Row.FindControl("gvChildGridPanch");
int distno = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Values["dist_no"]);
int mandno = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Values["mand_no"]);
int panchno = Convert.ToInt32(gv.DataKeys[e.Row.RowIndex].Values["Panchayat_no"]);
DataSet ds = (DataSet)Session["allresult"];
ds.Tables[3].DefaultView.RowFilter = "dist_no = " + distno + " AND mand_no = " + mandno + " AND Panchayat_no = " + panchno + "";
gv1.DataSource = ds.Tables[3];
gv1.DataBind();
}
}
}
}
=====================================================================
DELIMITER $$
DROP PROCEDURE IF EXISTS `krishicard`.`P
CREATE DEFINER=`root`@
BEGIN
-- geting district wise mandals count --
select dm.dist_no,
dm.dist_name,
count(mm.mand_n
inner join dist_mst dm on dm.dist_no=mm.d
-- geting mandal wise panchayats count --
select pm.dist_no,
pm.mand_no,
mm.mand_name,
count(pm.panchy
inner join mand_mst mm on mm.mand_no=pm.m
group by pm.dist_no,pm.m
-- geting panchayat wise enrolments count --
select ki.dist_no,
ki.mand_no,
ki.panchayat_no
pm.panchyat_nam
count(ki.refere
inner join panchyat_mst pm on ki.panchayat_no
group by ki.dist_no,ki.m
-- geting kisancardno,nam
select dist_no,
mand_no,
panchayat_no,
kissan_card_no,
kisanname from kisan_informati
END$$
DELIMITER ;
====================================================================
No comments:
Post a Comment