ASP.NET C# | Institute Management System Project Tutorial in HINDI | Part-06
Hello everyone welcome back .....
Institute Management System Project in asp.net Part-6 source code .
First watch my video its very helpful ...
Institute Management System Project in asp.net Part-6 source code .
First watch my video its very helpful ...
Step1- Create a MasterPage in "MasterPages" folder and give name "AdminMasterPage.master".
-------------------------------------------Source Code-------------------------------------------------
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="AdminMasterPage.master.cs" Inherits="MasterPages_AdminMasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="JS-ADMIN-USER/New.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
window.history.forward(1);
</script>
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body onload="javascript:window.history.forward(1);">
<table id="table_mene" width="100%">
<tr>
<td align="left">
</td>
</tr>
<tr>
<td align="center">
<ul id="milonicmenu1">
<li><a href="">Home</a> </li>
<li><a href="../AdminUser/Branch_Master.aspx">Branch Master</a> </li>
<li><a href="../Reports/Reports.aspx">Reports</a> </li>
<li><a href="../Default.aspx">Sign Out</a> </li>
</td>
</tr>
<tr>
<td align="left">
<asp:Label ID="lblUserName" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<br />
<script type="text/javascript">
_menuCloseDelay = 500;
_menuOpenDelay = 100;
_subOffsetTop = 0;
_subOffsetLeft = -2;
with (menuStyle = new mm_style()) {
bordercolor = "#999999";
borderstyle = "solid";
borderwidth = 1;
fontfamily = "Verdana, Tahoma, Arial";
fontsize = "80%";
fontstyle = "normal";
headerbgcolor = "#ffffff";
headercolor = "#000000";
offbgcolor = "#eeeeee";
offcolor = "#000000";
onbgcolor = "#ddffdd";
oncolor = "#000099";
outfilter = "randomdissolve(duration=0.3)";
overfilter = "Fade(duration=0.2);Alpha(opacity=100);Shadow(color=#777777', Direction=135, Strength=3)";
padding = 6;
pagebgcolor = "#82B6D7";
pagecolor = "black";
separatorcolor = "#999999";
separatorsize = 1;
subimage = "arrow.gif";
subimagepadding = 2;
}
with (menuStyle2 = new mm_style()) {
bordercolor = "#999999";
borderstyle = "solid";
borderwidth = 1;
fontfamily = "Arial";
fontsize = "14px";
fontstyle = "normal";
offbgcolor = "darkblue";
offcolor = "yellow";
onbgcolor = "#ffffff";
oncolor = "#ff0000";
padding = "6px"
}
// syntax: buildListMenu("id of list", "menu style name", "main menu properties")
buildListMenu("milonicmenu1", "menuStyle", "alwaysvisible=true;orientation='horizontal';top=5;left=335;")
buildListMenu("milonicmenu2", "menuStyle2", "alwaysvisible=true;orientation='vertical';top=100;left=310;")
buildListMenu("milonicpopupmenu", "menuStyle", "")
</script>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Step-2: Create a Folder under in MasterPages Folder give name as " JS-ADMIN-USER "
JS AdminUser folder |
you can download "JS-ADMIN-USER" folder Click Here
this folder contains some JS fileStep-3: Add new webpage in AdminUser Folder that name is " Branch_Master.aspx" and select a master page that name is AdminMasterPage.master .
-----------------------------------Design source code-----------------------------
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminMasterPage.master" AutoEventWireup="true" CodeFile="Branch_Master.aspx.cs" Inherits="AdminUser_Branch_Master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style10
{
width: 100%;
}
.style11
{
}
.style13
{
width: 384px;
}
.style15
{
text-align: center;
font-weight: bold;
font-style: italic;
color: #993399;
font-family: "Lucida Fax";
font-size: x-large;
}
</style>
<script src="../MasterPages/JS-ADMIN-USER/listmenus.js" type="text/javascript"></script>
<script src="../MasterPages/JS-ADMIN-USER/menu_data.js" type="text/javascript"></script>
<script src="../MasterPages/JS-ADMIN-USER/New.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
window.history.forward(1);
</script>
<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 align="center" class="style10">
<tr>
<td align="center">
<table class="style10">
<tr>
<td align="left">
Status : <asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:Panel ID="Panel2" runat="server" Height="558px">
<table class="style10"
style="background-image: url('../Images/Background.bmp'); >
<tr>
<td align="right" align="right">
<caption align="right">
<hr />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="btnAdd" runat="server" CausesValidation="False"
OnClick="btnAdd_Click" Text="Add New Branch" />
<hr />
</td>
</tr>
<tr>
<td align="center"
style="color: #800080; text-decoration: blink; font-weight: bold; font-style: italic; font-size: x-large; font-family: 'Lucida Bright';">
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="branch_unique_id"
OnPageIndexChanging="GridView2_PageIndexChanging"
OnRowDeleting="GridView2_RowDeleting" OnRowEditing="GridView2_RowEditing"
OnSorting="GridView2_Sorting">
<Columns>
<asp:BoundField DataField="branch_id" HeaderText="Branch ID"
SortExpression="branch_id" />
<asp:BoundField DataField="branch_name" HeaderText="Branch Name"
SortExpression="branch_name" />
<asp:BoundField DataField="branch_phone" HeaderText="Phone"
SortExpression="branch_phone" />
<asp:BoundField DataField="branch_email_id" HeaderText="Email ID"
SortExpression="branch_email_id" />
<asp:BoundField DataField="branch_owner" HeaderText="Owner"
SortExpression="branch_owner" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Edit"
Height="26px" ImageUrl="~/Images/btnedit.png" Width="28px" />
</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>
<EmptyDataTemplate>
<p>
There are no records.........</p>
</EmptyDataTemplate>
</asp:GridView>
<hr />
<br />
</td>
</tr>
</caption>
</table>
</asp:Panel>
</asp:View>
<asp:View ID="View2" runat="server">
<asp:Panel ID="Panel1" runat="server">
<table class="style10" align="center"
style="background-image: url('../Images/Background.bmp')">
<tr>
<td colspan="2" class="style15"
style="background-image: url('../Images/Background.bmp')">Add New Branch</td>
</tr>
<tr>
<td align="right" style="color: #FF0000;" class="style11" colspan="2">
<hr />
* Stands For Mandatory Fields
<hr />
</td>
</tr>
<tr>
<td align="right" class="style13" style="color: #336600;">
* Branch ID :
</td>
<td align="left">
<asp:TextBox ID="txtBranch_id" runat="server" Font-Bold="True"
Font-Names="Verdana" ForeColor="#118A26"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtBranch_id"
ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style13">
* Password :
</td>
<td align="left">
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPassword"
ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style13">
*Name :
</td>
<td align="left">
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtName" ErrorMessage="*"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" class="style13">
Address :
</td>
<td align="left">
<asp:TextBox ID="txtAddress" runat="server" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" class="style13">
Phone Number :
</td>
<td align="left">
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
FilterType="Custom,Numbers" TargetControlID="txtPhone" ValidChars="-">
</cc1:FilteredTextBoxExtender>
</td>
</tr>
<tr>
<td align="right" class="style13">
Email ID :
</td>
<td align="left">
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txtEmail" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmail" ErrorMessage="@"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td align="right" class="style13">
Owner :
</td>
<td align="left">
<asp:TextBox ID="txtOwner" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" class="style13">Remarks : </td>
<td align="left">
<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" Font-Bold="False"
Font-Names="Microsoft Sans Serif" Font-Size="Small" ForeColor="#003300"
OnClick="btnSubmit_Click" Style="cursor: pointer" 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>
</td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
-----------------------------------------------------------------------------------------------------
Step-4: C# Dynamic code for this page ( Branch_Master.aspx.cs )
-------------------------------------------C# coder----------------------------------------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class AdminUser_Branch_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 "Functions"
void Initial_settings()
{
MultiView1.ActiveViewIndex = 0;
query = "select * from branch_master where inst_login_id = '" + Convert.ToString(Session["login_id"]) + "' ";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView2.DataSource = dt_grid_display;
GridView2.DataBind();
}
void BindGridView(string sort_expression, string sort_direction)
{
query = "select * from branch_master order by " + sort_expression + " " + sort_direction + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
GridView2.DataSource = dt_grid_display;
GridView2.DataBind();
}
void Fill_page_controls(DataTable dt_local)
{
//txtPassword.TextMode = TextBoxMode.SingleLine;
txtBranch_id.Text = Convert.ToString(dt_local.Rows[0]["branch_id"]);
txtPassword.Attributes["value"] = Convert.ToString(dt_local.Rows[0]["branch_password"]);
//txtPassword.Text = Convert.ToString(dt_local.Rows[0]["branch_password"]);
txtName.Text = Convert.ToString(dt_local.Rows[0]["branch_name"]);
txtAddress.Text = Convert.ToString(dt_local.Rows[0]["branch_address"]);
txtPhone.Text = Convert.ToString(dt_local.Rows[0]["branch_phone"]);
txtEmail.Text = Convert.ToString(dt_local.Rows[0]["branch_email_id"]);
txtOwner.Text = Convert.ToString(dt_local.Rows[0]["branch_owner"]);
txtRemarks.Text = Convert.ToString(dt_local.Rows[0]["remarks"]);
}
void Enable_disable_page_controls()
{
txtBranch_id.Enabled = false;
}
#endregion
#region "Events"
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label lblUserName = (Label)Page.Master.FindControl("lblUserName");
lblUserName.Text = "Welcome , " + Convert.ToString(Session["login_id"]);
lblStatus.Text = "Page Opened.........";
Initial_settings();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
txtPassword.TextMode = TextBoxMode.Password;
MultiView1.ActiveViewIndex = 1;
bl_obj.ClearControls(View2);
lblStatus.Text = "Add New Branch.........";
bl_obj.ClearControls(txtPassword);
txtBranch_id.Enabled = true;
btnSubmit.Enabled = true;
btnUpdate.Enabled = false;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
query = "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 btnUpdate_Click(object sender, EventArgs e)
{
query = "update branch_master set branch_password = '" + txtPassword.Text + "' , branch_name = '" + txtName.Text + "' , branch_address = '" + txtAddress.Text + "' , branch_phone = '" + txtPhone.Text + "' , branch_email_id = '" + txtEmail.Text + "' , branch_owner = '" + txtOwner.Text + "' , remarks = '" + txtRemarks.Text + "' where branch_unique_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();
/********* 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;
bl_obj.ClearControls(txtPassword);
}
protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
query = "delete from branch_master where branch_unique_id = " + GridView2.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
{
lblStatus.Text = "Your Transcation can not completed...";
}
}
protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
{
/********* Code For Change Color **************/
//ViewState["edit_index"] = e.NewEditIndex;
/********* Code For Change Color **************/
Initial_settings();
query = "select * from branch_master where branch_unique_id = " + GridView2.DataKeys[e.NewEditIndex].Value.ToString() + "";
DataTable dt_grid_display = db_obj.ReturnDataTable(query);
Fill_page_controls(dt_grid_display);
Enable_disable_page_controls();
MultiView1.ActiveViewIndex = 1;
ViewState["key"] = GridView2.DataKeys[e.NewEditIndex].Value.ToString();
btnSubmit.Enabled = false;
btnUpdate.Enabled = true;
}
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView2.PageIndex = e.NewPageIndex;
Initial_settings();
}
protected void GridView2_Sorting(object sender, GridViewSortEventArgs e)
{
if (e.SortDirection.ToString() == "Ascending")
BindGridView(e.SortExpression.ToString(), "asc");
else
BindGridView(e.SortExpression.ToString(), "desc");
}
#endregion
}
-------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment