ADS

Saturday 23 March 2019

ASP.NET C# | Institute Management System Project Tutorial in HINDI | Part-7

ASP.NET C# | Institute Management System Project Tutorial in HINDI |


Step-1:
create a new master page in " MasterPages" folder that page name is " BranchUserMasterPage.master" & write the following HTML tag


 ____________________HTML (Design code)__________________________

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="BranchUserMasterPage.master.cs" Inherits="MasterPages_BranchUserMasterPage" %>

<!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>
    <table id="table_mene" width="100%">
        <tr>
            <td align="left">
            </td>
        </tr>
        <tr>
            <td align="center">
                <ul id="milonicmenu1">
                    <li><a href="../Home.aspx">Home</a> </li>
                    <li><a href="">Student Detail</a>
                        <ul>
                            <li><a href="../BranchUser/Student_info.aspx">Student Information</a></li>
                            <li><a href="../BranchUser/Student_course_selection.aspx">Student Course Selection</a></li>
                            <li><a href="../BranchUser/Student_payment.aspx">Student Payment</a></li>
                            <li><a href="../BranchUser/StudentBatchLinking.aspx">Student - Batch Assign</a></li>
                        </ul>
                    </li>
                    <li><a href="">Batch Detail</a>
                        <ul>
                            <li><a href="../BranchUser/Batch_master.aspx">Add Batch</a></li>
                            <li><a href="../BranchUser/Batch_Detail.aspx">Add Batch Detail</a></li>
                        </ul>
                    </li>
                    <li><a href="">Course Detail</a>
                        <ul>
                            <li><a href="../BranchUser/Course_category.aspx">Add Course Category</a></li>
                            <li><a href="../BranchUser/Course_master.aspx">Course Selection</a></li>
                        </ul>
                    </li>
                    <li><a href="">Fees Detail</a>
                        <ul>
                            <li><a href="../BranchUser/Fees_rule.aspx">Fess Rule</a></li>
                            <li><a href="../BranchUser/Fees.aspx">Fees</a></li>
                        </ul>
                    </li>
                    <li>
                        <li><a href="../BranchUser/Faculty_Master.aspx">Faculty Detail</a></li>
                    </li>
                    
                    <li><a href="../Home.aspx">Sign Out</a> </li>
            </td>
        </tr>
        <br />
        <br />
        <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=205;")
        buildListMenu("milonicmenu2", "menuStyle2", "alwaysvisible=true;orientation='vertical';top=100;left=310;")
        buildListMenu("milonicpopupmenu", "menuStyle", "")

    </script>

    <form id="form1" runat="server">
    <div style="background-image: url('../Images/bg.bmp')">
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

_________________________________________________________________

Step-2:  add new webpage in "BranchUser" that name is " Student_info.aspx

Design code of Student_info.aspx page

---------------------------------------------------------------------------------
<%@ 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" />
                                &nbsp;&nbsp;<asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" />
                                &nbsp;&nbsp;<asp:Button ID="btnCancel" runat="server" CausesValidation="False" OnClick="Cancelbtn"
                                    Text="Cancel" />
                                &nbsp;&nbsp;<hr />
                            </td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </asp:View>
        </asp:MultiView>
    </body>
    </html>
</asp:Content>

---------------------------------------------------------------------------------------------------------


Step-3: C# Code for "Student_info.aspx.cs" page

---------------------------------------------------------------------------------------------------------
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-4: create a new table in that name is " student_info "


create table  student_info
(
stu_id               int   identity(1,1),
inst_login_id nvarchar(50),
branch_unique_id                      int,
Unique_name                            nvarchar(50),
name   nvarchar(50),
address nvarchar(50),
phone nvarchar(50),
email                      nvarchar(50),
refrence          nvarchar(50),
refrence_from nvarchar(50),
remarks nvarchar(50),

)


No comments:

Post a Comment

Popular Posts