ASP.NET C# | Institute Management System Project Tutorial in HINDI | Part-08
How to create Institute Management System project in asp.net with source code
If you wish to learn further about Institute Management System Project, then I suggest you go through this interesting video...
Step-1: create a new page in BranchUser folder that name is " Batch_master "
_________________________________________________________________________________
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Batch_master.aspx.cs" Inherits="BranchUser_Batch_master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style4
{
width: 453px;
}
.style5
{
height: 6px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="501px">
<table width="100%">
<tr>
<td align="right" class="style5">
<hr />
<asp:Button ID="btnAddBatch" runat="server" CausesValidation="False" OnClick="btnAdd_Click"
Text="Add Batch" /><hr style="height: -12px" />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnSorting="GridView1_Sorting"
Style="text-align: center" Width="398px" DataKeyNames="batch_id">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="batch_name" HeaderText="Batch Name" SortExpression="batch_name" />
<asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit" Height="24px"
ImageUrl="~/Images/btnedit.png" Width="24px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete" Height="26px"
ImageUrl="~/Images/btndelete.png" Width="24px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<hr style="height: -12px" />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="495px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr style="height: -15px" />
Add Batch
<hr style="height: -15px" />
</td>
</tr>
<tr>
<td class="style4">
</td>
<td align="right" class="style7" style="color: #FF0000">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style4">
* Batch Name :
</td>
<td align="left">
<asp:TextBox ID="txtBatchName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtBatchName"
ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style4">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr style="height: -12px" />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClick="btnCancel_Click"
Text="Cancel" />
<hr style="height: -12px" />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
_________________________________________________________________________
Batch_master.aspx.cs ( Dynamic code )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Batch_master : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into batch_master (inst_login_id,branch_unique_id,batch_name,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtBatchName.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update batch_master set remarks = '" + txtRemarks.Text + "' where batch_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnAdd_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
lblStatus.Text = "Add Batch...";
bl_obj.ClearControls(View2);
txtBatchName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from batch_master where batch_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select * from batch_master where batch_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
txtBatchName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
#endregion
#region "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from batch_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from batch_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
txtBatchName.Text = Convert.ToString(dt_local.Rows[0]["batch_name"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
#endregion
}
____________________________________________________________________
Step: 2 create a new page that name is "Batch_Detail"
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Batch_Detail.aspx.cs" Inherits="BranchUser_Batch_Detail" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
}
.style3
{
width: 393px;
}
.style4
{
height: 10px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server"><asp:View ID="View1" runat="server">
<asp:Panel ID="Panel3" runat="server" Height="500px">
<table width="100%">
<tr>
<td align="right" class="style4"><hr />
<asp:Button ID="btnAddBatchDetail" runat="server" CausesValidation="False"
OnClick="btnAddBatchDetail_Click" Text="Add Batch Detail" /><hr />
</td>
</tr>
<tr>
<td align="center" width="100%">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="batch_detail_id"
OnPageIndexChanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="batch_name" HeaderText="Batch Name"
SortExpression="batch_name" />
<asp:BoundField DataField="day" HeaderText="Day" SortExpression="day" />
<asp:BoundField DataField="time_from_grid" HeaderText="From Time"
SortExpression="time_from_grid" />
<asp:BoundField DataField="time_to_grid" HeaderText="To Time"
SortExpression="time_to_grid" />
<asp:BoundField DataField="category_id" HeaderText="Course Category"
SortExpression="category_id" />
<asp:BoundField DataField="course_name" HeaderText="Course Name"
SortExpression="course_name" />
<asp:BoundField DataField="faculty_name" HeaderText="Faculty Name"
SortExpression="faculty_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="26px" ImageUrl="~/Images/btnedit.png" Width="27px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete"
Height="25px" ImageUrl="~/Images/btndelete.png" Width="26px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="500px">
<table class="style1">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; color: #800080; text-decoration: blink">
<hr />
<i>Batch Detail</i><hr />
</td>
</tr>
<tr>
<td align="left" class="style3">
</td>
<td align="right" style="color: #FF0000">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style3">
Batch Name :
</td>
<td>
<asp:DropDownList ID="ddlBatchName" runat="server"
DataTextField="batch_name" DataValueField="batch_id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Day :
</td>
<td>
<asp:DropDownList ID="ddlDays" runat="server" DataTextField="day"
DataValueField="day">
<asp:ListItem>-- select Any --</asp:ListItem>
<asp:ListItem>Sunday</asp:ListItem>
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
<asp:ListItem>Saturday</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Time :
</td>
<td>
<asp:TextBox ID="txtTimeFrom" runat="server" Width="90px"></asp:TextBox>
<b>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtTimeFrom" ErrorMessage="*"></asp:RequiredFieldValidator>
To </b>
<asp:TextBox ID="txtTimeTo" runat="server" Width="90px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtTimeTo" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style3">
Course Category :
</td>
<td>
<asp:DropDownList ID="ddlCategoryID" runat="server" AutoPostBack="True"
DataTextField="category_id" DataValueField="course_category_id"
onselectedindexchanged="ddlCategoryID_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Course Name :
</td>
<td>
<asp:DropDownList ID="ddlCourseName" runat="server"
DataTextField="course_name" DataValueField="course_id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Faculty :
</td>
<td>
<asp:DropDownList ID="ddlFacultyName" runat="server"
DataTextField="faculty_name" DataValueField="faculty_id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><hr />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
<asp:Button ID="btnUpdate" runat="server" Text="Update"
onclick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
onclick="btnCancel_Click" CausesValidation="False" /><hr />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" Mask="99:99"
MaskType="Time" TargetControlID="txtTimeFrom"
UserTimeFormat="TwentyFourHour" Enabled="True"></cc1:MaskedEditExtender>
<cc1:MaskedEditExtender ID="MaskedEditExtender2" runat="server" Mask="99:99"
MaskType="Time" TargetControlID="txtTimeTo" UserTimeFormat="TwentyFourHour"></cc1:MaskedEditExtender>
<cc1:MaskedEditValidator ID="MaskedEditValidator2" runat="server"
ControlExtender="MaskedEditExtender2" ControlToValidate="txtTimeTo"
InvalidValueMessage="*">
</cc1:MaskedEditValidator>
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
___________________________________________________________________________
Batch_Detail.aspx.cs (Dynamic code)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Batch_Detail : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
bl_obj.FillSelectAny(ddlCourseName);
}
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select batch_detail.* , convert(varchar(5),batch_detail.time_from,108)[time_from_grid],convert(varchar(5),batch_detail.time_to,108)[time_to_grid],batch_master.batch_name,course_category.category_id , course_master.course_name , faculty_master.faculty_name from batch_detail, batch_master , course_category , course_master , faculty_master where batch_master.batch_id = batch_detail.batch_id and course_category.course_category_id = batch_detail.course_cat_id and course_master.course_id = batch_detail.course_id and faculty_master.faculty_id = batch_detail.faculty_id and batch_detail.inst_login_id = '" + Session["inst_login_id"] + "' and batch_detail.branch_unique_id = " + Session["branch_unique_id"] + " ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_batch_name()
{
query = "select batch_id,batch_name from batch_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by batch_id";
DataTable dt_ddlBatchName = db_obj.ReturnDataTable(query);
ddlBatchName.DataSource = dt_ddlBatchName;
ddlBatchName.DataBind();
bl_obj.FillSelectAny(ddlBatchName);
}
void Fill_course_category()
{
query = "select course_category_id,category_id from course_category where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by category_id";
DataTable dt_ddlCategoryID = db_obj.ReturnDataTable(query);
ddlCategoryID.DataSource = dt_ddlCategoryID;
ddlCategoryID.DataBind();
bl_obj.FillSelectAny(ddlCategoryID);
}
void Fill_course_name()
{
query = " select course_id,course_name from course_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " and course_cat_id = " + ddlCategoryID.SelectedValue + " order by course_name";
DataTable dt_ddlCourseName = db_obj.ReturnDataTable(query);
ddlCourseName.DataSource = dt_ddlCourseName;
ddlCourseName.DataBind();
bl_obj.FillSelectAny(ddlCourseName);
}
void Fill_faculty()
{
query = " select faculty_id,faculty_name from faculty_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by faculty_name";
DataTable dt_ddlFacultyName = db_obj.ReturnDataTable(query);
ddlFacultyName.DataSource = dt_ddlFacultyName;
ddlFacultyName.DataBind();
bl_obj.FillSelectAny(ddlFacultyName);
}
void Fill_page_controls(DataTable dt_local)
{
ddlBatchName.SelectedValue = Convert.ToString(dt_local.Rows[0]["batch_id"]);
ddlDays.SelectedValue = Convert.ToString(dt_local.Rows[0]["day"]);
txtTimeFrom.Text = Convert.ToString(dt_local.Rows[0]["time_from_grid"]);
txtTimeTo.Text = Convert.ToString(dt_local.Rows[0]["time_to_grid"]);
ddlCategoryID.SelectedValue = Convert.ToString(dt_local.Rows[0]["course_cat_id"]);
ddlCategoryID_SelectedIndexChanged(null, null);
ddlCourseName.SelectedValue = Convert.ToString(dt_local.Rows[0]["course_id"]);
ddlFacultyName.SelectedValue = Convert.ToString(dt_local.Rows[0]["faculty_id"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void BindGridView(string sort_expression, string sort_direction)
{
//query = "select * from batch_detail order by " + sort_expression + " " + sort_direction + "";
query = "select batch_detail.* , convert(varchar(5),batch_detail.time_from,108)[time_from_grid],convert(varchar(5),batch_detail.time_to,108)[time_to_grid],batch_master.batch_name,course_category.category_id , course_master.course_name , faculty_master.faculty_name from batch_detail, batch_master , course_category , course_master , faculty_master where batch_master.batch_id = batch_detail.batch_id and course_category.course_category_id = batch_detail.course_cat_id and course_master.course_id = batch_detail.course_id and faculty_master.faculty_id = batch_detail.faculty_id batch_detail.inst_login_id = '" + Session["inst_login_id"] + "' and batch_detail.branch_unique_id = " + Session["branch_unique_id"] + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select *,convert(varchar(5),batch_detail.time_from,108)[time_from_grid],convert(varchar(5),batch_detail.time_to,108)[time_to_grid] from batch_detail where batch_detail_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_batch_name();
Fill_course_category();
Fill_faculty();
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
enable_disable_page_controls();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from batch_detail where batch_detail_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnAddBatchDetail_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
lblStatus.Text = "Add Batch...";
Fill_batch_name();
Fill_course_category();
Fill_faculty();
bl_obj.ClearControls(View2);
ddlBatchName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into batch_detail (inst_login_id,branch_unique_id,batch_id,day,time_from,time_to,course_cat_id,course_id,faculty_id,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "'," + Convert.ToInt16(Session["branch_unique_id"]) + "," + ddlBatchName.SelectedValue + ",'" + ddlDays.SelectedValue + "','" + txtTimeFrom.Text + "','" + txtTimeTo.Text + "'," + ddlCategoryID.SelectedValue + "," + ddlCourseName.SelectedValue + "," + ddlFacultyName.SelectedValue + " ,'" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update batch_detail set day = '" + ddlDays.SelectedValue + "', remarks = '" + txtRemarks.Text + "' where batch_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void ddlCategoryID_SelectedIndexChanged(object sender, EventArgs e)
{
Fill_course_name();
}
void enable_disable_page_controls()
{
ddlBatchName.Enabled = false;
}
#endregion
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
}
}
___________________________________________________________________
Step-3: create a new web page that named " Course_master "
-------------------------------------------------------------------------------------------------------------------------
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Course_master.aspx.cs" Inherits="BranchUser_Course_master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
color: #FF0000;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="499px">
<table class="style1">
<tr>
<td align="right"><hr />
<asp:Button ID="btnAddCourse" runat="server" onclick="btnAddCourse_Click"
Text="Add Course Name" /><hr />
</td>
</tr>
<tr>
<td style="text-align: center">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onpageindexchanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onsorting="GridView1_Sorting" AllowPaging="True" AllowSorting="True"
DataKeyNames="course_id" CaptionAlign="Top">
<Columns>
<asp:BoundField HeaderText="Course Category" DataField="course_category"
SortExpression="course_category" />
<asp:BoundField HeaderText="Course Name" DataField="course_name"
SortExpression="course_name" />
<asp:BoundField HeaderText="Fees" DataField="fees" SortExpression="fees" />
<asp:BoundField HeaderText="Remarks" DataField="remarks"
SortExpression="remarks" />
<asp:TemplateField HeaderText="course_category_id"
SortExpression="course_cat_id" Visible="False">
<ItemTemplate>
<asp:Label ID="lbl_course_category_id" runat="server"
Text='<%# Bind("course_cat_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgbtnEdit" runat="server" Height="26px"
ImageUrl="~/Images/btnedit.png" Width="28px" CommandName="Edit" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Height="25px"
ImageUrl="~/Images/btndelete.png" Width="27px" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<p>
There are No Records......</p>
</EmptyDataTemplate>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="429px">
<table class="style1">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; color: #800080; text-decoration: blink">
<hr />
<i>Select Course By Category</i><%--style="height: -15px" --%>
</td>
</tr>
<tr>
<td align="right" colspan="2" style="color: #FF0000"><hr />
* Stands For Mandatory Fields <hr /></td>
</tr>
<tr>
<td align="right">
Course Category :
</td>
<td>
<asp:DropDownList ID="ddlCourseCategory" runat="server"
DataTextField="category_id" DataValueField="course_category_id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right">
Course Name :
</td>
<td>
<asp:TextBox ID="txtCourseName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCourseName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Fees :
</td>
<td>
<asp:TextBox ID="txtFees" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtFees" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><hr />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
<asp:Button ID="btnUpdate" runat="server" Text="Update"
onclick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
onclick="btnCancel_Click" CausesValidation="False" /><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
_________________________________________________________________________
Course_master.aspx.cs (Dynamic code)
__________________________________
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Course_master : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
Fill_course_category();
}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from course_master where course_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception ex)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select * from course_master where course_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
ddlCourseCategory.Enabled = false;
txtCourseName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into course_master (inst_login_id,branch_unique_id,course_name,remarks,course_cat_id,fees) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtCourseName.Text + "','" + txtRemarks.Text + "'," + ddlCourseCategory.SelectedValue + "," + txtFees.Text + ")";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update course_master set fees = '" + txtFees.Text + "' , remarks = '" + txtRemarks.Text + "' where course_id = " + Convert.ToString(ViewState["key"]) + "";//"insert into branch_master (inst_login_id,branch_id,branch_password,branch_name,branch_address,branch_phone,branch_email_id,branch_owner,remarks) values ('" + Convert.ToString(Session["login_id"]) + "','" + txtBranch_id.Text + "','" + txtPassword.Text + "','" + txtName.Text + "','" + txtAddress.Text + "','" + txtPhone.Text + "','" + txtEmail.Text + "','" + txtOwner.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnAddCourse_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Course By Category...";
ddlCourseCategory.Enabled = true;
txtCourseName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
#endregion
#region "Functions"
void Fill_course_category()
{
query = "select category_id,course_category_id from course_category where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToString(Session["branch_unique_id"]) + " order by category_id";
DataTable dt_ddlCourseCategory = db_obj.ReturnDataTable(query);
ddlCourseCategory.DataSource = dt_ddlCourseCategory;
ddlCourseCategory.DataBind();
bl_obj.FillSelectAny(ddlCourseCategory);
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id and course_master.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and course_master.branch_unique_id = " + Convert.ToString(Session["branch_unique_id"]) + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
ddlCourseCategory.SelectedValue = Convert.ToString(dt_local.Rows[0]["course_cat_id"]);
txtCourseName.Text = Convert.ToString(dt_local.Rows[0]["course_name"]);
txtFees.Text = Convert.ToString(dt_local.Rows[0]["fees"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id and course_master.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and course_master.branch_unique_id = " + Convert.ToString(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
#endregion
}
__________________________________________________________________________
Step-4: create a new page that name is " Course_category "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Course_category.aspx.cs" Inherits="BranchUser_Course_category" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 100%;
height: 23px;
}
.style2
{
height: 8px;
}
.style3
{
}
.style4
{
height: 8px;
width: 334px;
}
.style5
{
height: 2px;
width: 334px;
}
.style6
{
height: 2px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /> <table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:Panel ID="Panel1" runat="server" Height="569px">
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<table class="style1">
<tr>
<td align="right"><hr />
<asp:Button ID="btnAddCourseCategory" runat="server" Text="Add Course Category"
onclick="btnAddCourseCategory_Click" /><hr style="height: -12px" />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" style="text-align: center" onpageindexchanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onsorting="GridView1_Sorting" DataKeyNames="course_category_id">
<EmptyDataTemplate>
<p>There are No Records......</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="category_id" HeaderText="Course Category"
SortExpression="category_id" />
<asp:BoundField DataField="remarks" HeaderText="Remarks"
SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Height="25px"
ImageUrl="~/Images/btnedit.png" Width="24px" CommandName="Edit" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" Height="24px"
ImageUrl="~/Images/btndelete.png" Width="24px" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<hr style="height: -12px" />
</td>
</tr>
</table>
</asp:View>
<asp:View ID="View2" runat="server">
<table class="style1">
<tr>
<td align="center" class="style2" colspan="2"
style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr style="height: -15px" />
<span class="style3">Add Course Category</span><hr style="height: -15px" />
</td>
</tr>
<tr>
<td class="style3">
</td>
<td>
<p align="right">
* Stands For Mandatory Fields</p>
</td>
</tr>
<tr>
<td align="right" class="style5">
Course Category :
</td>
<td class="style6">
<asp:TextBox ID="txtCourseCategory" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCourseCategory" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style4">
Remarks :
</td>
<td class="style2">
<asp:TextBox ID="txtRemarks" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2"><hr />
<asp:Button ID="btnSubmit" runat="server" onclick="btnSubmit_Click"
Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click"
Text="Update" />
<asp:Button ID="btnCancel" runat="server" onclick="btnCancel_Click"
Text="Cancel" CausesValidation="False" /><hr style="height: -15px" />
</td>
</tr>
</table>
</asp:View>
</asp:MultiView>
</asp:Panel>
</asp:Content>
Course_category.aspx.cs (Dynamic code)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Security;
using System.Configuration;
using System.Data;
public partial class BranchUser_Course_category : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from course_category where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from course_category where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
txtCourseCategory.Text = Convert.ToString(dt_local.Rows[0]["category_id"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into course_category (inst_login_id,branch_unique_id,category_id,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtCourseCategory.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from course_category where course_category_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
/********* Code For Change Color **************/
//GridViewRow gr = (GridViewRow)GridView2.Rows[Convert.ToInt16(ViewState["edit_index"])];
//gr.BackColor = System.Drawing.Color.Black;
/********* Code For Change Color **************/
}
catch (Exception ex)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
Initial_settings();
query = "select * from course_category where course_category_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
txtCourseCategory.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
//category_id = '" + txtCourseCategory.Text + "',
query = "update course_category set remarks = '" + txtRemarks.Text + "' where course_category_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnAddCourseCategory_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Course Category...";
txtCourseCategory.Enabled = true;
btnUpdate.Enabled = false;
btnSubmit.Enabled = true;
}
#endregion
}
________________________________________________________________________
Step-5: create a new page that name is " Faculty_Master "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Faculty_Master.aspx.cs" Inherits="BranchUser_Faculty_Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style2
{
font-style: normal;
font-family: Verdana;
font-size: medium;
color: #336600;
}
.style3
{
font-style: normal;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="502px">
<table width="100%">
<tr>
<td align="right"><hr />
<asp:Button ID="btnAddNewFaculty" runat="server" CausesValidation="False"
OnClick="btnAdd_Click" Text="Add New Faculty" /><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
OnPageIndexChanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center"
DataKeyNames="faculty_id">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="faculty_name" HeaderText="Name"
SortExpression="faculty_name" />
<asp:BoundField DataField="faculty_address" HeaderText="Address"
SortExpression="faculty_address" />
<asp:BoundField DataField="faculty_phone" HeaderText="Phone No."
SortExpression="faculty_phone" />
<asp:BoundField DataField="faculty_email" HeaderText="Email"
SortExpression="faculty_email" />
<asp:BoundField DataField="faculty_qualification" HeaderText="Qualification"
SortExpression="faculty_qualification" />
<asp:BoundField DataField="remarks" HeaderText="Remarks"
SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="24px" ImageUrl="~/Images/btnedit.png" Width="23px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete"
Height="27px" ImageUrl="~/Images/btndelete.png" Width="26px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="481px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2"
style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr />
Enter Faculty Detail<hr style="height: -15px" />
</td>
</tr>
<tr>
<td class="style7">
</td>
<td align="right" class="style7">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style4">
* Faculty Name :
</td>
<td align="left" class="style5">
<asp:TextBox ID="txtFacultyName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtFacultyName" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style3">
* Address :
</td>
<td align="left">
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtAddress" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Phone No. :
</td>
<td align="left">
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Email ID :
</td>
<td align="left">
<asp:TextBox ID="txtEmailID" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmailID" ErrorMessage="@"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td align="right">
* Qualification :
</td>
<td>
<asp:TextBox ID="txtQualification" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtQualification" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr />
<asp:Button ID="btnSubmit" runat="server" OnClick="Submitbtn" Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click"
Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False"
OnClick="Cancelbtn" Text="Cancel" />
<hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
Faculty_Master.aspx.cs (Dynamic code)
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 System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Faculty_Master : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Faculty Detail...";
txtFacultyName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void Submitbtn(object sender, EventArgs e)
{
query = "insert into faculty_master (inst_login_id,branch_unique_id,faculty_name,faculty_address,faculty_phone,faculty_email,faculty_qualification,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtFacultyName.Text + "','" + txtAddress.Text + "','" + txtPhone.Text + "','" + txtEmailID.Text + "','" + txtQualification.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update faculty_master set faculty_address = '" + txtAddress.Text + "', faculty_phone = '" + txtPhone.Text + "', faculty_email = '" + txtEmailID.Text + "', faculty_qualification = '" + txtQualification.Text + "', remarks = '" + txtRemarks.Text + "' where faculty_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void Cancelbtn(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select * from faculty_master where faculty_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
txtFacultyName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from faculty_master where faculty_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
#endregion
#region "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from faculty_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
txtFacultyName.Text = Convert.ToString(dt_local.Rows[0]["faculty_name"]);
txtAddress.Text = Convert.ToString(dt_local.Rows[0]["faculty_address"]);
txtPhone.Text = Convert.ToString(dt_local.Rows[0]["faculty_phone"]);
txtEmailID.Text = Convert.ToString(dt_local.Rows[0]["faculty_email"]);
txtQualification.Text = Convert.ToString(dt_local.Rows[0]["faculty_qualification"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from faculty_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
#endregion
}
Step-6: create a new page that name is " Fees "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Fees.aspx.cs" Inherits="BranchUser_Fees" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style2
{
font-style: normal;
font-family: Verdana;
font-size: medium;
color: #336600;
}
.style3
{
font-style: normal;
}
.style4
{
font-size: medium;
font-family: Verdana;
font-style: normal;
color: #336600;
text-decoration: blink;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="506px">
<table width="100%">
<tr>
<td align="right"><hr />
<asp:Button ID="AddFeesDate" runat="server" CausesValidation="False" OnClick="btnAdd_Click"
Text="Add Fees Date" /><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center" DataKeyNames="fees_id">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="unique_name" HeaderText="Student Unique Name" SortExpression="unique_name" />
<asp:BoundField DataField="fees_date_grid" HeaderText="Fees Date" SortExpression="fees_date_grid" />
<asp:BoundField DataField="fees" HeaderText="Fees" SortExpression="fees" />
<asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit" Height="27px"
ImageUrl="~/Images/btnedit.png" Width="27px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete" Height="23px"
ImageUrl="~/Images/btndelete.png" Width="24px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr/>
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="502px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr />
Enter Fees Detail<hr style="height: -15px" />
</td>
</tr>
<tr>
<td class="style7">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td>
<td align="right" class="style7" style="color: #FF0000">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style3">
* Student Unique Name :
</td>
<td align="left">
<asp:DropDownList ID="ddlStudentUniqueName" DataTextField="unique_name" DataValueField="stu_id"
runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style4">
* Fees Date :
</td>
<td align="left">
<asp:TextBox ID="txtFeesDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtFeesDate" ErrorMessage="*"></asp:RequiredFieldValidator>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy"
TargetControlID="txtFeesDate">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td align="right">
* Fees :
</td>
<td align="left">
<asp:TextBox ID="txtFees" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtFees" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClick="btnCancel_Click"
Text="Cancel" />
<hr />
<br />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
-----------------------------------------------------------------------------
Fees.aspx.cs (dynamic Code)
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 System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Fees : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
int row_affected = 0;
#endregion
#region Events
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
Fill_student_unique_name();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
//DateTime dt = Convert.ToDateTime(txtFeesDate.Text);
query = "insert into Fees (inst_login_id,branch_unique_id,stu_id,fees_date,fees,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "'," + ddlStudentUniqueName.SelectedValue + ",convert(datetime,'" + txtFeesDate.Text + "',103),'" + txtFees.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update Fees set fees_date = '" + txtFeesDate.Text + "', fees = '" + txtFees.Text + "', remarks = '" + txtRemarks.Text + "' where fees_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnAdd_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Fees Detail...";
ddlStudentUniqueName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from Fees where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select *,convert(varchar(10),fees_date,103) [fees_date_grid] from Fees where fees_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
ddlStudentUniqueName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from Fees where fees_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
#endregion
#region "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
//query = "select *,convert(varchar(10),fees_date,103) [fees_date_grid] from Fees";
query = "select Fees.*, student_info.unique_name,convert(varchar(10),fees_date,103) [fees_date_grid] from Fees,student_info where Fees.stu_id = student_info.stu_id and Fees.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and Fees.branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
ddlStudentUniqueName.SelectedValue = Convert.ToString(dt_local.Rows[0]["stu_id"]); ;
txtFeesDate.Text = Convert.ToString(dt_local.Rows[0]["fees_date_grid"]);
txtFees.Text = Convert.ToString(dt_local.Rows[0]["fees"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void Fill_student_unique_name()
{
query = "select unique_name,stu_id from student_info where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by unique_name";
DataTable dt_ddlStudentUniqueName = db_obj.ReturnDataTable(query);
//ddlInstitute.DataTextField = "name";
//ddlInstitute.DataValueField = "login_id";
ddlStudentUniqueName.DataSource = dt_ddlStudentUniqueName;
ddlStudentUniqueName.DataBind();
bl_obj.FillSelectAny(ddlStudentUniqueName);
}
#endregion
}
Step-7: create a new page that name is " Fees_rule "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Fees_rule.aspx.cs" Inherits="BranchUser_Fees_rule" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style4
{
width: 453px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="height: 6px; width: 959px;">
<tr><td>Status :<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</td></tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="503px">
<table width="100%">
<tr>
<td align="right"><hr />
<asp:Button ID="btnAddRule" runat="server" CausesValidation="False"
OnClick="btnAdd_Click" Text="Add Rule" /><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center"
Width="456px" DataKeyNames="rule_id">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="rule_name" HeaderText="Rule Name"
SortExpression="rule_name" />
<asp:BoundField DataField="rule_days" HeaderText="Rule Days"
SortExpression="rule_days" />
<asp:BoundField DataField="remarks" HeaderText="Remarks"
SortExpression="remarks" />
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="23px" ImageUrl="~/Images/btnedit.png" Width="25px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete"
Height="24px" ImageUrl="~/Images/btndelete.png" Width="24px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="498px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2"
style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr />
FEES RULE<hr style="height: -2px" />
</td>
</tr>
<tr>
<td class="style4">
</td>
<td align="right" class="style7" style="color: #FF0000">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style4">
* Rule Name :
</td>
<td align="left">
<asp:TextBox ID="txtRuleName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtRuleName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style4">
Will Pay Fees on every :
</td>
<td>
<asp:TextBox ID="txtPayFeesDay" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtPayFeesDay" ErrorMessage="*"></asp:RequiredFieldValidator>
Days</td>
</tr>
<tr>
<td align="right" class="style4">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click"
Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click"
Text="Update" Width="77px" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False"
OnClick="btnCancel_Click" Text="Cancel" />
<hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
_________________________________________________________________________
Fees_rule.aspx.cs
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 System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_Fees_rule : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select * from fees_rule where rule_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from fees_rule where rule_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into fees_rule (inst_login_id,branch_unique_id,rule_name,rule_days,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtRuleName.Text + "','" + txtPayFeesDay.Text + "','" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update fees_rule set rule_name = '" + txtRuleName.Text + "',rule_days = '" + txtPayFeesDay.Text + "' , remarks = '" + txtRemarks.Text + "' where rule_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnAdd_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Rule Name...";
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
#endregion
#region "Functions"
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from fees_rule where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from fees_rule where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
txtRuleName.Text = Convert.ToString(dt_local.Rows[0]["rule_name"]);
txtPayFeesDay.Text = Convert.ToString(dt_local.Rows[0]["rule_days"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
#endregion
}
Step-8 : create a new page that name is " Student_course_selection "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Student_course_selection.aspx.cs" Inherits="BranchUser_Student_course_selection" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style6
{
width: 100%;
}
.style2
{
font-style: normal;
font-family: Verdana;
font-size: medium;
color: #336600;
}
.style3
{
font-style: normal;
}
.style4
{
font-size: medium;
font-family: Verdana;
font-style: normal;
color: #336600;
text-decoration: blink;
}
.style5
{
font-size: medium;
font-family: Verdana;
font-weight: bold;
font-style: normal;
color: #336600;
text-decoration: blink;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br /><table>
<tr>
<td>
Status :<asp:Label ID="lblStatus" runat="server" Style="text-align: left" Text="Label"></asp:Label>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="501px">
<table class="style6">
<tr>
<td align="right"><hr />
<asp:Button ID="btnStudentCourseSelecton" runat="server" OnClick="btnAddStudentPayment_Click"
Text="Assign Course to Student"/><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="course_selection_id"
OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDeleting="GridView1_RowDeleting"
OnRowEditing="GridView1_RowEditing" OnSorting="GridView1_Sorting"
Style="text-align: center" Width="80%">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField HeaderText="Student Unique Name" DataField="unique_name" SortExpression="unique_name" />
<asp:BoundField HeaderText="Course Category" DataField="category_id" SortExpression="category_id" />
<asp:BoundField HeaderText="Course Name" DataField="course_name" SortExpression="course_name" />
<asp:BoundField HeaderText="Fees" DataField="course_fees" SortExpression="course_fees" />
<asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit" Height="26px"
ImageUrl="~/Images/btnedit.png" Width="25px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete" Height="26px"
ImageUrl="~/Images/btndelete.png" Width="25px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="500px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr style="height: -15px" />
Student Course Selection<hr />
</td>
</tr>
<tr>
<td class="style7">
</td>
<td align="right" class="style7" style="color: #FF0000">
* Stands For Mandatory Fields
</td>
</tr>
<tr>
<td align="right" class="style3">
* Student Unique Name :
</td>
<td align="left">
<asp:DropDownList ID="ddlStudentUniqueName" runat="server" DataTextField="unique_name"
DataValueField="stu_id">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="ddlStudentUniqueName" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style3">
* Course Category :
</td>
<td align="left">
<asp:DropDownList ID="ddlCourseCategory" DataValueField="course_category_id" DataTextField="category_id"
runat="server" AutoPostBack="True"
onselectedindexchanged="ddlCourseCategory_SelectedIndexChanged">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="ddlCourseCategory" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style4">
* Course Name :
</td>
<td align="left" class="style5">
<asp:DropDownList ID="ddlCourseName" runat="server" DataTextField="course_name"
DataValueField="course_id" AutoPostBack="True"
onselectedindexchanged="ddlCourseName_SelectedIndexChanged">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="ddlCourseName" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
* Fees :
</td>
<td align="left">
<asp:TextBox ID="txtFees" runat="server" Height="22px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtFees" ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"
Height="34px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClick="btnCancel_Click"
Text="Cancel" />
<hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
------------------------------------------------------------------------
Student_course_selection.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
public partial class BranchUser_Student_course_selection : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into student_course_selection (inst_login_id,branch_unique_id,stu_id,course_category_id,course_id,course_fees,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "'," + Convert.ToInt16(Session["branch_unique_id"]) + "," + ddlStudentUniqueName.SelectedValue + "," + ddlCourseCategory.SelectedValue + "," + ddlCourseName.SelectedValue + "," + txtFees.Text + ",'" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update student_course_selection set course_fees = " + txtFees.Text + ", remarks = '" + txtRemarks.Text + "' where course_selection_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnAddStudentPayment_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
// Fill_Student_unique_name();
Fill_Student_unique_name();
Fill_Course_category();
lblStatus.Text = "Assign Course to Student...";
bl_obj.FillSelectAny(ddlCourseName);
bl_obj.ClearControls(View2);
ddlStudentUniqueName.Enabled = true;
ddlCourseCategory.Enabled = true;
ddlCourseName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select * from student_course_selection where course_selection_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_Student_unique_name();
Fill_Course_category();
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
ddlStudentUniqueName.Enabled = false;
ddlCourseCategory.Enabled = false;
ddlCourseName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from student_course_selection where course_selection_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void ddlCourseCategory_SelectedIndexChanged(object sender, EventArgs e)
{
Fill_Course_name();
}
protected void ddlCourseName_SelectedIndexChanged(object sender, EventArgs e)
{
Fill_Fees();
}
#endregion
#region "Functions"
void Fill_Fees()
{
query = "select fees from course_master where course_id = " + ddlCourseName.SelectedValue + "";
txtFees.Text = db_obj.ExecuteScaler(query);
}
void BindGridView(string sort_expression, string sort_direction)
{
//query = " select student_course_selection.*, student_info.unique_name, course_category.category_id, course_master.course_name from student_course_selection, student_info, course_category, course_master where student_course_selection.stu_id = student_info.stu_id and student_course_selection.course_category_id = course_master.course_name and student_course_selection.course_id = course_category.category_id order by " + sort_expression + " " + sort_direction + "";
query = "select student_course_selection.* , student_info.unique_name, course_category.category_id, course_master.course_name from student_course_selection, student_info, course_category, course_master where student_course_selection.stu_id = student_info.stu_id and student_course_selection.course_id = course_master.course_id and student_course_selection.course_category_id = course_category.course_category_id and student_info.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and student_info.branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by " + sort_expression + " " + sort_direction + "";
//query = "select student_payment.* , fees_rule.rule_name,student_info.unique_name,convert(varchar(10),date,103) [fees_date_grid] from fees_rule, student_info, student_payment where student_payment.stu_id = student_info.stu_id and student_payment.rule_id = fees_rule.rule_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
ddlStudentUniqueName.SelectedValue = Convert.ToString(dt_local.Rows[0]["stu_id"]);
ddlCourseCategory.SelectedValue = Convert.ToString(dt_local.Rows[0]["course_category_id"]);
Fill_Course_name();
ddlCourseName.SelectedValue = Convert.ToString(dt_local.Rows[0]["course_id"]);
txtFees.Text = Convert.ToString(dt_local.Rows[0]["course_fees"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void Fill_Student_unique_name()
{
query = "select stu_id,unique_name from student_info where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by stu_id";
DataTable dt_ddlStudentUniqueName = db_obj.ReturnDataTable(query);
ddlStudentUniqueName.DataSource = dt_ddlStudentUniqueName;
ddlStudentUniqueName.DataBind();
bl_obj.FillSelectAny(ddlStudentUniqueName);
}
void Fill_Course_category()
{
query = "select course_category_id,category_id from course_category where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by course_category_id";
DataTable dt_ddlCourseCategory = db_obj.ReturnDataTable(query);
ddlCourseCategory.DataSource = dt_ddlCourseCategory;
ddlCourseCategory.DataBind();
bl_obj.FillSelectAny(ddlCourseCategory);
}
void Fill_Course_name()
{
query = "select course_id,course_name from course_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " and course_cat_id = " + ddlCourseCategory.SelectedValue + " order by course_id";
DataTable dt_ddlCourseName = db_obj.ReturnDataTable(query);
ddlCourseName.DataSource = dt_ddlCourseName;
ddlCourseName.DataBind();
bl_obj.FillSelectAny(ddlCourseName);
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
//query = "select student_course_selection.* , student_info.unique_name, course_category.category_id, course_master.course_name from student_course_selection, student_info, course_category, course_master where student_course_selection.stu_id = student_info.stu_id and student_course_selection.course_category_id = course_master.course_id and student_course_selection.course_id = course_category.category_id";
query = "select student_course_selection.* , student_info.unique_name, course_category.category_id, course_master.course_name from student_course_selection, student_info, course_category, course_master where student_course_selection.stu_id = student_info.stu_id and student_course_selection.course_id = course_master.course_id and student_course_selection.course_category_id = course_category.course_category_id and student_info.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and student_info.branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
//query = "select student_payment.* , fees_rule.rule_name,student_info.unique_name,convert(varchar(10),date,103) [fees_date_grid] from fees_rule, student_info, student_payment where student_payment.stu_id = student_info.stu_id and student_payment.rule_id = fees_rule.rule_id";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
#endregion
}
Step-9: create a new page that name is " Student_info"
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Student_info.aspx.cs" Inherits="BranchUser_Student_info" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
color: #FF3300;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<html>
<body>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" BorderColor="#61AD32" BorderStyle="None"
Height="501px">
<table width="100%">
<tr style="background-image: url('../../Images/Line1.jpg')">
<td align="right" style="background-image: url('../../Images/Line1.jpg')">
<hr style="height: -12px" />
<asp:Button ID="btnAdd" runat="server" Text="Add New Student" OnClick="btnAdd_Click"
CausesValidation="False" /><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" Style="text-align: center" AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" OnPageIndexChanging="GridView1_PageIndexChanging"
OnSorting="GridView1_Sorting" DataKeyNames="stu_id" OnRowDeleting="GridView1_RowDeleting"
OnRowEditing="GridView1_RowEditing" Width="100%">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="unique_name" HeaderText="Unique Name" SortExpression="unique_name" />
<asp:BoundField DataField="name" HeaderText="Name" SortExpression="name" />
<asp:BoundField DataField="address" HeaderText="Address" SortExpression="address" />
<asp:BoundField DataField="phone" HeaderText="Phone No." SortExpression="phone" />
<asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
<asp:BoundField DataField="refrence" HeaderText="Refrence" SortExpression="refrence" />
<asp:BoundField DataField="remarks" HeaderText="Remarks" SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Height="24px" ImageUrl="~/Images/btnedit.png"
Width="22px" CommandName="Edit" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" Height="24px" ImageUrl="~/Images/btndelete.png"
Width="23px" CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server" EnableViewState="False">
<asp:Panel ID="Panel1" runat="server">
<table width="100%" align="center">
<tr>
<td class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; color: #800080; text-decoration: blink" align="center">
<hr />
<i>Enter Student Detail</i><hr />
<%--style="height: -15px" --%>
</td>
</tr>
<tr>
<td class="style7" align="right" colspan="2" style="color: #FF0000">
* Stands For Mandatory Fields
<hr />
</td>
</tr>
<tr>
<td align="right">
* Student Unique Name :
</td>
<td align="left">
<asp:TextBox ID="txtStudentUniqueNme" runat="server" Style="text-align: left"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtStudentUniqueNme"
ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style4" align="right">
* Student Name :
</td>
<td align="left" class="style5">
<asp:TextBox ID="txtStudentName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtStudentName"
ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style3" align="right">
* Address :
</td>
<td align="left">
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtStudentName"
ErrorMessage="*">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
Phone No. :
</td>
<td align="left">
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Email ID :
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="@" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td align="right">
Refrence :
</td>
<td>
<asp:TextBox ID="txtRefrence" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Refrencer From :
</td>
<td>
<asp:TextBox ID="txtRefrenceFrom" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2" ID="btnSubmit">
<hr />
<asp:Button ID="btnSubmit" runat="server" onclick="Submitbtn" Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClick="Cancelbtn"
Text="Cancel" />
<hr />
</td>
</tr>
<tr>
<td align="center" colspan="2">
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</body>
</html>
</asp:Content>
______________________________________________________________________________
Student_info.aspx (Dynamic code)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
public partial class BranchUser_Student_info : System.Web.UI.Page
{
#region "Variables & Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
string sort_expression = string.Empty;
string sort_direction = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!Page.IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = " Add Student Details...";
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void Submitbtn(object sender, EventArgs e)
{
query = "insert into student_info(inst_login_id,branch_unique_id,Unique_name,name,address,phone,email,refrence,refrence_from,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "','" + Convert.ToInt16(Session["branch_unique_id"]) + "','" + txtStudentUniqueNme.Text + "','" + txtStudentName.Text + "','" + txtAddress.Text + "','" + txtPhone.Text + "','" + txtEmail.Text + "','" + txtRefrence.Text + "','" + txtRefrenceFrom.Text + "','" + txtRemarks.Text + "' )";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
bl_obj.ClearControls(View1);
Initial_settings();
}
catch (Exception ex1)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void Cancelbtn(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from student_info where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void BindGridView(string sort_expression, string sort_direction)
{
query = " select * from student_info order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
{
BindGridView(e.SortExpression.ToString(), "desc");
}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from student_info where stu_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
}
catch (Exception ex)
{
lblStatus.Text = "Your Transcation can not completed...";
}
Initial_settings();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = " select * from student_info where stu_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
void fill_page_controls(DataTable dt_local)
{
txtStudentUniqueNme.Text = Convert.ToString(dt_local.Rows[0]["unique_name"]);
txtStudentName.Text = Convert.ToString(dt_local.Rows[0]["name"]);
txtAddress.Text = Convert.ToString(dt_local.Rows[0]["address"]);
txtPhone.Text = Convert.ToString(dt_local.Rows[0]["phone"]);
txtEmail.Text = Convert.ToString(dt_local.Rows[0]["email"]);
txtRefrence.Text = Convert.ToString(dt_local.Rows[0]["refrence"]);
txtRefrenceFrom.Text = Convert.ToString(dt_local.Rows[0]["refrence_from"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
enable_disable_page_controls();
}
void enable_disable_page_controls()
{
txtStudentUniqueNme.Enabled = false;
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update student_info set name = '" + txtStudentName.Text + "', address = '" + txtAddress.Text + "', phone = '" + txtPhone.Text + "', email = '" + txtEmail.Text + "', refrence = '" + txtRefrence.Text + "', refrence_from = '" + txtRefrenceFrom.Text + "' where stu_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
/********* Code For Change Color **************/
//GridViewRow gr = (GridViewRow)GridView2.Rows[Convert.ToInt16(ViewState["edit_index"])];
//gr.BackColor = System.Drawing.Color.Black;
/********* Code For Change Color **************/
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
#endregion
#region "Functions"
#endregion
}
Step-10: create a new page that name is "Student_payment "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="Student_payment.aspx.cs" Inherits="BranchUser_Student_payment" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style2
{
font-style: normal;
font-family: Verdana;
font-size: medium;
color: #336600;
}
.style3
{
font-style: normal;
}
.style4
{
font-size: medium;
font-family: Verdana;
font-style: normal;
color: #336600;
text-decoration: blink;
}
.style5
{
font-size: medium;
font-family: Verdana;
font-weight: bold;
font-style: normal;
color: #336600;
text-decoration: blink;
}
.style6
{
width: 100%;
}
.style7
{
height: 14px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="style1">
<tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel1" runat="server" Height="501px">
<table class="style6">
<tr>
<td align="right"><hr />
<asp:Button ID="btnAddStudentPayment" runat="server"
onclick="btnAddStudentPayment_Click" Text="Add Student Payment" /><hr />
</td>
</tr>
<tr>
<td align="center">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="student_payment_id"
OnPageIndexChanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField HeaderText="Student Unique Name" DataField="unique_name"
SortExpression="unique_name" />
<asp:BoundField HeaderText="Rule Name" DataField="rule_name"
SortExpression="rule_name" />
<asp:BoundField HeaderText="Amount" DataField="amount"
SortExpression="amount" />
<asp:BoundField HeaderText="Date" DataField="fees_date_grid"
SortExpression="fees_date_grid" />
<asp:BoundField DataField="remarks" HeaderText="Remarks"
SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="26px" ImageUrl="~/Images/btnedit.png" Width="29px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete"
Height="28px" ImageUrl="~/Images/btndelete.png" Width="27px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr style="height: -15px" />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="498px">
<table align="center" width="100%">
<tr>
<td align="center" class="style2" colspan="2"
style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; font-style: italic; color: #800080; text-decoration: blink">
<hr style="height: -15px" />
Student Payment Detail<hr/>
</td>
</tr>
<tr>
<td class="style7" align="right" colspan="2" style="color: #FF0000">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
* Stands For Mandatory Fields
<hr /> </td>
</tr>
<tr>
<td align="right" class="style3">
* Student Unique Name :
</td>
<td align="left">
<asp:DropDownList ID="ddlStudentUniqueName" DataValueField="stu_id"
DataTextField="unique_name" runat="server" Width="184px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
* Rule Name :
</td>
<td align="left">
<asp:DropDownList ID="ddlRuleName" DataValueField="rule_id"
DataTextField="rule_name" runat="server" Height="16px" Width="184px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style4">
* Amount :
</td>
<td align="left" class="style5">
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtAmount" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
* Date :
</td>
<td align="left">
<asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtDate" ErrorMessage="*"></asp:RequiredFieldValidator>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server"
Format="dd/MM/yyyy" TargetControlID="txtDate">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td align="right">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine" Width="178px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<hr />
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click"
Text="Submit" />
<asp:Button ID="btnUpdate" runat="server" onclick="btnUpdate_Click"
Text="Update" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="False"
OnClick="btnCancel_Click" Text="Cancel" />
<hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
_________________________________________________________________________
Student_payment.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.Web.Security;
using System.Configuration;
using System.Web.UI.HtmlControls;
public partial class BranchUser_Student_payment : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
int row_affected = 0;
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
//query = "select batch_detail.* , batch_master.batch_name,course_category.category_id , course_master.course_name , faculty_master.faculty_name from batch_detail, batch_master , course_category , course_master , faculty_master where batch_master.batch_id = batch_detail.batch_id and course_category.course_category_id = batch_detail.course_cat_id and course_master.course_id = batch_detail.course_id and faculty_master.faculty_id = batch_detail.faculty_id";
query = "select student_payment.* , fees_rule.rule_name,student_info.unique_name,convert(varchar(10),date,103) [fees_date_grid] from fees_rule, student_info, student_payment where student_payment.stu_id = student_info.stu_id and student_payment.rule_id = fees_rule.rule_id and student_payment.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and student_payment.branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_Student_unique_name()
{
query = "select stu_id,unique_name from student_info where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by stu_id";
DataTable dt_ddlStudentUniqueName = db_obj.ReturnDataTable(query);
ddlStudentUniqueName.DataSource = dt_ddlStudentUniqueName;
ddlStudentUniqueName.DataBind();
bl_obj.FillSelectAny(ddlStudentUniqueName);
}
void Fill_Rule_name()
{
query = "select rule_id,rule_name from fees_rule where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by rule_name";
DataTable dt_ddlRuleName = db_obj.ReturnDataTable(query);
ddlRuleName.DataSource = dt_ddlRuleName;
ddlRuleName.DataBind();
bl_obj.FillSelectAny(ddlRuleName);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into student_payment (inst_login_id,branch_unique_id,stu_id,rule_id,amount,date,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "'," + Convert.ToInt16(Session["branch_unique_id"]) + "," + ddlStudentUniqueName.SelectedValue + "," + ddlRuleName.SelectedValue + "," + txtAmount.Text + ",convert(datetime,'" + txtDate.Text + "',103),'" + txtRemarks.Text + "')";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update student_payment set amount = " + txtAmount.Text + ", date = '" + txtDate.Text + "', remarks = '" + txtRemarks.Text + "' where student_payment_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnAddStudentPayment_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
Fill_Student_unique_name();
Fill_Rule_name();
bl_obj.ClearControls(View2);
lblStatus.Text = "Add Student Payment Detail...";
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
query = "select *,convert(varchar(10),date,103) [fees_date_grid] from student_payment where student_payment_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
ddlStudentUniqueName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
void Fill_page_controls(DataTable dt_local)
{
ddlStudentUniqueName.SelectedValue = Convert.ToString(dt_local.Rows[0]["stu_id"]);
ddlRuleName.SelectedValue = Convert.ToString(dt_local.Rows[0]["rule_id"]);
txtAmount.Text = Convert.ToString(dt_local.Rows[0]["amount"]);
txtDate.Text = Convert.ToString(dt_local.Rows[0]["fees_date_grid"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select student_payment.* , fees_rule.rule_name,student_info.unique_name,convert(varchar(10),date,103) [fees_date_grid] from fees_rule, student_info, student_payment where student_payment.stu_id = student_info.stu_id and student_payment.rule_id = fees_rule.rule_id order by " + sort_expression + " " + sort_direction + "";
//query = "select course_master.*,course_category.category_id course_category from course_category,course_master where course_category.course_category_id = course_master.course_cat_id order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from student_payment where student_payment_id = " + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch (Exception)
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
#endregion
}
Step-11: create a new page that name is " StudentBatchLinking.aspx "
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BranchUserMasterPage.master" AutoEventWireup="true" CodeFile="StudentBatchLinking.aspx.cs" Inherits="BranchUser_StudentBatchLinking" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
}
.style3
{
}
.style4
{
height: 10px;
}
</style>
<script type="text/javascript">
setInterval("RecordStatus();", 1000);
function RecordStatus() {
msg = document.getElementById("ctl00_ContentPlaceHolder1_lblStatus");
if (msg.style.color == "#7c2bc6") {
msg.style.color = "#FF0080";
}
else {
msg.style.color = "#7c2bc6";
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="style1">
<br /><tr>
<td>
<asp:Panel ID="Panel4" runat="server">
Status :
<asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</td>
</tr>
</table>
<asp:MultiView ID="MultiView1" runat="server"><asp:View ID="View1" runat="server">
<asp:Panel ID="Panel3" runat="server" Height="501px">
<table width="100%">
<tr>
<td align="right" class="style4"><hr />
<asp:Button ID="btnAddBatchStudentLink" runat="server" CausesValidation="False"
OnClick="btnAddBatchStudentLink_Click"
Text="Add Student - Batch Linking" />
<hr /></td>
</tr>
<tr>
<td align="center" width="100%">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="batch_stu_link_id"
OnPageIndexChanging="GridView1_PageIndexChanging"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
OnSorting="GridView1_Sorting" Style="text-align: center">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="unique_name" HeaderText="Unique Name"
SortExpression="unique_name" />
<asp:BoundField DataField="batch_name" HeaderText="Batch Name"
SortExpression="batch_name" />
<asp:BoundField DataField="remarks" HeaderText="Remarks"
SortExpression="remarks" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="26px" ImageUrl="~/Images/btnedit.png" Width="25px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" runat="server" CommandName="Delete"
Height="25px" ImageUrl="~/Images/btndelete.png" Width="26px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView><hr />
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="501px">
<table class="style1">
<tr>
<td align="center" class="style2" colspan="2" style="font-size: x-large; font-family: 'Lucida Fax';
font-weight: bold; color: #800080; text-decoration: blink">
<hr style="height: -15px" />
<i>Student - Batch Linking</i><hr style="height: -15px" />
</td>
</tr>
<tr>
<td align="right" class="style3" colspan="2" style="color: #FF0000">
* Stands For Mandatory Fields </td>
</tr>
<tr>
<td align="right" class="style3">
Student Unique Name :</td>
<td>
<asp:DropDownList ID="ddlStudentUniqueName" runat="server"
DataTextField="unique_name" DataValueField="stu_id">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Batch :
</td>
<td>
<asp:DropDownList ID="ddlBatchName" runat="server" DataTextField="batch_name"
DataValueField="batch_id" AutoPostBack="True"
onselectedindexchanged="ddlBatchName_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right" class="style3">
Remarks :
</td>
<td>
<asp:TextBox ID="txtRemarks" runat="server" TextMode="MultiLine" Width="175px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2"><hr />
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="batch_detail_id"
OnPageIndexChanging="GridView1_PageIndexChanging" OnSorting="GridView1_Sorting"
PageSize="5" Style="text-align: center">
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="batch_name" HeaderText="Batch Name"
SortExpression="batch_name" />
<asp:BoundField DataField="day" HeaderText="Day" SortExpression="day" />
<asp:BoundField DataField="time_from_grid" HeaderText="From Time"
SortExpression="time_from_grid" />
<asp:BoundField DataField="time_to_grid" HeaderText="To Time"
SortExpression="time_to_grid" />
<asp:BoundField DataField="category_id" HeaderText="Course Category"
SortExpression="category_id" />
<asp:BoundField DataField="course_name" HeaderText="Course Name"
SortExpression="course_name" />
<asp:BoundField DataField="faculty_name" HeaderText="Faculty Name"
SortExpression="faculty_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkBatchStudentLink" runat="server" Checked='<%# Bind("status") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center"><hr />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
<asp:Button ID="btnUpdate" runat="server" Text="Update"
onclick="btnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel"
onclick="btnCancel_Click" /><hr />
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td>
</tr>
</table>
</asp:Panel>
</asp:View>
</asp:MultiView>
</asp:Content>
--------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Configuration;
using System.Data;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class BranchUser_StudentBatchLinking : System.Web.UI.Page
{
#region "Variables And Objects"
DatabaseLayer db_obj = new DatabaseLayer();
BusinessLogic bl_obj = new BusinessLogic();
string query = string.Empty;
int row_affected = 0;
#endregion
#region "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select batch_student_linking_mst.* , student_info.unique_name , batch_master.batch_name from batch_student_linking_mst , student_info , batch_master where batch_student_linking_mst.stu_id = student_info.stu_id and batch_master.batch_id = batch_student_linking_mst.batch_id and batch_student_linking_mst.inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and batch_student_linking_mst.branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView1.DataSource = dt_grid_display;
GridView1.DataBind();
}
void Fill_batch_name()
{
query = "select batch_id,batch_name from batch_master where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by batch_id";
DataTable dt_ddlBatchName = db_obj.ReturnDataTable(query);
ddlBatchName.DataSource = dt_ddlBatchName;
ddlBatchName.DataBind();
bl_obj.FillSelectAny(ddlBatchName);
}
void Fill_Student_unique_name()
{
query = "select stu_id,unique_name from student_info where inst_login_id = '" + Convert.ToString(Session["inst_login_id"]) + "' and branch_unique_id = " + Convert.ToInt16(Session["branch_unique_id"]) + " order by stu_id";
DataTable dt_ddlStudentUniqueName = db_obj.ReturnDataTable(query);
ddlStudentUniqueName.DataSource = dt_ddlStudentUniqueName;
ddlStudentUniqueName.DataBind();
bl_obj.FillSelectAny(ddlStudentUniqueName);
}
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["inst_login_id"] == null || Session["branch_unique_id"] == null || Session["branch_id"] == null)
Response.Redirect("../Home.aspx");
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = Convert.ToString(Session["inst_login_id"]) + " Welcomes " + Convert.ToString(Session["branch_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnAddBatchStudentLink_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
Fill_Student_unique_name();
Fill_batch_name();
ddlStudentUniqueName.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void ddlBatchName_SelectedIndexChanged(object sender, EventArgs e)
{
query = "select batch_detail.* , convert(varchar(5),batch_detail.time_from,108)[time_from_grid],convert(varchar(5),batch_detail.time_to,108)[time_to_grid],batch_master.batch_name,course_category.category_id , course_master.course_name , faculty_master.faculty_name,convert(bit,'true') [status] from batch_detail, batch_master , course_category , course_master , faculty_master where batch_master.batch_id = batch_detail.batch_id and course_category.course_category_id = batch_detail.course_cat_id and course_master.course_id = batch_detail.course_id and faculty_master.faculty_id = batch_detail.faculty_id and batch_master.batch_id = " + ddlBatchName.SelectedValue + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView2.DataSource = dt_grid_display;
GridView2.DataBind();
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
query = "update batch_student_linking_mst set remarks = '" + txtRemarks.Text + "' where batch_stu_link_id = " + Convert.ToString(ViewState["key"]) + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
//query = "delete from batch_student_linking_dtl where batch_stu_link_id = " + Convert.ToString(ViewState["key"]) + "";
//row_affected = db_obj.ExecuteQuery(query);
try
{
string query_batch_stu_link_id = "select scope_identity() from batch_student_linking_mst";
string batch_stu_link_id = db_obj.ExecuteScaler(query_batch_stu_link_id);
for (int i = 0; i < GridView2.Rows.Count; i++)
{
/******* Problem regarding to get Identity ***************************/
CheckBox chkBatchStudentLink = (CheckBox)GridView2.Rows[i].FindControl("chkBatchStudentLink");
int status = 0;
if (chkBatchStudentLink.Checked)
{
status = 1;
}
else
{
status = 0;
}
//if (chkBatchStudentLink.Checked)
//{
//string query_dtl = "insert into batch_student_linking_dtl (batch_stu_link_id,batch_detail_id) values (5 , " + GridView2.DataKeys[i].Value.ToString() + ")";
string query_dtl = "update batch_student_linking_dtl set status = " + status + " where batch_stu_link_id = " + Convert.ToString(ViewState["key"]) + " and batch_detail_id = " + GridView2.DataKeys[i].Value.ToString() + " ";
row_affected = db_obj.ExecuteQuery(query_dtl);
//}
}
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Detail Level Transcation can not completed...";
}
/********* Code For Change Color **************/
//GridViewRow gr = (GridViewRow)GridView2.Rows[Convert.ToInt16(ViewState["edit_index"])];
//gr.BackColor = System.Drawing.Color.Black;
/********* Code For Change Color **************/
}
catch
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "insert into batch_student_linking_mst (inst_login_id,branch_unique_id,stu_id,batch_id,remarks) values ('" + Convert.ToString(Session["inst_login_id"]) + "'," + Convert.ToInt16(Session["branch_unique_id"]) + "," + ddlStudentUniqueName.SelectedValue + "," + ddlBatchName.SelectedValue + ",'" + txtRemarks.Text + "')";
string query_dtl = string.Empty;
try
{
row_affected = db_obj.ExecuteQuery(query);
try
{
string query_batch_stu_link_id = "select scope_identity() from batch_student_linking_mst";
string batch_stu_link_id = db_obj.ExecuteScaler(query_batch_stu_link_id);
for (int i = 0; i < GridView2.Rows.Count; i++)
{
/******* Problem regarding to get Identity ***************************/
CheckBox chkBatchStudentLink = (CheckBox)GridView2.Rows[i].FindControl("chkBatchStudentLink");
int status = 0;
if (chkBatchStudentLink.Checked)
{
status = 1;
}
else
{
status = 0;
}
query_dtl = "insert into batch_student_linking_dtl (batch_stu_link_id,batch_detail_id,status) values (8 , " + GridView2.DataKeys[i].Value.ToString() + "," + status + ")";
row_affected = db_obj.ExecuteQuery(query_dtl);
}
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
Initial_settings();
}
catch
{
lblStatus.Text = "Your Detail Level Transcation can not completed...";
}
}
catch
{
lblStatus.Text = "Your Master Level Transcation can not completed...";
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
//if (e.SortDirection.ToString() == "Ascending")
//else
//{
//}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from batch_student_linking_mst where batch_stu_link_id = " + GridView1.DataKeys[e.RowIndex].Value + "";
try
{
row_affected = db_obj.ExecuteQuery(query);
if (row_affected > 0)
{
lblStatus.Text = "Your Transcation successfully completed...";
}
else
{
lblStatus.Text = "Your Transcation successfully completed but nothing changed...";
}
}
catch (Exception ex)
{
lblStatus.Text = "Your Transcation can not completed...";
}
Initial_settings();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
ViewState["key"] = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
query = "select * from batch_student_linking_mst where batch_stu_link_id = " + GridView1.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
Fill_page_dtl_controls(dt_grid_display);
MultiView1.ActiveViewIndex = 1;
ddlStudentUniqueName.Enabled = false;
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
void Fill_page_controls(DataTable dt_local)
{
Fill_Student_unique_name();
ddlStudentUniqueName.SelectedValue = Convert.ToString(dt_local.Rows[0]["stu_id"]);
Fill_batch_name();
ddlBatchName.SelectedValue = Convert.ToString(dt_local.Rows[0]["batch_id"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void Fill_page_dtl_controls(DataTable dt_local)
{
query = "select distinct batch_student_linking_dtl.status,batch_detail.* , convert(varchar(5),batch_detail.time_from,108)[time_from_grid],convert(varchar(5),batch_detail.time_to,108)[time_to_grid],batch_master.batch_name," +
" course_category.category_id , course_master.course_name , faculty_master.faculty_name from batch_detail, batch_master , course_category , course_master , faculty_master ,batch_student_linking_mst ," +
" batch_student_linking_dtl where batch_student_linking_dtl.batch_detail_id = batch_detail.batch_detail_id and batch_student_linking_mst.batch_id = batch_master.batch_id and batch_master.batch_id = batch_detail.batch_id and course_category.course_category_id = batch_detail.course_cat_id" +
" and course_master.course_id = batch_detail.course_id and faculty_master.faculty_id = batch_detail.faculty_id and batch_student_linking_mst.batch_stu_link_id = batch_student_linking_dtl.batch_stu_link_id" +
" and batch_student_linking_mst.batch_stu_link_id = " + Convert.ToString(ViewState["key"]) + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView2.DataSource = dt_grid_display;
GridView2.DataBind();
}
#endregion
}
Database SQL Query:
________________________________________________________create table batch_master
(
batch_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
batch_name nvarchar(50),
remarks nvarchar(50),
)
create table course_master
(
course_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
course_name nvarchar(50),
remarks nvarchar(50),
course_cat_id int,
fees nvarchar(50),
)
create table faculty_master (
faculty_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
faculty_name nvarchar(50),
faculty_address nvarchar(50),
faculty_phone nvarchar(50),
faculty_email nvarchar(50),
faculty_qualification nvarchar(50),
remarks nvarchar(50),
)
create table batch_detail
(
batch_id int,
inst_login_id nvarchar(50),
branch_unique_id int,
day nvarchar(50),
time_from nvarchar(50),
time_to nvarchar(50),
course_cat_id int,
course_id int,
faculty_id int,
remarks nvarchar(50),
)
create table course_category
(
course_category_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
category_id nvarchar(50),
remarks nvarchar(50),
)
create table Fees
(
fees_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
stu_id int,
fees_date nvarchar(50),
fees nvarchar(50),
remarks nvarchar(50),
)
create table fees_rule
(
rule_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
rule_name nvarchar(50),
rule_days nvarchar(50),
remarks nvarchar(50),
)
create table student_course_selection
(
course_selection_id int identity(1,1),
inst_login_id nvarchar(50),
branch_unique_id int,
stu_id int,
course_category_id int,
course_id int,
course_fees nvarchar(50),
remarks nvarchar(50),
)
create table student_payment
(
student_payment_id int identity(1,1) primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
stu_id int,
rule_id int,
amount nvarchar(50),
date nvarchar(50),
remarks nvarchar(50),
)
create table batch_student_linking_mst
(
batch_stu_link_id int identity(1,1) Primary key,
inst_login_id nvarchar(50),
branch_unique_id int,
stu_id int,
batch_id int,
remarks nvarchar(50),
)
create table batch_student_linking_dtl
(
batch_stu_link_id int,
batch_detail_id int,
status nvarchar(50),
)
If you wish to learn further about Institute Management System, then I suggest you go through this interesting video ?
can u tell me .. print all delivery iin one day
ReplyDeleteCan u make a application form for me. I will paid
ReplyDeleteMail me immediately ashutosian@gmail.com
ReplyDelete