/// <summary>
    /// Delete Mapped Faculties Then Add In Un - Mapped (University And DMS) Faculty GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdFinalUniAndDMSFaculty_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int rowIndex = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "DeleteRow")
        {
            DataTable dtFinalUniAndDMSExamFaculty = VsdtFinalUniAndDMSExamFaculty;
            DataRow   drFinalUniAndDMSExamFaculty = dtFinalUniAndDMSExamFaculty.Rows[rowIndex];

            string UnivFacultyName = drFinalUniAndDMSExamFaculty["UnivFacultyName"].ToString();

            DataRow[] drUniv = VsdtUniExamFaculty.Select("SoftDataFacultyName='" + UnivFacultyName + "'");

            if (drUniv.Count() <= 0)
            {
                DataRow drUniExamFaculty = VsdtUniExamFaculty.NewRow();
                drUniExamFaculty["SoftDataFacultyCD"]   = 0;
                drUniExamFaculty["SoftDataFacultyName"] = UnivFacultyName;
                VsdtUniExamFaculty.Rows.Add(drUniExamFaculty);
                VsdtUniExamFaculty.DefaultView.Sort = "SoftDataFacultyName Asc";
                grdUniversityExamFaculty.DataSource = VsdtUniExamFaculty;
                grdUniversityExamFaculty.DataBind();
            }

            int    dmsFacultyCD   = Convert.ToInt32(drFinalUniAndDMSExamFaculty["FacultyCD"]);
            string dmsFacultyName = drFinalUniAndDMSExamFaculty["DMSFacultyName"].ToString();

            DataRow[] dr = VsdtDMSExamFaculty.Select("FacultyName='" + dmsFacultyName + "'");

            if (dr.Count() <= 0)
            {
                DataRow drDMSExamFaculty = VsdtDMSExamFaculty.NewRow();
                drDMSExamFaculty["FacultyCD"]   = dmsFacultyCD;
                drDMSExamFaculty["FacultyName"] = dmsFacultyName;
                VsdtDMSExamFaculty.Rows.Add(drDMSExamFaculty);
                VsdtDMSExamFaculty.DefaultView.Sort = "FacultyName Asc";
                grdDMSExamFaculty.DataSource        = VsdtDMSExamFaculty;
                grdDMSExamFaculty.DataBind();
            }

            VsdtFinalUniAndDMSExamFaculty.Rows.RemoveAt(rowIndex);

            grdFinalUniAndDMSFaculty.DataSource = VsdtFinalUniAndDMSExamFaculty;
            grdFinalUniAndDMSFaculty.DataBind();


            if (grdUniversityExamFaculty.Rows.Count > 0 || grdDMSExamFaculty.Rows.Count > 0)
            {
                btnAdd.Visible      = true;
                divUnMapped.Visible = true;
            }

            if (grdFinalUniAndDMSFaculty.Rows.Count <= 0)
            {
                divMapped.Visible = false;
            }
        }
    }
    /// <summary>
    /// Add Both Un - Mapped (University And DMS) Faculty In Mapped Faculties GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "";

        VsdtUniAndDMSExamFaculty = null;
        VsdtUniAndDMSExamFaculty = new DataTable();

        bool uniCheckedOrNot = false;
        bool dmsCheckedOrNot = false;

        DataTable dtDMSRowIndex = new DataTable();

        if (VsdtUniAndDMSExamFaculty == null || VsdtUniAndDMSExamFaculty.Rows.Count <= 0)
        {
            VsdtUniAndDMSExamFaculty = new DataTable();
            VsdtUniAndDMSExamFaculty.Columns.Add("ExamYear", typeof(int));
            VsdtUniAndDMSExamFaculty.Columns.Add("ExamSession", typeof(string));
            VsdtUniAndDMSExamFaculty.Columns.Add("ExamSessionID", typeof(int));
            VsdtUniAndDMSExamFaculty.Columns.Add("UnivFacultyName", typeof(string));
            VsdtUniAndDMSExamFaculty.Columns.Add("FacultyCD", typeof(int));
            VsdtUniAndDMSExamFaculty.Columns.Add("DMSFacultyName", typeof(string));
        }

        foreach (GridViewRow gvUniRow in grdUniversityExamFaculty.Rows)
        {
            CheckBox chkUniExamFaculty = gvUniRow.FindControl("chkUniExamFaculty") as CheckBox;

            if (chkUniExamFaculty.Checked == true)
            {
                Label lblSoftDataFacultyCD   = gvUniRow.FindControl("lblSoftDataFacultyCD") as Label;
                Label lblSoftDataFacultyName = gvUniRow.FindControl("lblSoftDataFacultyName") as Label;

                DataRow drUniAndDMSExamFaculty = VsdtUniAndDMSExamFaculty.NewRow();
                drUniAndDMSExamFaculty["ExamYear"]        = Convert.ToInt32(ddlExamYear.SelectedItem.Text);
                drUniAndDMSExamFaculty["ExamSession"]     = ddlSession.SelectedItem.Text;
                drUniAndDMSExamFaculty["ExamSessionID"]   = Convert.ToInt32(ddlSession.SelectedValue);
                drUniAndDMSExamFaculty["UnivFacultyName"] = lblSoftDataFacultyName.Text;

                foreach (GridViewRow gvDMSRow in grdDMSExamFaculty.Rows)
                {
                    CheckBox chkDMSExamFaculty = gvDMSRow.FindControl("chkDMSExamFaculty") as CheckBox;
                    if (chkDMSExamFaculty.Checked == true)
                    {
                        Label lblFacultyCD   = gvDMSRow.FindControl("lblFacultyCD") as Label;
                        Label lblFacultyName = gvDMSRow.FindControl("lblFacultyName") as Label;

                        drUniAndDMSExamFaculty["FacultyCD"]      = Convert.ToInt32(lblFacultyCD.Text);
                        drUniAndDMSExamFaculty["DMSFacultyName"] = lblFacultyName.Text;
                        VsdtUniAndDMSExamFaculty.Rows.Add(drUniAndDMSExamFaculty);

                        DataRow[] r1 = VsdtUniExamFaculty.Select("SoftDataFacultyName='" + lblSoftDataFacultyName.Text + "'");
                        if (r1.Count() > 0)
                        {
                            int rowIndex1 = VsdtUniExamFaculty.Rows.IndexOf(r1[0]);
                            VsdtUniExamFaculty.Rows.RemoveAt(rowIndex1);
                            grdUniversityExamFaculty.DataSource = VsdtUniExamFaculty;
                            grdUniversityExamFaculty.DataBind();
                        }

                        DataRow[] r2 = VsdtDMSExamFaculty.Select("FacultyName='" + lblFacultyName.Text + "'");
                        if (r2.Count() > 0)
                        {
                            int rowIndex = VsdtDMSExamFaculty.Rows.IndexOf(r2[0]);

                            if (!dtDMSRowIndex.Columns.Contains("DMSFacultyName"))
                            {
                                dtDMSRowIndex.Columns.Add("DMSFacultyName", typeof(string));
                            }

                            DataRow drDMSRowIndex = dtDMSRowIndex.NewRow();
                            drDMSRowIndex["DMSFacultyName"] = lblFacultyName.Text;
                            dtDMSRowIndex.Rows.Add(drDMSRowIndex);
                        }
                        dmsCheckedOrNot = true;
                    }
                }
                uniCheckedOrNot = true;
            }
        }

        if (uniCheckedOrNot == false)
        {
            lblMsg.Text = "Select Atleast One University Exam Faculty.";
            return;
        }

        if (dmsCheckedOrNot == false)
        {
            lblMsg.Text = "Select Atleast One DMS Exam Faculty.";
            VsdtUniAndDMSExamFaculty = null;
            VsdtUniAndDMSExamFaculty = new DataTable();
            return;
        }

        if (uniCheckedOrNot == true && dmsCheckedOrNot == true)
        {
            foreach (DataRow dmsRow in dtDMSRowIndex.Rows)
            {
                DataRow[] r = VsdtDMSExamFaculty.Select("FacultyName='" + dmsRow["DMSFacultyName"] + "'");
                if (r.Count() > 0)
                {
                    int rowIndex = VsdtDMSExamFaculty.Rows.IndexOf(r[0]);
                    VsdtDMSExamFaculty.Rows.RemoveAt(rowIndex);
                    grdDMSExamFaculty.DataSource = VsdtDMSExamFaculty;
                    grdDMSExamFaculty.DataBind();
                }
            }

            if (VsdtFinalUniAndDMSExamFaculty == null || VsdtFinalUniAndDMSExamFaculty.Rows.Count <= 0)
            {
                grdFinalUniAndDMSFaculty.DataSource = VsdtFinalUniAndDMSExamFaculty = VsdtUniAndDMSExamFaculty;
                grdFinalUniAndDMSFaculty.DataBind();
            }
            else
            {
                foreach (DataRow gvFinalRow in VsdtUniAndDMSExamFaculty.Rows)
                {
                    DataRow dr = VsdtFinalUniAndDMSExamFaculty.NewRow();
                    dr["ExamYear"]        = gvFinalRow["ExamYear"];
                    dr["ExamSession"]     = gvFinalRow["ExamSession"];
                    dr["ExamSessionID"]   = gvFinalRow["ExamSessionID"];
                    dr["UnivFacultyName"] = gvFinalRow["UnivFacultyName"];
                    dr["FacultyCD"]       = gvFinalRow["FacultyCD"];
                    dr["DMSFacultyName"]  = gvFinalRow["DMSFacultyName"];
                    VsdtFinalUniAndDMSExamFaculty.Rows.Add(dr);
                }
                grdFinalUniAndDMSFaculty.DataSource = VsdtFinalUniAndDMSExamFaculty;
                grdFinalUniAndDMSFaculty.DataBind();
            }
        }

        if (grdUniversityExamFaculty.Rows.Count <= 0 && grdDMSExamFaculty.Rows.Count <= 0)
        {
            btnAdd.Visible      = false;
            divUnMapped.Visible = false;
        }

        if (grdFinalUniAndDMSFaculty.Rows.Count > 0)
        {
            divMapped.Visible = true;
        }
    }