Ejemplo n.º 1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            BPDocuments bp = new BPDocuments();
            BEDocuments ds = bp.SelectByID(DocumentID);
            BEDocuments.tbl_DocumentsRow doc = ds.tbl_Documents.FindByDocumentID(DocumentID);

            if (doc != null)
            {
                DeleteLinksToDocument(doc.DocumentID);
                DeleteAttachmentsToDocument(doc.DocumentID);
                MWUtility.DeleteDocumentFiles(doc.DocumentName, this);
                doc.Delete();
                bp.Update(ds);
            }

            Response.Redirect("BrowseDocuments.aspx?CatID=" + FilterCatID);
        }
Ejemplo n.º 2
0
        private bool SaveDocumentInfo()
        {
            bool isNew = false;
            bool updateExisting = false;
            string strFileName = null;
            BPDocuments bp = new BPDocuments();
            BEDocuments ds = new BEDocuments();

            if (DocumentID > 0)
            {
                if (inpUpload.PostedFile.FileName == "")
                    updateExisting = true;
            }
            else
                isNew = true;

            if (!updateExisting)
                strFileName = UploadFunctions.UploadFile(inpUpload.PostedFile, Server.MapPath(ConfigurationManager.AppSettings["UploadsPath"]), UploadTypes.Document);

            if (strFileName != null || updateExisting)
            {
                BEDocuments.tbl_DocumentsRow doc;

                if (isNew)
                    doc = ds.tbl_Documents.Newtbl_DocumentsRow();
                else
                {
                    ds = bp.SelectByID(DocumentID);
                    doc = ds.tbl_Documents.FindByDocumentID(DocumentID);
                }

                doc.DocumentCategoryID = Convert.ToInt32(ddlDocumentCategories.SelectedValue);

                if (!updateExisting)
                    doc.DocumentName = strFileName;

                doc.DocumentAlias = txtDocumentAlias.Text;

                if (txtDocumentDescription.Text.Trim() != "")
                    doc.DocumentDescription = txtDocumentDescription.Text;
                else
                    doc.SetDocumentDescriptionNull();


                string path = ConfigurationManager.AppSettings["UploadsPath"];
                if (File.Exists(Server.MapPath(path + doc.DocumentName)))
                {
                    FileInfo file = new FileInfo(Server.MapPath(path + doc.DocumentName));
                    doc.DocumentSize = file.Length;
                }
                else
                    doc.DocumentSize = 0;

                doc.DocumentActive = chkDocumentActive.Checked;
                doc.DateModified = DateTime.Now;
                doc.ModifiedByAdminID = PageUserID;

                if (isNew)
                {
                    doc.DateCreated = DateTime.Now;
                    ds.tbl_Documents.Addtbl_DocumentsRow(doc);
                }

                bp.Update(ds);
                return true;
            }
            else
                return false;
        }