protected void gvUploadedFiles_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            decimal document_id = (decimal)e.Keys[0];

            SQMDocumentMgr.DeleteAttachment(document_id);
            Bind_gvUploadedFiles();
            // do below to signal the calling page to refresh the attachment list
            SessionManager.ReturnObject = new ATTACHMENT();
            SessionManager.ReturnStatus = true;
        }
Beispiel #2
0
      //public void SaveFilesPreventativeMeasures()
      //{
      //    string[] descriptions;

      //    //if (trAttachDesc.Visible == true)
      //    //	descriptions = tbAttachDesc.Text.Split('|');
      //    //else
      //    //	descriptions = hfDescriptions.Value.Split('|');

      //    if (hfDescriptions.Value.Length > 0)
      //        descriptions = hfDescriptions.Value.Split('|');
      //    else if (tbAttachDesc.Text.Length > 0)
      //        descriptions = tbAttachDesc.Text.Split('|');
      //    else
      //        descriptions = "".Split('|');

      //    int i = 0;
      //    foreach (UploadedFile file in raUpload.UploadedFiles)
      //    {
      //        string description = (i < descriptions.Count()) ? descriptions[i] : "";
      //        decimal displayType = (file.FileName.ToLower().Contains(".jpeg") || file.FileName.ToLower().Contains(".jpg") ||
      //            file.FileName.ToLower().Contains(".gif") || file.FileName.ToLower().Contains(".png")) ||
      //            file.FileName.ToLower().Contains(".bmp") ? 1 : 0;
      //        SQMDocumentMgr.AddAttachment(
      //            file.FileName,
      //            description,
      //            displayType,
      //            "",
      //            SessionManager.DocumentContext.RecordType,
      //            SessionManager.DocumentContext.RecordID,
      //            SessionManager.DocumentContext.RecordStep,
      //            Session.SessionID,
      //            file.InputStream,
      //            (int)Incident_Section.PreventativeMeasuresAttachment
      //            );
      //        i++;
      //    }

      //    // Update "display" status of existing files
      //    foreach (GridDataItem item in rgFiles.Items)
      //    {
      //        decimal attachmentId = Convert.ToDecimal(item.GetDataKeyValue("AttachmentId"));
      //        CheckBox cb = (CheckBox)item["DisplayTypeColumn"].FindControl("checkBox");
      //        decimal displayType = (cb.Checked) ? 1 : 0;
      //        SQMDocumentMgr.UpdateAttachmentDisplayType(attachmentId, displayType);
      //    }
      //}

      protected void rgFiles_OnDeleteCommand(object source, GridCommandEventArgs e)
      {
          GridEditableItem item         = (GridEditableItem)e.Item;
          decimal          attachmentId = (decimal)item.GetDataKeyValue("AttachmentId");
          ATTACHMENT       attach       = SQMDocumentMgr.DeleteAttachment(attachmentId);

          this.GetUploadedFiles(_recordType, _recordId);

          if (OnAttachmentDelete != null && attach != null)
          {
              OnAttachmentDelete(attach);
          }
      }
        protected void rgFiles_OnDeleteCommand(object source, GridCommandEventArgs e)
        {
            //Declare variables for manage the conditions for delete the files from all the incident sections.
            string Incident = "uploader";                                           //for incident step.
            string IncidentFinalCorrectiveAction = "uploaderFinalCorrectiveAction"; //for FinalCorrectiveAction step.
            string IncidentPreventativeMeasures  = "uploaderPreventativeMeasures";  // for PreventativeMeasures step.
            string uploaderID = ID;


            GridEditableItem item         = (GridEditableItem)e.Item;
            decimal          attachmentId = (decimal)item.GetDataKeyValue("AttachmentId");
            ATTACHMENT       attach       = SQMDocumentMgr.DeleteAttachment(attachmentId);


            //after delete display attached files according to uploader id.
            if (uploaderID == Incident)
            {
                this.GetUploadedFilesIncidentSection(_recordType, _recordId, "", (int)Incident_Section.IncidentAttachment);
            }
            else if (uploaderID == IncidentFinalCorrectiveAction)
            {
                this.GetUploadedFilesIncidentSection(_recordType, _recordId, "", (int)Incident_Section.FinalCorrectiveAttachment);
            }
            else if (uploaderID == IncidentPreventativeMeasures)
            {
                this.GetUploadedFilesIncidentSection(_recordType, _recordId, "", (int)Incident_Section.PreventativeMeasuresAttachment);
            }
            else
            {
                this.GetUploadedFiles(_recordType, _recordId);
            }

            if (OnAttachmentDelete != null && attach != null)
            {
                OnAttachmentDelete(attach);
            }
        }