Ejemplo n.º 1
0
        protected void gvFeesCategory_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            FeesCategoryBL objFeesBl = new FeesCategoryBL();

            try
            {
                ViewState["FeesCategoryMID"] = Convert.ToInt32(e.CommandArgument.ToString());
                if (e.CommandName.ToString() == "Edit1")
                {
                    ApplicationResult objResultsEdit = new ApplicationResult();
                    objResultsEdit = objFeesBl.FeesCategory_Select(Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));

                    if (objResultsEdit != null)
                    {
                        if (objResultsEdit.resultDT.Rows.Count > 0)
                        {
                            txtFeesCategoryName.Text          = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEESNAME].ToString();
                            rblFeeType.SelectedValue          = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEESTYPE].ToString();
                            ddlOutstandingMonth.SelectedValue = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_OutstandingMonth].ToString();
                            txtAbbreviation.Text = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEEABBREVIATION].ToString();
                            ddlFeeGroup.Text     = objResultsEdit.resultDT.Rows[0][FeesCategoryBO.FEESCATEGORY_FEEGROUPID].ToString();
                            ViewState["Mode"]    = "Edit";
                            PanelGrid_VisibilityMode(2);
                        }
                    }
                }

                if (e.CommandName.ToString() == "Delete1")
                {
                    Controls objControls = new Controls();
                    //objControls.EnableControls(Master.FindControl("ContentPlaceHolder1"));
                    ApplicationResult objDelete = new ApplicationResult();

                    objDelete = objFeesBl.Validate_FeesCategory_Delete(Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()), Convert.ToInt32(Session[ApplicationSession.SCHOOLID]));
                    if (objDelete != null)
                    {
                        if (objDelete.resultDT.Rows.Count > 0)
                        {
                            if (Convert.ToInt32(objDelete.resultDT.Rows[0]["FeesCategoryMID"]) == Convert.ToInt32(ViewState["FeesCategoryMID"].ToString()))
                            {
                                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('There are ClasseTemplate(s) associated with this FeeCategory. To delete this FeeCategory you need to delete ClasseTemplate(s) first');</script>");
                                goto Exit;
                            }
                        }
                    }
                    ApplicationResult objResultsDelete = new ApplicationResult();

                    objResultsDelete = objFeesBl.FeesCategory_Delete(Convert.ToInt32(e.CommandArgument.ToString()));
                    if (objResultsDelete.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                        ClearAll();
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Fee Category deleted successfully.');</script>");
                        GridDataBind();
                        PanelGrid_VisibilityMode(1);
                    }
                }
                Exit :;
            }
            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>");
            }
        }