Пример #1
0
        protected void gvClass_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                ViewState["ClassMID"] = e.CommandArgument.ToString();
                Controls          objControls   = new Controls();
                ClassBL           objClasstBl   = new ClassBL();
                ApplicationResult objResults    = new ApplicationResult();
                DivisionTBL       objDivisionBl = new DivisionTBL();
                if (e.CommandName.ToString() == "Edit1")
                {
                    objResults = objClasstBl.Class_Select(Convert.ToInt32(ViewState["ClassMID"].ToString()));
                    if (objResults != null)
                    {
                        if (objResults.resultDT.Rows.Count > 0)
                        {
                            ddlSection.SelectedValue = objResults.resultDT.Rows[0][ClassBO.CLASS_SECTIONTID].ToString();
                            txtClassName.Text        = objResults.resultDT.Rows[0][ClassBO.CLASS_CLASSNAME].ToString();
                            txtApprovalNo.Text       = objResults.resultDT.Rows[0][ClassBO.CLASS_APPROVALNO].ToString();
                            txtApprovalDate.Text     = objResults.resultDT.Rows[0][ClassBO.CLASS_APPROVALDATE].ToString();
                            txtNoOfPeriod.Text       = objResults.resultDT.Rows[0][ClassBO.CLASS_NOOFPERIOD].ToString();
                            objResults = objDivisionBl.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();
                            }
                            ViewState["Mode"] = "Edit";
                            PanelGrid_VisibilityMode(2);
                        }
                    }
                }
                if (e.CommandName.ToString() == "Delete1")
                {
                    //objControls.EnableControls(Master.FindControl("ContentPlaceHolder1"));
                    //ApplicationResult objDelete = new ApplicationResult();

                    //objDelete = objClasstBl.Validate_Class_Delete(Convert.ToInt32(ViewState["ClassMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]), ViewState["DivisionName"].ToString());
                    //if (objDelete != null)
                    //{
                    //    if (objDelete.resultDT.Rows.Count > 0)
                    //    {
                    //        if (Convert.ToInt32(objDelete.resultDT.Rows[0]["CurrentClassID"]) == Convert.ToInt32(ViewState["ClassMID"].ToString()))
                    //        {
                    //            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('There are Student(s) associated with this Class. To delete this Section you need to delete Student(s) first.');</script>");
                    //        }
                    //    }
                    //    else
                    //    {
                    //        objResults = objClasstBl.Class_Delete(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]), ViewState["DivisionName"].ToString());
                    //        if (objResults.status == ApplicationResult.CommonStatusType.SUCCESS)
                    //        {
                    //            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Class deleted successfully.');</script>");
                    //            ClearAll();
                    //            GridDataBind();
                    //            PanelGrid_VisibilityMode(1);
                    //        }
                    //    }
                    //}
                    ApplicationResult objResult  = new ApplicationResult();
                    ClassBL           objClassBl = new ClassBL();
                    objResult = objClassBl.Class_Delete(Convert.ToInt32(ViewState["ClassMID"].ToString()),
                                                        Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                    if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Class deleted successfully.');</script>");
                        GridDataBind();
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('There are Student(s) associated with this Class. To delete this Section you need to delete Student(s) first.');</script>");
                    }
                }
            }
            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>");
            }
        }