示例#1
0
        private void uclCaseDelete(string cmdArg)
        {
            int status = ProblemCase.DeleteProblemCase(CaseCtl().problemCase.ProbCase.PROBCASE_ID);

            if (status == 0)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveError');", true);
            }
            else
            {
                CaseCtl().Clear();
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
            }

            uclSearchBar_OnSearchClick();
        }
        public static int DeleteIncident(decimal incidentId)
        {
            int    status = 0;
            string delCmd = " IN (" + incidentId + ") ";

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                try
                {
                    decimal probCaseId = (from po in ctx.PROB_OCCUR where po.INCIDENT_ID == incidentId select po.PROBCASE_ID).FirstOrDefault();

                    if (probCaseId > 0)
                    {
                        status = ProblemCase.DeleteProblemCase(probCaseId);
                    }

                    List <decimal> attachmentIds = (from a in ctx.ATTACHMENT where a.RECORD_TYPE == 40 && a.RECORD_ID == incidentId
                                                    select a.ATTACHMENT_ID).ToList();

                    if (attachmentIds != null && attachmentIds.Count > 0)
                    {
                        status = ctx.ExecuteStoreCommand("DELETE FROM ATTACHMENT_FILE WHERE ATTACHMENT_ID IN (" + String.Join(",", attachmentIds) + ")");
                        status = ctx.ExecuteStoreCommand("DELETE FROM ATTACHMENT WHERE ATTACHMENT_ID IN (" + String.Join(",", attachmentIds) + ")");
                    }

                    status = ctx.ExecuteStoreCommand("DELETE FROM PROB_OCCUR WHERE INCIDENT_ID" + delCmd);
                    status = ctx.ExecuteStoreCommand("DELETE FROM INCIDENT_ANSWER WHERE INCIDENT_ID" + delCmd);
                    status = ctx.ExecuteStoreCommand("DELETE FROM INCIDENT WHERE INCIDENT_ID" + delCmd);
                }
                catch (Exception ex)
                {
                    SQMLogger.LogException(ex);
                }
            }

            return(status);
        }