protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e) { try { btnSave.Enabled = true; btnSave.Attributes.Add("bgcolor", "#848484"); Controls objControls = new Controls(); StudentBL objStudentBL = new StudentBL(); ApplicationResult objResults = new ApplicationResult(); if (e.CommandName.ToString() == "Edit1") { ViewState["StudentMID"] = Convert.ToInt32(e.CommandArgument.ToString()); objResults = objStudentBL.Student_Select(Convert.ToInt32(ViewState["StudentMID"].ToString()), 0); if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { ViewState["DivisionName"] = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTDIVISIONTID].ToString(); #region Find DivisionName DivisionTBL objDivision = new DivisionTBL(); ApplicationResult objResultsDivision = new ApplicationResult(); objResultsDivision = objDivision.DivisionT_Select_By_DivisionTID(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTDIVISIONTID].ToString())); if (objResultsDivision != null) { if (objResultsDivision.resultDT.Rows.Count > 0) { ViewState["Division"] = objResultsDivision.resultDT.Rows[0][DivisionTBO.DIVISIONT_DIVISIONNAME].ToString(); } } #endregion #region Find SectionName SectionBL objSection = new SectionBL(); ApplicationResult objResultsSection = new ApplicationResult(); objResultsSection = objSection.Section_Select(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTSECTIONID].ToString())); if (objResultsSection != null) { if (objResultsSection.resultDT.Rows.Count > 0) { ViewState["SectionName"] = objResultsSection.resultDT.Rows[0][SectionBO.SECTION_SECTIONNAME].ToString(); } } #endregion #region Find Class ClassBL objClass = new ClassBL(); ApplicationResult objResultsClass = new ApplicationResult(); objResultsClass = objClass.Class_Select(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTCLASSID].ToString())); if (objResultsClass != null) { if (objResultsClass.resultDT.Rows.Count > 0) { ViewState["ClassMID"] = objResultsClass.resultDT.Rows[0][ClassBO.CLASS_CLASSMID].ToString(); ViewState["ClassName"] = objResultsClass.resultDT.Rows[0][ClassBO.CLASS_CLASSNAME].ToString(); } } #endregion ViewState["AcademicYear"] = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTYEAR].ToString(); } } } } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }
protected void gvDivision_OnRowCommand(object sender, GridViewCommandEventArgs e) { ApplicationResult objResults = new ApplicationResult(); DivisionTBL objDivisionTBL = new DivisionTBL(); ViewState["DivisionTID"] = e.CommandArgument.ToString(); Controls objControls = new Controls(); try { if (e.CommandName.ToString() == "EditDivision") { if (ViewState["Mode"].ToString() == "Save") { // GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); DataTable dtTaskTemp = (DataTable)ViewState["Division"]; //txtDivisionName.Text= dtTaskTemp.Rows[0][1].ToString(); //txtDivisionName.Text = Convert.ToString(row.RowIndex); ViewState["DivisionDatatableTID"] = e.CommandArgument.ToString(); string strFilter = "DivisionTID = '" + e.CommandArgument.ToString() + "'"; DataRow[] results = dtTaskTemp.Select(strFilter); if (results.CopyToDataTable().Rows.Count > 0) { txtDivisionName.Text = results.CopyToDataTable().Rows[0][1].ToString(); } ViewState["DivisionMode"] = "Edit"; } else { objResults = objDivisionTBL.DivisionT_Select_By_DivisionTID(Convert.ToInt32(ViewState["DivisionTID"].ToString())); if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { txtDivisionName.Text = objResults.resultDT.Rows[0][DivisionTBO.DIVISIONT_DIVISIONNAME].ToString(); ViewState["DivisionMode"] = "Edit"; } } } } else if (e.CommandName == "DeleteDivision") { if (ViewState["Mode"].ToString() == "Save") { GridViewRow row = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); DataTable dtTaskTemp = (DataTable)ViewState["Division"]; dtTaskTemp.Rows.RemoveAt(row.RowIndex); dtTaskTemp.AcceptChanges(); ViewState["Division"] = dtTaskTemp; gvDivision.DataSource = (DataTable)ViewState["Division"]; gvDivision.DataBind(); } else { objResults = objDivisionTBL.DivisionT_Delete(Convert.ToInt32(e.CommandArgument.ToString())); if (objResults != null) { if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS) { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Division Deleted Successfully.');</script>"); } else { ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('There are Division(s) associated with this Student. To delete this Divisions you need to delete Student(s) first.');</script>"); } } objResults = objDivisionTBL.DivisionT_Select_DivisionName_By_Class(Convert.ToInt32(ViewState["ClassMID"].ToString())); if (objResults != null) { // ViewState["Division"] = objResults.resultDT; // gvDivision.DataSource = (DataTable)ViewState["Division"]; gvDivision.DataSource = objResults.resultDT; gvDivision.DataBind(); } } } } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }
protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e) { try { Controls objControls = new Controls(); StudentBL objStudentBL = new StudentBL(); ApplicationResult objResults = new ApplicationResult(); if (e.CommandName.ToString() == "Edit1") { ViewState["StudentMID"] = Convert.ToInt32(e.CommandArgument.ToString()); divStudentPanel.Visible = true; objResults = objStudentBL.Student_Select(Convert.ToInt32(ViewState["StudentMID"].ToString()), 0); divStudentPanel.Visible = true; if (objResults != null) { if (objResults.resultDT.Rows.Count > 0) { ViewState["DivisionName"] = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTDIVISIONTID].ToString(); #region Find DivisionName DivisionTBL objDivision = new DivisionTBL(); ApplicationResult objResultsDivision = new ApplicationResult(); objResultsDivision = objDivision.DivisionT_Select_By_DivisionTID(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTDIVISIONTID].ToString())); if (objResultsDivision != null) { if (objResultsDivision.resultDT.Rows.Count > 0) { ViewState["Division"] = objResultsDivision.resultDT.Rows[0][DivisionTBO.DIVISIONT_DIVISIONNAME].ToString(); } } #endregion #region Find SectionName SectionBL objSection = new SectionBL(); ApplicationResult objResultsSection = new ApplicationResult(); objResultsSection = objSection.Section_Select(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTSECTIONID].ToString())); if (objResultsSection != null) { if (objResultsSection.resultDT.Rows.Count > 0) { ViewState["SectionName"] = objResultsSection.resultDT.Rows[0][SectionBO.SECTION_SECTIONNAME].ToString(); } } #endregion #region Find Class ClassBL objClass = new ClassBL(); ApplicationResult objResultsClass = new ApplicationResult(); objResultsClass = objClass.Class_Select(Convert.ToInt32(objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTCLASSID].ToString())); if (objResultsClass != null) { if (objResultsClass.resultDT.Rows.Count > 0) { ViewState["ClassMID"] = objResultsClass.resultDT.Rows[0][ClassBO.CLASS_CLASSNAME].ToString(); } } #endregion lblAdmissionNo.Text = objResults.resultDT.Rows[0][StudentBO.STUDENT_ADMISSIONNO].ToString(); lblCurrentGrNo.Text = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTGRNO].ToString(); lblStudentNameEng.Text = objResults.resultDT.Rows[0][StudentBO.STUDENT_STUDENTLASTNAMEENG].ToString() + " " + objResults.resultDT.Rows[0][StudentBO.STUDENT_STUDENTFIRSTNAMEENG].ToString() + " " + objResults.resultDT.Rows[0][StudentBO.STUDENT_STUDENTMIDDLENAMEENG].ToString(); lblClassDivision.Text = ViewState["ClassMID"].ToString() + "-" + ViewState["Division"].ToString(); lblCurrentSection.Text = ViewState["SectionName"].ToString(); lblAcademicYear.Text = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTYEAR].ToString(); ViewState["AcademicYear"] = objResults.resultDT.Rows[0][StudentBO.STUDENT_CURRENTYEAR].ToString(); } } GridDataBind(); } } catch (Exception ex) { logger.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>"); } }