Ejemplo n.º 1
0
 private void deleteDocumentToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //delete document button
     try
     {
         if (MessageBox.Show("Are you sure you want to delete this document?", "Delete Confirmation Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             qm_sop currentSop = (qm_sop)treeViewQMS.SelectedNode.Tag;
             if (currentSop.GetType() == typeof(qm_tree))
             {
                 return;
             }
             else if (currentSop == null)
             {
                 MessageBox.Show("Oops, something went wrong", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             var data = db.qm_sop.FirstOrDefault(q => q.qm_sop_id == currentSop.qm_sop_id);
             db.qm_sop.Remove(data);
             db.SaveChanges();
             MessageBox.Show("Document deleted successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         MessageBox.Show("Selected item is not a document", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         PopulateTree();
     }
 }
Ejemplo n.º 2
0
        private qm_sop ConvertObjectToType()
        {
            var    obj   = treeViewQMS.SelectedNode.Tag;
            qm_sop typed = (qm_sop)obj;

            return(typed);
        }
Ejemplo n.º 3
0
 public bool isDocument()
 {
     if (getSelectedNodeID() == "")
     {
         return(false);
     }
     try
     {
         qm_sop obj_test = ((qm_sop)getSelectedTree());
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string fileName           = txtDocumentName.Text;
            string destionationFolder = @"C:\Users\iME\Documents\sop\";
            string pathstring         = Path.Combine(destionationFolder, fileName);

            try
            {
                qm_sop sop = new qm_sop();
                sop.filePath   = pathstring;
                sop.title      = txtDocumentName.Text;
                sop.created_at = DateTime.Now;
                sop.qm_tree_id = parentTree.qm_tree_id;
                if (txtSourceFile.Text == string.Empty || pathstring == string.Empty)
                {
                    MessageBox.Show("Source path and file name cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    File.Copy(txtSourceFile.Text, pathstring);
                    using (emedEntities db = new emedEntities())
                    {
                        db.qm_sop.Add(sop);
                        db.SaveChanges();
                        //TreeNode newNode = new TreeNode(sop.title + " - Document");
                        //newNode.Tag = parentTree;
                        //parentNode.Nodes.Add(newNode);
                        MessageBox.Show("Document has been sent for approval", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 5
0
 private void LoadDocument(qm_sop path)
 {
     pdfViewer1.DocumentFilePath = path.filePath;
     txtDocumentName.Text        = path.title;
     txtSourceFile.Text          = path.filePath;
 }
Ejemplo n.º 6
0
 public Document(qm_sop docxPath)
 {
     InitializeComponent();
     _docxPath = docxPath;
     LoadDocument(_docxPath);
 }