<asp:GridView ID="grdvCommonCore" runat="server" AutoGenerateColumns="False"
OnRowDataBound="grdvCommonCore_RowDataBound"
Width="100%" AllowPaging="True" PageSize="5">
<AlternatingRowStyle CssClass="GridAltRowStyle" />
<Columns>
<asp:TemplateField HeaderText="Course Name,AU Value and Department">
<ItemTemplate>
<asp:GridView ID="grdvCommonCoreCourses" runat="server"
OnRowDataBound="grdvCommonCoreCourses_RowDataBound"
AllowPaging="true" PageSize="10" AutoGenerateColumns="False"
Width="100%" OnPageIndexChanging="grdvCommonCoreCourses_PageIndexChanging"
OnRowCommand="grdvCommonCoreCourses_RowCommand">
<HeaderStyle CssClass="GridHeaderStyle" />
<RowStyle CssClass="GridRowStyle" />
<AlternatingRowStyle CssClass="GridAltRowStyle" />
<Columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server"
ImageUrl="~/images/Cross.png" /></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField Visible="False">
<ItemTemplate>
<asp:Label ID="lblCommonCoreCoursesId" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Course Name">
<ItemTemplate>
<asp:Label ID="lblCommonCoreCourses" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AU Value">
<ItemTemplate>
<asp:Label ID="lblCommonCoreAUvalue" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Department Name">
<ItemTemplate>
<asp:Label ID="lblCommonCoreDepeartment" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="No Of Compulsory Courses">
<ItemTemplate>
<asp:Label ID="lblCommonCoreCoursesNo" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total AU Value">
<ItemTemplate>
<asp:Label ID="lblCommonCoreAUValue" runat="server"></asp:Label></ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No Course Found</EmptyDataTemplate>
<HeaderStyle CssClass="GridHeaderStyle" />
<RowStyle CssClass="GridRowStyle" />
</asp:GridView>
C# Coding Section:
public void ShowProgram()
{
IEnumerable<LINQ.ProgramRequirementMap> objCommonCoreProgramRequirementMap = BLL.ProgramRequirementMap.GetProgramRequirementByProgramId
(Convert.ToInt32(hdnProgramId.Value), Constants.ProgramConstrainType.CommonCore.ToString());
if (objCommonCoreProgramRequirementMap.Count() > 0)
grdvCommonCore.DataSource = objCommonCoreProgramRequirementMap;
else
grdvCommonCore.DataSource = null;
grdvCommonCore.DataBind();
}
protected void grdvCommonCore_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView grdvCommonCoreCourses = (GridView)e.Row.FindControl("grdvCommonCoreCourses");
Label lblCommonCoreCoursesNo = (Label)e.Row.FindControl("lblCommonCoreCoursesNo");
Label lblCommonCoreAUValue = (Label)e.Row.FindControl("lblCommonCoreAUValue");
List<LINQ.CourseProgramRequirementMap> objCommonCoreProgramRequirementMap = BLL.CourseProgramRequirementMap.GetCoursesAccordingRequirement
((Convert.ToInt32(hdnProgramId.Value)), Constants.ProgramConstrainType.CommonCore.ToString());
if (grdvCommonCoreCourses != null)
{
if (objCommonCoreProgramRequirementMap.Count() > 0)
{
hdvCommonCompulsoryNo.Value = objCommonCoreProgramRequirementMap.Count().ToString();
ShowCommonCourses(grdvCommonCoreCourses);
}
}
if (lblCommonCoreCoursesNo != null)
lblCommonCoreCoursesNo.Text = objCommonCoreProgramRequirementMap.Count() + " Of " + objCommonCoreProgramRequirementMap.Count();
if (lblCommonCoreAUValue != null)
lblCommonCoreAUValue.Text = doubleCommonCoreAUValue.ToString();
}
}
public void ShowCommonCourses(GridView grdvCommonCoreCourses)
{
List<LINQ.CourseProgramRequirementMap> objCommonCoreProgramRequirementMap = BLL.CourseProgramRequirementMap.GetCoursesAccordingRequirement
((Convert.ToInt32(hdnProgramId.Value)), Constants.ProgramConstrainType.CommonCore.ToString());
if (objCommonCoreProgramRequirementMap.Count() > 0)
{
grdvCommonCoreCourses.DataSource = objCommonCoreProgramRequirementMap;
}
else
{
grdvCommonCoreCourses.DataSource = null;
}
doubleCommonCoreAUValue = 0.0;
grdvCommonCoreCourses.DataBind();
}
protected void grdvCommonCoreCourses_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete");
Label lblCommonCoreCoursesId = (Label)e.Row.FindControl("lblCommonCoreCoursesId");
Label lblCommonCoreCourses = (Label)e.Row.FindControl("lblCommonCoreCourses");
Label lblCommonCoreAUvalue = (Label)e.Row.FindControl("lblCommonCoreAUvalue");
Label lblCommonCoreDepeartment = (Label)e.Row.FindControl("lblCommonCoreDepeartment");
if (imgDelete != null)
{
imgDelete.CommandName = "DeleteCourse";
imgDelete.CommandArgument = ((LINQ.CourseProgramRequirementMap)e.Row.DataItem).CourseId.ToString();
imgDelete.OnClientClick = "return confirm('Are you sure you want to delete the Course from program?It will effect all the programs.');";
}
if (lblCommonCoreCoursesId != null)
lblCommonCoreCoursesId.Text = ((LINQ.CourseProgramRequirementMap)e.Row.DataItem).CourseId.ToString();
if (lblCommonCoreCourses != null)
lblCommonCoreCourses.Text = ((LINQ.CourseProgramRequirementMap)e.Row.DataItem).Course.Abbreviation;
if (lblCommonCoreAUvalue != null)
{
lblCommonCoreAUvalue.Text = BLL.CourseCategoryMap.getAuValue(Convert.ToInt32(lblCommonCoreCoursesId.Text));
doubleCommonCoreAUValue = doubleCommonCoreAUValue + Convert.ToDouble(lblCommonCoreAUvalue.Text.Trim());
}
if (lblCommonCoreDepeartment != null)
lblCommonCoreDepeartment.Text = ((LINQ.CourseProgramRequirementMap)e.Row.DataItem).Course.CourseAbbreviation.Department.DepartmentName;
}
}
protected void grdvCommonCoreCourses_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView grdvCommonCoreCourses = null;
foreach (GridViewRow row in grdvCommonCore.Rows)
{
grdvCommonCoreCourses = (GridView)(row.Cells[0].FindControl("grdvCommonCoreCourses"));
}
grdvCommonCoreCourses.PageIndex = e.NewPageIndex;
ShowCommonCourses(grdvCommonCoreCourses);
tabProgramInfo.ActiveTabIndex = 1;
}
protected void grdvCommonCoreCourses_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("DeleteCourse"))
{
BLL.ProgramRequirement.Delete(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(hdnProgramId.Value),
BLL.Constants.ProgramConstrainType.CommonCore.ToString());
ShowProgram();
}
}
No comments:
Post a Comment