using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class StudentAttendanceReport : System.Web.UI.Page
{
GeneralUtility OGu;
static int totalstudents;
string Sql;
GeneralUtility oGU;
DataTable oDt;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userID"] == null)
{
postAtParent();
}
else
{
totalstudent();
if (!IsPostBack)
{
string RoleID = Session["roleID"].ToString();
if (RoleID == "R00001")
{
SchoolBind();
lblMsg.Text = "";
trIn.Visible = false;
ddlbind();
}
else
{
orgrow.Visible = false;
SchoolBind();
lblMsg.Text = "";
trIn.Visible = false;
ddlbind();
ddlclassbind();
}
}
}
}
public void postAtParent()
{
string str = "";
str = "<script launguage=Javascript>";
str = str + "document.forms[0].target='_top';";
str = str + "document.forms[0].action='loginform.aspx';"; // url goes here
str = str + "document.forms[0].submit();";
str = str + "</script>";
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "assignToparent", str);
}
public void ddlclassbind()
{
oGU = new GeneralUtility();
oDt = new DataTable();
Sql = null;
string OrgID = Session["Org"].ToString();
if (Session["roleID"].ToString() == "R00001")
{
Sql = "Select DISTINCT Class From ACC_APP1_Student Where OrgID='" + ddlOrg.SelectedValue.ToString() + "' ORDER BY CLASS";
}
else
{
Sql = "Select DISTINCT Class From ACC_APP1_Student Where OrgID='" + OrgID + "' ORDER BY CLASS";
}
oDt = oGU.GetDataTable(Sql);
if (oDt.Rows.Count > 0)
{
ddlClass.DataSource = oDt;
ddlClass.DataTextField = "Class";
//ddlClass.DataValueField = "Class";
ddlClass.DataBind();
ddlClass.Items.Insert(0, "ALL");
}
}
public void ddlbind()
{
oGU = new GeneralUtility();
oDt = new DataTable();
Sql = "select * from OrganizationDetail order by OrgName";
oDt = oGU.GetDataTable(Sql);
ddlOrg.DataSource = oDt;
ddlOrg.DataTextField = "OrgName";
ddlOrg.DataValueField = "OrgID";
ddlOrg.DataBind();
ddlOrg.Items.Insert(0, "Select");
}
public void totalstudent()
{
oGU = new GeneralUtility();
oDt = new DataTable();
string ddclass = ddlClass.SelectedValue.ToString();
string RoleID = Session["roleID"].ToString();
if (RoleID == "R00001")
{
string ddorg = ddlOrg.SelectedValue.ToString();
Sql = null;
if (ddclass == "ALL")
Sql = " select * from dbo.ACC_APP1_Student where orgid='" + ddorg + "' ";
else
Sql = " select * from dbo.ACC_APP1_Student where orgid='" + ddorg + "' and class='" + ddclass + "' ";
oDt = oGU.GetDataTable(Sql);
totalstudents = oDt.Rows.Count;
}
else
{
string OrgID = Session["Org"].ToString();
Sql = null;
if (ddclass == "ALL")
Sql = " select * from dbo.ACC_APP1_Student where orgid='" + OrgID + "' ";
else
Sql = " select * from dbo.ACC_APP1_Student where orgid='" + OrgID + "' and class='" + ddclass + "' ";
oDt = oGU.GetDataTable(Sql);
totalstudents = oDt.Rows.Count;
}
}
public void SchoolBind()
{
// reqId = Session["Org"].ToString();
oGU = new GeneralUtility();
oDt = new DataTable();
string OrgID = Session["Org"].ToString();
string RoleID = Session["roleID"].ToString();
if (RoleID == "R00001")
{
ddlOrg.Visible = true;
Sql = "select OrgId, Orgname from OrganizationDetail ";
oDt = oGU.GetDataTable(Sql);
ddlOrg.DataSource = oDt;
ddlOrg.DataValueField = "OrgId";
ddlOrg.DataTextField = "Orgname";
ddlOrg.DataBind();
ddlOrg.Items.Insert(0, "Select");
}
else
{
// ddlOrg.Visible = false;
Sql = "select OrgId, Orgname from OrganizationDetail Where OrgID='" + OrgID + "'";
oDt = oGU.GetDataTable(Sql);
ddlOrg.DataSource = oDt;
ddlOrg.DataValueField = "OrgId";
ddlOrg.DataTextField = "Orgname";
ddlOrg.DataBind();
ddlOrg.Items.Insert(0, "Select");
}
}
int GetDaysInMonth(int month, int year)
{
if (month < 1 || month > 12)
{
throw new System.ArgumentOutOfRangeException("month", month, "month mustbe between 1 and 12");
}
if (1 == month || 3 == month || 5 == month || 7 == month || 8 == month ||
10 == month || 12 == month)
{
return 31;
}
else if (2 == month)
{
if (0 == (year % 4))
{
if (0 == (year % 400))
{
return 29;
}
else if (0 == (year % 100))
{
return 28;
}
return 29;
}
return 28;
}
return 30;
}
public void monthbind()
{
int days = GetDaysInMonth(Convert.ToInt32(ddlmonth.SelectedValue), Convert.ToInt32(DateTime.Now.Year));
DataTable myDT = new DataTable();
for (int i = 0; i < days; i++)
{
DataColumn id = new DataColumn("id");
id.ColumnName = id + i.ToString();
id.DataType = System.Type.GetType("System.Int32");
myDT.Columns.Add(id);
}
for (int i = 1; i <= 1; i++)
{
DataRow dr = myDT.NewRow();
for (int ii = 0; ii < days; ii++)
{
dr[ii] = ii.ToString();
}
myDT.Rows.Add(dr);
}
GridView1.DataSource = myDT;
GridView1.DataBind();
GridView1.Visible = true;
}
public void fillgrid()
{
GeneralUtility ogu=new GeneralUtility();
DataTable oDt = new DataTable();
SqlCommand cmd = new SqlCommand("select StudentID, Name from ACC_APP1_Student");
cmd.CommandType = CommandType.Text;
}
protected void ddlmonth_SelectedIndexChanged(object sender, EventArgs e)
{
monthbind();
}
protected void ddlOrg_SelectedIndexChanged(object sender, EventArgs e)
{
ddlclassbind();
}
protected void ddlClass_SelectedIndexChanged(object sender, EventArgs e)
{
ddlbind();
}
protected void btnInReport_Click(object sender, EventArgs e)
{
monthbind();
}
protected void btnImportToExcel_Click(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}