Beispiel #1
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);
            }
        }
Beispiel #2
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>");
            }
        }
 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>");
     }
 }