示例#1
0
        public List <CommentsBE> GetJobCommentsWithAttachmentsBAL(CommentsBE commentBE)
        {
            List <CommentsBE> CommentBEList = new List <CommentsBE>();

            try
            {
                AttachmentDAL attachmentDAL = new AttachmentDAL();

                CommentBEList = attachmentDAL.GetJobCommentsWithAttachmentsDAL(commentBE);
                attachmentDAL = null;
            }
            catch (Exception ex)
            {
            }
            finally { }
            return(CommentBEList);
        }
示例#2
0
        public List <CommentsBE> GetJobCommentsWithAttachmentsDAL(CommentsBE commentBE)
        {
            List <CommentsBE> CommentBEList = new List <CommentsBE>();

            try
            {
                DataTable      dt    = new DataTable();
                int            index = 0;
                SqlParameter[] param = new SqlParameter[2];
                param[index++] = new SqlParameter("@Action", commentBE.Action);
                param[index++] = new SqlParameter("@JobId", commentBE.JobDetails.Id);

                DataSet ds = SqlHelper.ExecuteDataset(DBConnection.Connection.ToString(), CommandType.StoredProcedure, "spJobAttachments", param);

                dt = ds.Tables[0];

                foreach (DataRow dr in dt.Rows)
                {
                    CommentsBE oNewCommentBE = new CommentsBE();
                    oNewCommentBE.Attachment    = new AttachmentsBE();
                    oNewCommentBE.JobDetails    = new JobDetailsBE();
                    oNewCommentBE.usr           = new UserLogin();
                    oNewCommentBE.CommentId     = dr["CommentId"] != DBNull.Value ? Convert.ToInt32(dr["CommentId"]) : 0;
                    oNewCommentBE.JobDetails.Id = dr["JobId"] != DBNull.Value ? Convert.ToInt32(dr["JobId"]) : 0;
                    oNewCommentBE.ClientId      = Convert.ToInt32(dr["ClientId"].ToString());
                    oNewCommentBE.Description   = dr["CommentDescription"] != DBNull.Value ? Convert.ToString(dr["CommentDescription"]) : null;
                    oNewCommentBE.CreatedOn     = Convert.ToDateTime(dr["CreatedOn"]);
                    oNewCommentBE.usr.Username  = Convert.ToString(dr["UserName"]);
                    oNewCommentBE.Attachment.JobAttachmentId = dr["JobAttachmentId"] != DBNull.Value ? Convert.ToInt32(dr["JobAttachmentId"]) : 0;
                    oNewCommentBE.Attachment.Name            = dr["AttachmentName"] != DBNull.Value ? Convert.ToString(dr["AttachmentName"]) : null;
                    oNewCommentBE.Attachment.Path            = dr["Path"] != DBNull.Value ? Convert.ToString(dr["Path"]) : null;
                    CommentBEList.Add(oNewCommentBE);
                }
            }
            catch (Exception ex)
            {
            }
            return(CommentBEList);
        }
示例#3
0
        private void GetJobCommentsWithAttachments()
        {
            CommentsBE     commentBE     = new CommentsBE();
            AttachmentsBAL attachmentBAL = new AttachmentsBAL();

            commentBE.JobDetails = new JobDetailsBE();

            StringBuilder sHTML = new StringBuilder();

            commentBE.Action = "GetJobCommentsWithAttachmentsByJobId";

            if (Request.QueryString["JobId"] != null)
            {
                commentBE.JobDetails.Id = Convert.ToInt32(Request.QueryString["JobId"]);
            }

            List <CommentsBE> lstAttachments = attachmentBAL.GetJobCommentsWithAttachmentsBAL(commentBE);

            if (lstAttachments.Count > 0)
            {
                int previous = 0, AttachmentCountByCommentID = 0;

                for (int i = 0; i < lstAttachments.Count(); i++)
                {
                    if (i != 0 && previous != lstAttachments[i].CommentId)
                    {
                        sHTML.Append("</div>");
                        sHTML.Append("</div></div></blockquote>");
                    }

                    if (previous != lstAttachments[i].CommentId)
                    {
                        AttachmentCountByCommentID = lstAttachments.Where(x => x.CommentId == lstAttachments[i].CommentId && x.Attachment.JobAttachmentId > 0).Count();

                        sHTML.Append("<blockquote>");
                        sHTML.Append("<div class='submit-by'> Added By: ");
                        sHTML.Append("<span class='comment-name'>");
                        sHTML.Append(lstAttachments[i].usr.Username);
                        sHTML.Append("</span>");
                        sHTML.Append(" on ");
                        sHTML.Append("<span class='comment-date'>");
                        sHTML.Append(lstAttachments[i].CreatedOn.Value.ToString("MM/dd/yyyy"));
                        sHTML.Append("</span>");
                        sHTML.Append("</div>");
                        sHTML.Append("<div class='row'><div class='col-sm-6 blockquote-body'>");
                        sHTML.Append("<p> <img alt='' src='/images/qoute-icon.png'>");
                        sHTML.Append(lstAttachments[i].Description);
                        sHTML.Append("</p>");
                        sHTML.Append("</div>");
                        sHTML.Append("<div class='col-sm-6 text-right'>");
                        sHTML.Append("<i class='fa fa-paperclip fa-rotate-270' aria-hidden='true'></i>");
                        sHTML.Append("<a class='link-underline' id='link-underline" + (i + 1).ToString() + "' onclick='return ToggleAttachments(this) ';><img alt = '' src='/images/attachment-icon.png' />");
                        sHTML.Append("Attachments " + "[" + AttachmentCountByCommentID + "]");
                        sHTML.Append("</a>");
                        sHTML.Append("<div class='down-attach attachment-download" + (i + 1).ToString() + "' style='display: none'>");

                        previous = lstAttachments[i].CommentId;
                    }

                    if (lstAttachments[i].Attachment.JobAttachmentId > 0)
                    {
                        sHTML.Append(String.Format("<a class='btn btn-link' href='DownloadAttachment.aspx?FilePath={0} &FileName={1}'>", lstAttachments[i].Attachment.Path, lstAttachments[i].Attachment.Name));
                        sHTML.Append(lstAttachments[i].Attachment.Name);
                        sHTML.Append("</a>");
                    }
                }
            }

            if (lstAttachments.Count > 0)
            {
                sHTML.Append("</div></div></blockquote>");
            }

            divComments.InnerHtml = sHTML.ToString();
        }