Beispiel #1
0
        protected void gvStatus_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            StatusBL objStatusBl = new StatusBL();

            try
            {
                ViewState["StatusMasterID"] = Convert.ToInt32(e.CommandArgument.ToString());
                if (e.CommandName.ToString() == "Edit1")
                {
                    ApplicationResult objResultsEdit = new ApplicationResult();
                    objResultsEdit = objStatusBl.Status_Select(Convert.ToInt32(ViewState["StatusMasterID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]));

                    if (objResultsEdit != null)
                    {
                        if (objResultsEdit.resultDT.Rows.Count > 0)
                        {
                            txtStatusName.Text = objResultsEdit.resultDT.Rows[0][StatusBO.STATUS_STATUSNAME].ToString();
                            txtStatusDesc.Text = objResultsEdit.resultDT.Rows[0][StatusBO.STATUS_DISCRIPTION].ToString();

                            ViewState["Mode"] = "Edit1";
                            PanelGrid_VisibilityMode(2);
                        }
                    }
                }

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

                    objDelete = objStatusBl.Validate_Status_Delete(Convert.ToInt32(ViewState["StatusMasterID"].ToString()), Convert.ToInt32(Session[ApplicationSession.TRUSTID]));
                    if (objDelete != null)
                    {
                        ApplicationResult objResultsDelete = new ApplicationResult();

                        objResultsDelete = objStatusBl.Status_Delete(Convert.ToInt32(e.CommandArgument.ToString()));
                        if (objResultsDelete.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            ClearAll();
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Status deleted successfully.');</script>");
                            GridDataBind();
                            PanelGrid_VisibilityMode(1);
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('There are Student(s) associated with this Status. To delete this Status 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>");
            }
        }
Beispiel #2
0
 protected void gvStatus_OnRowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         StatusBL objStatusBL = new StatusBL();
         if (e.CommandName == "Edit1")
         {
             ViewState["Mode"] = "Edit";
             ViewState["ID"]   = e.CommandArgument.ToString();
             var objResult = objStatusBL.Status_Select(Convert.ToInt32(ViewState["ID"].ToString()));
             if (objResult != null)
             {
                 if (objResult.ResultDt.Rows.Count > 0)
                 {
                     txtName.Text     = objResult.ResultDt.Rows[0][StatusBo.STATUS_NAME].ToString();
                     txtPLCValue.Text = objResult.ResultDt.Rows[0][StatusBo.STATUS_PLCVALUE].ToString();
                     PanelVisibilityMode(false, true);
                 }
             }
         }
         else if (e.CommandName == "Delete1")
         {
             var objResult = objStatusBL.Status_Delete(Convert.ToInt32(e.CommandArgument.ToString()), Convert.ToInt32(Session[ApplicationSession.Userid].ToString()), System.DateTime.UtcNow.AddHours(5.5).ToString());
             if (objResult.Status == ApplicationResult.CommonStatusType.Success)
             {
                 ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record Deleted Successfully.');</script>");
                 PanelVisibilityMode(true, false);
                 BindgvStatus();
             }
             else
             {
                 ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You can not delete this Reception because it is in used.');</script>");
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Error", ex);
         ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>");
     }
 }