コード例 #1
0
    /// <summary>
    /// Delete Mapped Exam Then Add In Un - Mapped (University And DMS) Exam GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void grdFinalUniAndDMSMappedExam_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        universityExamModal.Style.Add("display", "none");
        dmsExamModal.Style.Add("display", "none");
        universityRecordsModal.Style.Add("display", "none");

        int rowIndex = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "DeleteRow")
        {
            DataTable dtFinalUniAndDMSExam = VsdtFinalUniAndDMSExam;
            DataRow   drFinalUniAndDMSExam = dtFinalUniAndDMSExam.Rows[rowIndex];

            string UnivFacultyName = drFinalUniAndDMSExam["UnivExamName"].ToString();

            DataRow[] drUniv = VsdtUniExam.Select("ExamName='" + UnivFacultyName + "'");

            if (drUniv.Count() <= 0)
            {
                DataRow drUniExam = VsdtUniExam.NewRow();
                drUniExam["RecordCount"] = 0;
                drUniExam["ExamName"]    = UnivFacultyName;
                VsdtUniExam.Rows.Add(drUniExam);
                VsdtUniExam.DefaultView.Sort         = "ExamName Asc";
                grdUniversityUnMappedExam.DataSource = VsdtUniExam;
                grdUniversityUnMappedExam.DataBind();
            }

            int    dmsExamCD   = Convert.ToInt32(drFinalUniAndDMSExam["DMSExamCD"]);
            string dmsExamName = drFinalUniAndDMSExam["DMSExamName"].ToString();

            DataRow[] dr = VsdtDMSExam.Select("ExamName='" + dmsExamName + "'");

            if (dr.Count() <= 0)
            {
                DataRow drDMSExamFaculty = VsdtDMSExam.NewRow();
                drDMSExamFaculty["Ctrl"]     = dmsExamCD;
                drDMSExamFaculty["ExamName"] = dmsExamName;
                VsdtDMSExam.Rows.Add(drDMSExamFaculty);
                VsdtDMSExam.DefaultView.Sort  = "ExamName Asc";
                grdDMSUnMappedExam.DataSource = VsdtDMSExam;
                grdDMSUnMappedExam.DataBind();
            }

            VsdtFinalUniAndDMSExam.Rows.RemoveAt(rowIndex);

            SaveExamMappingOnDeleteBtn();
            btnShow_Click(sender, e);
            grdFinalUniAndDMSMappedExam.DataSource = VsdtFinalUniAndDMSExam;
            grdFinalUniAndDMSMappedExam.DataBind();


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

            if (grdUniversityUnMappedExam.Rows.Count > 0)
            {
                tblUniversityGridHeader.Visible = true;
                btnShowUnivExam.Enabled         = true;
            }

            if (grdDMSUnMappedExam.Rows.Count > 0)
            {
                tblDMSGridHeader.Visible = true;
                btnShowDMSExam.Enabled   = true;
            }

            if (grdFinalUniAndDMSMappedExam.Rows.Count <= 0)
            {
                divMapped.Visible = false;
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Add Both Un - Mapped (University And DMS) Exam In Mapped Exam GridView
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        lblMsg.Text = "";
        universityExamModal.Style.Add("display", "none");
        dmsExamModal.Style.Add("display", "none");
        universityRecordsModal.Style.Add("display", "none");

        VsdtUniAndDMSExam = null;
        VsdtUniAndDMSExam = new DataTable();

        bool uniCheckedOrNot = false;
        bool dmsCheckedOrNot = false;

        DataTable dtDMSRowIndex = new DataTable();

        if (VsdtUniAndDMSExam == null || VsdtUniAndDMSExam.Rows.Count <= 0)
        {
            VsdtUniAndDMSExam = new DataTable();
            VsdtUniAndDMSExam.Columns.Add("ExamYear", typeof(int));
            VsdtUniAndDMSExam.Columns.Add("ExamSession", typeof(string));
            VsdtUniAndDMSExam.Columns.Add("ExamSessionID", typeof(int));
            VsdtUniAndDMSExam.Columns.Add("FacultyCD", typeof(int));
            VsdtUniAndDMSExam.Columns.Add("UnivExamName", typeof(string));
            VsdtUniAndDMSExam.Columns.Add("DMSExamCD", typeof(int));
            VsdtUniAndDMSExam.Columns.Add("DMSExamName", typeof(string));
        }

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

            if (chkUniExamFaculty.Checked == true)
            {
                Label lblUnivExamName = gvUniRow.FindControl("lblUnivExamName") as Label;
                Label lblTotalRecord  = gvUniRow.FindControl("lblTotalRecord") as Label;

                DataRow drUniAndDMSExamFaculty = VsdtUniAndDMSExam.NewRow();
                drUniAndDMSExamFaculty["ExamYear"]      = Convert.ToInt32(ddlExamYear.SelectedItem.Text);
                drUniAndDMSExamFaculty["ExamSession"]   = ddlSession.SelectedItem.Text;
                drUniAndDMSExamFaculty["ExamSessionID"] = Convert.ToInt32(ddlSession.SelectedValue);
                drUniAndDMSExamFaculty["FacultyCD"]     = Convert.ToInt32(ddlExamFaculty.SelectedValue);
                drUniAndDMSExamFaculty["UnivExamName"]  = lblUnivExamName.Text;

                foreach (GridViewRow gvDMSRow in grdDMSUnMappedExam.Rows)
                {
                    CheckBox chkDMSExamFaculty = gvDMSRow.FindControl("chkDMSExam") as CheckBox;
                    if (chkDMSExamFaculty.Checked == true)
                    {
                        Label lblCtrl        = gvDMSRow.FindControl("lblCtrl") as Label;
                        Label lblDMSExamName = gvDMSRow.FindControl("lblExamName") as Label;

                        drUniAndDMSExamFaculty["DMSExamCD"]   = Convert.ToInt32(lblCtrl.Text);
                        drUniAndDMSExamFaculty["DMSExamName"] = lblDMSExamName.Text;
                        VsdtUniAndDMSExam.Rows.Add(drUniAndDMSExamFaculty);

                        DataRow[] r1 = VsdtUniExam.Select("ExamName='" + lblUnivExamName.Text + "'");
                        if (r1.Count() > 0)
                        {
                            int rowIndex1 = VsdtUniExam.Rows.IndexOf(r1[0]);
                            VsdtUniExam.Rows.RemoveAt(rowIndex1);
                            grdUniversityUnMappedExam.DataSource = VsdtUniExam;
                            grdUniversityUnMappedExam.DataBind();
                        }

                        DataRow[] r2 = VsdtDMSExam.Select("ExamName='" + lblDMSExamName.Text + "'");
                        if (r2.Count() > 0)
                        {
                            int rowIndex = VsdtDMSExam.Rows.IndexOf(r2[0]);

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

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

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

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

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

            if (VsdtFinalUniAndDMSExam == null || VsdtFinalUniAndDMSExam.Rows.Count <= 0)
            {
                grdFinalUniAndDMSMappedExam.DataSource = VsdtFinalUniAndDMSExam = VsdtUniAndDMSExam;
                grdFinalUniAndDMSMappedExam.DataBind();
            }
            else
            {
                foreach (DataRow gvFinalRow in VsdtUniAndDMSExam.Rows)
                {
                    DataRow dr = VsdtFinalUniAndDMSExam.NewRow();
                    dr["ExamYear"]      = gvFinalRow["ExamYear"];
                    dr["ExamSession"]   = gvFinalRow["ExamSession"];
                    dr["ExamSessionID"] = gvFinalRow["ExamSessionID"];
                    dr["FacultyCD"]     = gvFinalRow["FacultyCD"];
                    dr["UnivExamName"]  = gvFinalRow["UnivExamName"];
                    dr["DMSExamCD"]     = gvFinalRow["DMSExamCD"];
                    dr["DMSExamName"]   = gvFinalRow["DMSExamName"];
                    VsdtFinalUniAndDMSExam.Rows.Add(dr);
                }
                grdFinalUniAndDMSMappedExam.DataSource = VsdtFinalUniAndDMSExam;
                grdFinalUniAndDMSMappedExam.DataBind();
            }
        }

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

        if (grdUniversityUnMappedExam.Rows.Count <= 0)
        {
            tblUniversityGridHeader.Visible = false;
            btnShowUnivExam.Enabled         = true;
        }

        if (grdDMSUnMappedExam.Rows.Count <= 0)
        {
            tblDMSGridHeader.Visible = false;
            btnShowDMSExam.Enabled   = false;
        }

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