Beispiel #1
0
 /// <summary>
 /// Event that Fores on Delete Click wich Deletes the Document
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnDeleteDocument_Click1(object sender, EventArgs e)
 {
     try
     {
         var Id = Convert.ToInt32(txtDocumentIdDelete.Text);
         var DocumentDetailsBLLObj = new Document_DetailsBLL();
         var IsDeleted             = DocumentDetailsBLLObj.Delete(Id);
         if (IsDeleted)
         {
             lblMessageDelete.Text             = "Document deleted";
             txtDocumentIdDelete.Text          = string.Empty;
             txtDocumentNameDelete.Text        = string.Empty;
             txtDocumentDescriptionDelete.Text = string.Empty;
             txtDocumentTypeDelete.Text        = string.Empty;
             txtDisciplineNameDelete.Text      = string.Empty;
             txtTitleDelete.Text  = string.Empty;
             txtAuthorDelete.Text = string.Empty;
             txtPriceDelete.Text  = string.Empty;
             lblPathDelete.Text   = string.Empty;
         }
         else
         {
             Response.Write("<script>alert('Unable to delete document')</script>");
         }
     }
     catch (ELibException ex)
     {
         Response.Write("<script>alert('" + ex.Message + "')</script>");
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('" + ex.Message + "')</script>");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Event that Fires on Button Search Click Which Searches the List Of Documents Based On Value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtSearch.Text != "")
                {
                    var SearchName            = (txtSearch.Text);
                    var DocumentDetailsBLLObj = new Document_DetailsBLL();
                    var DocumentDetailsList   = DocumentDetailsBLLObj.SearchByDocumentName(SearchName);
                    if (DocumentDetailsList != null)
                    {
                        Response.Redirect("~/SearchResultsPage.aspx?Search=" + txtSearch.Text);
                    }
                    else
                    {
                        Response.Write("<script>alert('No such Document exists.')</script>");
                    }
                }

                else
                {
                    Response.Write("<script>alert('Enter Some Text')</script>");
                }
            }
            catch (ELibException ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
        }
Beispiel #3
0
        /// <summary>
        /// Event That Fires on Find Button Click For Deleting
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnFindDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var DocumentBLLObj = new Document_DetailsBLL();
                var Id             = Convert.ToInt32(txtDocumentIdDelete.Text);
                var DocumentObj    = DocumentBLLObj.SearchByDocumentId(Id).First();

                txtDocumentNameDelete.Text        = DocumentObj.DocumentName;
                txtDocumentDescriptionDelete.Text = DocumentObj.DocumentDescription;
                txtDocumentTypeDelete.Text        = DocumentObj.DocumentTypeName;
                txtDisciplineNameDelete.Text      = DocumentObj.DisciplineName;
                txtTitleDelete.Text  = DocumentObj.Title;
                txtAuthorDelete.Text = DocumentObj.Author;
                txtPriceDelete.Text  = Convert.ToString(DocumentObj.Price);
                lblPathDelete.Text   = DocumentObj.DocumentPath;
            }
            catch (FormatException ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            catch (ELibException ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
        }
        /// <summary>
        /// Event That Fires On List Selected Index Changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvDisciplinesList_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                var Id              = Convert.ToInt32(gvDisciplinesList.SelectedDataKey.Value); //Converts the Selected Value To Int and Store in Id
                var DocumentBLLObj  = new Document_DetailsBLL();
                var DocumentListObj = DocumentBLLObj.BrowseDocuments(Id);
                if (DocumentListObj.Count == 0)                                             //Checks If Documenrt List with 0 records
                {
                    Response.Write("<script>alert('No Documents')</script>");
                }
                else
                {
                    gvDocumentDetailsList.DataSource = DocumentListObj;
                    gvDocumentDetailsList.DataBind();
                }
            }

            catch (ELibException ex)                                                    //Custom Exception
            {
                Response.Write("<script>alert('" + ex.Message + ")</script>");
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Oops!! Error ,Please Try Again')</script>");
            }
        }
Beispiel #5
0
        private void btnFind_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var dd             = cmbDisciplineIdUpdate.SelectedItem as Disciplines;
                var DocumentBLLObj = new Document_DetailsBLL();
                var dd1            = cmbDocumentTypeIdUpdate.SelectedItem as Document_Type_Details;
                var Id             = Convert.ToInt32(txtDocumentIDUpdate.Text);
                var DocumentObj    = DocumentBLLObj.SearchByDocumentId(Id).First();

                txtDocumentIDUpdate.Visibility    = Visibility.Hidden;
                txtDocumentNameUpdate.Text        = DocumentObj.DocumentName;
                txtDocumentDescriptionUpdate.Text = DocumentObj.DocumentDescription;

                cmbDocumentTypeIdUpdate.Text     = DocumentObj.DocumentTypeId.DocumentTypeName;
                cmbDisciplineIdUpdate.Text       = DocumentObj.DisciplineId.DisciplineName;
                txtTitleUpdate.Text              = DocumentObj.Title;
                txtAuthorUpdate.Text             = DocumentObj.Author;
                dtpUploadDateUpdate.SelectedDate = DocumentObj.UploadDate;
                txtPriceUpdate.Text              = Convert.ToString(DocumentObj.Price);
                lblpathUpdate.Content            = DocumentObj.DocumentPath;
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
            catch (ELibException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (Application.Current.Properties["User_ID"] != null)
     {
         if (Application.Current.Properties["User_Type"].ToString() == "Administrator")
         {
             btnProfile.Visibility = Visibility.Collapsed;
         }
         btnlogout.Visibility = Visibility.Visible;
         lblname.Content      = "Welcome " + Application.Current.Properties["User_Name"];
     }
     else
     {
         btnlogout.Visibility  = Visibility.Collapsed;
         btnProfile.Visibility = Visibility.Collapsed;
     }
     try
     {
         var DocumentDetailsBLLObj = new Document_DetailsBLL();
         var DocumentsList         = DocumentDetailsBLLObj.SearchByDocumentId(SelectedDocumentId);
         grdDocumentDetails.ItemsSource = DocumentsList;
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
     catch (ELibException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
 }
 /// <summary>
 /// Event That Fires on Button DownLoad Button Click Based On User Type
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnDownload_Click(object sender, EventArgs e)
 {
     try
     {
         var DocumentId     = Convert.ToInt32(Request.QueryString["DocumentId"]);
         var DocumentBLLObj = new Document_DetailsBLL();
         var DocumentObj    = DocumentBLLObj.SearchByDocumentId(DocumentId).First();
         //subscriber--NonSubscriber--Administrator
         if (Session["User_ID"] != null)
         {
             Session["DocumentObj"] = DocumentObj;
             if (DocumentObj.DocumentTypeId.DocumentTypeId == 1)
             {
                 Response.Redirect("~/DownloadPremium.aspx?DocumentId=" + DocumentId);
             }
             else
             {
                 var name = DocumentObj.DocumentPath;
                 Response.ContentType = "application/pdf";
                 Response.AppendHeader("Content-Disposition", "attachment; filename=" + DocumentObj.DocumentName + ".pdf");
                 Response.TransmitFile(Server.MapPath("~/Documents/" + DocumentObj.DocumentName + ".pdf"));
                 Response.End();
             }
         }
         //Guest-freebie Document
         else if (DocumentObj.DocumentTypeId.DocumentTypeId == 2)
         {
             var name = DocumentObj.DocumentPath;
             Response.ContentType = "application/pdf";
             Response.AppendHeader("Content-Disposition", "attachment; filename=" + DocumentObj.DocumentName + ".pdf");
             Response.TransmitFile(Server.MapPath("~/Documents/" + DocumentObj.DocumentName + ".pdf"));
             Response.End();
         }
         //guest-Premium Document
         else
         {
             Response.Write("<script>alert('Sorry!Please Login to Download Premium Documents')</script>");
         }
     }
     catch (ELibException)
     {
         Response.Write("<script>alert('Sorry!!!..Please try Again')</script>");
     }
     catch (Exception)
     {
         Response.Write("<script>alert('Sorry!!!..Please try Again')</script>");
     }
 }
Beispiel #8
0
        /// <summary>
        /// Event That Fires on Update Buttons Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtDocumentNameUpdate.Text != null && txtDocumentDescriptionUpdate.Text != null && cmbDocumentTypeUpdate.Text != null &&
                    cmbDisciplineNameUpdate.Text != null && txtTitleUpdate != null && txtAuthorUpdate != null && txtPriceUpdate != null &&
                    lblPathUpdate.Text != null)
                {
                    Document_Details DocumentObj = new Document_Details();
                    DocumentObj.DocumentId                    = Convert.ToInt32(txtDocumentIdUpdate.Text);
                    DocumentObj.DocumentName                  = txtDocumentNameUpdate.Text;
                    DocumentObj.DocumentDescription           = txtDocumentDescriptionUpdate.Text;
                    DocumentObj.DocumentTypeId.DocumentTypeId = Convert.ToInt32(cmbDocumentTypeUpdate.SelectedItem.Value);
                    DocumentObj.DisciplineId.DisciplineId     = Convert.ToInt32(cmbDisciplineNameUpdate.SelectedItem.Value);
                    DocumentObj.Title  = txtTitleUpdate.Text;
                    DocumentObj.Author = txtAuthorUpdate.Text;
                    DocumentObj.Price  = Convert.ToDecimal(txtPriceUpdate.Text);
                    SaveFileUpdate(fileUpdate);
                    DocumentObj.DocumentPath = pathToCheck;

                    var DocumentBLLObj = new Document_DetailsBLL();
                    var IsAdded        = DocumentBLLObj.UpdateDocument(DocumentObj);
                    if (IsAdded)
                    {
                        Response.Write("<script>alert('Document Details Updated!')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Unable to update document')</script>");
                    }
                }
            }
            catch (FormatException ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            catch (ELibException ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "')</script>");
            }
        }
        private void display()
        {
            var BrowseObj = new Document_DetailsBLL();

            var ListBrowseObj = lstbxBrowse.SelectedItem as Disciplines;

            try
            {
                grdBrowse.ItemsSource = BrowseObj.BrowseDocuments(ListBrowseObj.DisciplineId, CurrentPage);
            }
            catch (ELibException)
            {
                MessageBox.Show("Documents for " + ListBrowseObj.DisciplineName + " is not present");
            }
            catch (Exception)
            {
                MessageBox.Show("Please Select Discipline");
            }
        }
Beispiel #10
0
        private void btnUpload_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var dd = cmbDisciplineName.SelectedItem as Disciplines;
                Document_Details DocumentObj = new Document_Details();
                var dd1 = cmbDocumentTypeName.SelectedItem as Document_Type_Details;

                DocumentObj.DocumentName                  = txtDocumentNameUpload.Text;
                DocumentObj.DocumentDescription           = txtDocumentDescriptionUpload.Text;
                DocumentObj.DocumentTypeId.DocumentTypeId = dd1.DocumentTypeId;
                DocumentObj.DisciplineId.DisciplineId     = dd.DisciplineId;
                DocumentObj.Title  = txtTitleUpload.Text;
                DocumentObj.Author = txtAuthorUpload.Text;
                DocumentObj.Price  = Convert.ToDecimal(txtPriceUpload.Text);
                File(dialog1);
                DocumentObj.DocumentPath = path;

                var DocumentBLLObj = new Document_DetailsBLL();
                var IsAdded        = DocumentBLLObj.UploadDocument(DocumentObj);
                if (IsAdded)
                {
                    MessageBox.Show("Document Details added");
                }
                else
                {
                    MessageBox.Show("Document Details not added");
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
            catch (ELibException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show("All Fields are Mandatory", "Error", MessageBoxButton.OK);
            }
        }
Beispiel #11
0
 private void btnSearch1_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtSearch.Text.Length > 0)
         {
             var SearchName            = (txtSearch.Text);
             var DocumentDetailsBLLObj = new Document_DetailsBLL();
             var DocumentDetailsList   = DocumentDetailsBLLObj.SearchByDocumentName(SearchName);
             if (DocumentDetailsList != null)
             {
                 this.NavigationService.Navigate(new SearchResultsPage()
                 {
                     Name = SearchName
                 });
             }
             else
             {
                 MessageBox.Show("Enter Proper Document Name");
             }
         }
         else
         {
             MessageBox.Show("Enter a Document Name to Search");
         }
     }
     catch (FormatException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
     catch (ELibException ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK);
     }
 }