示例#1
0
 /// <summary>
 /// Event That Fires on Submit Click Which Downloads The File
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateCard())
         {
             Document_Details DocumentObj = (Document_Details)Session["DocumentObj"];
             // 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.TransmitFile(Server.MapPath("~/Documents/" + DocumentObj.DocumentPath + ".pdf"));
             Response.End();
         }
         else
         {
             Response.Write("<script>alert('Sorry! InValid Credit Card details.')</script>");
         }
     }
     catch (ELibException ex)
     {
         Response.Write("<script>alert(" + ex.Message + ")</script>");
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert(" + ex.Message + ")</script>");
     }
 }
        public bool freebie(Document_Details document)
        {
            {
                var dialog = new SaveFileDialog();
                dialog.Filter       = "PDF Files|*.pdf";
                dialog.AddExtension = true;
                if (dialog.ShowDialog().GetValueOrDefault() == true)
                {
                    using (var fs = new System.IO.FileStream(document.DocumentPath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                    {
                        using (var sr = new System.IO.BinaryReader(fs))
                        {
                            var fs1 = new System.IO.FileStream(dialog.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                            var sw  = new System.IO.BinaryWriter(fs1);

                            sw.Write(sr.ReadBytes((int)fs.Length - 1));

                            sw.Close();
                            fs1.Close();
                            sr.Close();
                            fs.Close();
                            return(true);
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
 public Download(Document_Details Obj, decimal discount)
 {
     InitializeComponent();
     DetailsObj               = Obj;
     lbldocnameval.Content    = DetailsObj.DocumentName;
     lbldocpriceval.Content   = "Rs. " + ((double)DetailsObj.Price) + "/- INR";
     lbltotalpriceval.Content = "Rs " + (Convert.ToDouble(DetailsObj.Price - (discount * DetailsObj.Price))) + "/- INR";
 }
        public List <Document_Details> BrowseDocuments(int disciplineIdSelected, int offsetPageNumber)
        {
            List <Document_Details> DisciplineDetailsListObj = null;

            var ConnectionObj = DatabaseConnection.CreateConnection();
            var CommandObj    = DatabaseConnection.CreateCommand(ConnectionObj, "ELIB_Management_System.uspBrowse_Document_Details", CommandType.StoredProcedure);

            var P1 = DatabaseConnection.CreateParameter(CommandObj, "@Discipline_Id", DbType.Int32);

            P1.Value = disciplineIdSelected;
            CommandObj.Parameters.Add(P1);

            var P2 = DatabaseConnection.CreateParameter(CommandObj, "@OffsetPageNumber", DbType.Int32);

            P2.Value = offsetPageNumber;
            CommandObj.Parameters.Add(P2);
            try
            {
                DataTable TableObj = DatabaseConnection.ExecuteReader(CommandObj);
                if (TableObj != null && TableObj.Rows.Count > 0)
                {
                    DisciplineDetailsListObj = new List <Document_Details>();
                    foreach (DataRow row in TableObj.Rows)
                    {
                        var DocumentDetailsObj = new Document_Details();

                        DocumentDetailsObj.DocumentId                    = (int)row[0];
                        DocumentDetailsObj.DocumentName                  = (string)row[1];
                        DocumentDetailsObj.DocumentDescription           = (string)row[2];
                        DocumentDetailsObj.DocumentPath                  = (string)row[3];
                        DocumentDetailsObj.DocumentTypeId.DocumentTypeId = (int)row[4];
                        DocumentDetailsObj.DisciplineId.DisciplineId     = (int)row[5];
                        DocumentDetailsObj.Title      = (string)row[6];
                        DocumentDetailsObj.Author     = (string)row[7];
                        DocumentDetailsObj.UploadDate = (DateTime)row[8];
                        DocumentDetailsObj.Price      = (decimal)row[9];

                        DisciplineDetailsListObj.Add(DocumentDetailsObj);
                    }
                }
            }
            catch (DbException ex)
            {
                throw new ELibException("There is an Error while fetching the document details from the database. Try again after some time", ex);
            }
            catch (Exception ex)
            {
                throw new ELibException("Unknown error", ex);
            }

            return(DisciplineDetailsListObj);
        }
示例#5
0
        private bool ValidateDocuments(Document_Details obj)
        {
            var IsValid      = true;
            var ErrorMessage = new StringBuilder();

            if (string.IsNullOrEmpty(obj.DocumentName))
            {
                IsValid = false;
                ErrorMessage.AppendLine("Document Name Should Not be Epmty!");
            }
            if (string.IsNullOrEmpty(obj.DocumentDescription))
            {
                IsValid = false;
                ErrorMessage.AppendLine("Document Description Should Not be Epmty!");
            }
            if (obj.DocumentTypeId.DocumentTypeId != 1 && obj.DocumentTypeId.DocumentTypeId != 2)
            {
                IsValid = false;
                ErrorMessage.AppendLine("Document Type Name Should be Selected From DropDown List!");
            }
            if (obj.DisciplineId.DisciplineId <= 0)
            {
                IsValid = false;
                ErrorMessage.AppendLine("Discipline Name Should be Selected From DropDown List!");
            }
            if (string.IsNullOrEmpty(obj.Title))
            {
                IsValid = false;
                ErrorMessage.AppendLine("Document Description Should Not be Epmty!");
            }
            if (string.IsNullOrEmpty(obj.Author))
            {
                IsValid = false;
                ErrorMessage.AppendLine("Author Should Not be Epmty!");
            }
            if (obj.Price < 0)
            {
                IsValid = false;
                ErrorMessage.AppendLine("Price Should Not be Less Than 0 for Premium Documents!");
            }
            if (string.IsNullOrEmpty(obj.DocumentPath))
            {
                IsValid = false;
                ErrorMessage.AppendLine("Document Path Should Not be Epmty!");
            }
            if (!IsValid)
            {
                throw new ELibException(ErrorMessage.ToString());
            }
            return(IsValid);
        }
        public List <Document_Details> SearchDocumentById(int id)
        {
            Document_Details DocumentDetailsObj = null;
            var DocumentsList = new List <Document_Details>();
            var ConnectionObj = DatabaseConnection.CreateConnection();
            var CommandObj    = DatabaseConnection.CreateCommand(ConnectionObj, "ELIB_Management_System.uspSelectDocument_DetailsById", CommandType.StoredProcedure);

            var P1 = DatabaseConnection.CreateParameter(CommandObj, "@document_id", DbType.Int32);

            P1.Value = id;
            CommandObj.Parameters.Add(P1);

            try
            {
                DataTable TableObj = DatabaseConnection.ExecuteReader(CommandObj);
                if (TableObj != null && TableObj.Rows.Count > 0)
                {
                    foreach (DataRow row in TableObj.Rows)
                    {
                        DocumentDetailsObj                               = new Document_Details();
                        DocumentDetailsObj.DocumentId                    = (int)row[0];
                        DocumentDetailsObj.DocumentName                  = (string)row[1];
                        DocumentDetailsObj.DocumentDescription           = (string)row[2];
                        DocumentDetailsObj.DocumentPath                  = (string)row[3];
                        DocumentDetailsObj.DocumentTypeId.DocumentTypeId = (int)row[4];
                        DocumentDetailsObj.DisciplineId.DisciplineId     = (int)row[5];
                        DocumentDetailsObj.Title                         = (string)row[6];
                        DocumentDetailsObj.Author                        = (string)row[7];
                        DocumentDetailsObj.UploadDate                    = ((DateTime)row[8]).Date;
                        DocumentDetailsObj.Price                         = (decimal)row[9];
                        DocumentDetailsObj.DocumentTypeName              = (string)row[10];
                        DocumentDetailsObj.DisciplineName                = (string)row[11];
                        DocumentsList.Add(DocumentDetailsObj);
                    }
                }
            }
            catch (DbException ex)
            {
                throw new ELibException("Error reading data", ex);
            }
            catch (Exception ex)
            {
                throw new ELibException("Unknown error", ex);
            }

            return(DocumentsList);
        }
示例#7
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>");
            }
        }
示例#8
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);
            }
        }
示例#9
0
        public bool UploadDocument(Document_Details documentObj)
        {
            var IsAdded = false;

            try
            {
                if (ValidateDocuments(documentObj))
                {
                    var DALObj = new Document_DetailsOperations();
                    IsAdded = DALObj.UploadDocument(documentObj);
                }
            }
            catch (ELibException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new ELibException("Unknown error", ex);
            }
            return(IsAdded);
        }
示例#10
0
        public bool UpdateDocument(Document_Details DocumentObj)
        {
            var IsUpdated = false;

            try
            {
                if (ValidateDocuments(DocumentObj))
                {
                    var ObjDAL = new Document_DetailsOperations();

                    IsUpdated = ObjDAL.UpdateDocument(DocumentObj);
                }
            }
            catch (ELibException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new ELibException("Error editing Document details", ex);
            }
            return(IsUpdated);
        }
        public bool UpdateDocument(Document_Details documentObj)
        {
            var IsUpdated           = false;
            Document_Details newObj = new Document_Details();

            var ConnectionObj = DatabaseConnection.CreateConnection();
            var CommandObj    = DatabaseConnection.CreateCommand(ConnectionObj, "ELIB_Management_System.uspUpdateDocument_Details", CommandType.StoredProcedure);

            var Param0 = DatabaseConnection.CreateParameter(CommandObj, "@document_id", DbType.String);

            Param0.Value = documentObj.DocumentId;
            //Param0.Size = 20;
            CommandObj.Parameters.Add(Param0);

            var Param1 = DatabaseConnection.CreateParameter(CommandObj, "@document_name", DbType.String);

            Param1.Value = documentObj.DocumentName;
            Param1.Size  = 20;
            CommandObj.Parameters.Add(Param1);

            var Param2 = DatabaseConnection.CreateParameter(CommandObj, "@document_description", DbType.String);

            Param2.Value = documentObj.DocumentDescription;
            Param2.Size  = 200;
            CommandObj.Parameters.Add(Param2);

            var Param3 = DatabaseConnection.CreateParameter(CommandObj, "@document_path", DbType.String);

            Param3.Value = documentObj.DocumentPath;
            Param3.Size  = 50;
            CommandObj.Parameters.Add(Param3);

            var Param4 = DatabaseConnection.CreateParameter(CommandObj, "@document_type_id", DbType.String);

            Param4.Value = documentObj.DocumentTypeId.DocumentTypeId;
            //Param4.Size = 200;
            CommandObj.Parameters.Add(Param4);

            var Param5 = DatabaseConnection.CreateParameter(CommandObj, "@discipline_id", DbType.String);

            Param5.Value = documentObj.DisciplineId.DisciplineId;
            //Param5.Size = 200;
            CommandObj.Parameters.Add(Param5);

            var Param6 = DatabaseConnection.CreateParameter(CommandObj, "@title", DbType.String);

            Param6.Value = documentObj.Title;
            Param6.Size  = 30;
            CommandObj.Parameters.Add(Param6);

            var Param7 = DatabaseConnection.CreateParameter(CommandObj, "@author", DbType.String);

            Param7.Value = documentObj.Author;
            Param7.Size  = 50;
            CommandObj.Parameters.Add(Param7);

            var Param8 = DatabaseConnection.CreateParameter(CommandObj, "@price", DbType.String);

            Param8.Value = documentObj.Price;
            CommandObj.Parameters.Add(Param8);
            try
            {
                DatabaseConnection.ExecuteNonQuery(CommandObj);
                IsUpdated = true;
            }

            catch (DbException ex)
            {
                throw new ELibException(ex.Message);
            }
            catch (Exception ex)
            {
                throw new ELibException(ex.Message);
            }
            return(IsUpdated);
        }