Пример #1
0
        private void InitAttachmentsList()
        {
            btnAttachments.AddOnClick("javascript:return view_att();ClearErrMsg();");



            var _page = new PageBase();
            var ds    = Document.GetDocumentAttachments(Convert.ToInt32(_page.DocNumber), _page.LoadID.ToString());

            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                if (bShowEmailIcon == true)
                {
                    if (Page.User.IsInRole(((int)UserRoles.urBudgetDivisionAdmin).ToString()) == true || Page.User.IsInRole(((int)UserRoles.urOrganizationAdmin).ToString()) == true)
                    {
                        hdnUserIsAdmin.Value = "1";
                        btnEmail.Visible     = true;
                        //btnEmail.AddTitle("");
                    }
                    else
                    {
                        hdnUserIsAdmin.Value = "0";
                        btnEmail.Visible     = false;
                    }
                }
                else
                {
                    hdnUserIsAdmin.Value = "0";
                    btnEmail.Visible     = false;
                }
                return;
            }

            var count = ds.Tables[0].Rows.Count;

            lblAttCount.Visible = true;
            //lblAttCount.Text = " (" + count.ToString() + "). ";

            var doc_id             = 0;
            var sUploadDate        = "";
            var iCountDisplayedAtt = 0;

            for (int row_id = 0, tbl_row = 0; row_id < count && tbl_row < 3; row_id++) // olga's - only 3 docs
                                                                                       //for (int row_id = 0, tbl_row = 0; row_id < count; row_id++)
            {
                if (doc_id != (int)ds.Tables[0].Rows[row_id]["DocID"])
                {
                    // String.Format("{0:M/d/yyyy}", dt);
                    doc_id      = (int)ds.Tables[0].Rows[row_id]["DocID"];
                    sUploadDate = ds.Tables[0].Rows[row_id]["UploadDate"].ToString();
                    var dUploadDate = Convert.ToDateTime(sUploadDate);
                    sUploadDate = dUploadDate.ToString("d");
                    var td = new HtmlTableCell();
                    var tr = new HtmlTableRow();

                    var sb = new StringBuilder();
                    //sb.Append(sUploadDate + " - ");
                    sb.Append("<a href='javascript:view_doc(");

                    sb.Append(ds.Tables[0].Rows[row_id]["DocID"].ToString());
                    sb.Append(");' ><img src='../images/btn_view_file.gif' alt='' title='view file'  style='border:0;vertical-align:middle;'/>");

                    //sb.Append(ds.Tables[0].Rows[row_id]["DocID"].ToString() +");' >");
                    //sb.Append("<img src='../images/btn_view_file.gif' alt='' height='18px' style='border:0;'/>");

                    sb.Append("<span class='regBldGreyText'>");
                    sb.Append(sUploadDate + " - " + ds.Tables[0].Rows[row_id]["FileName"].ToString());
                    //sb.Append(ds.Tables[0].Rows[row_id]["FileName"].ToString() + " (" + sUploadDate + ")");
                    sb.Append("</span></a>");
                    td.InnerHtml = sb.ToString();
                    td.AddVerticalAlignTop();
                    tr.AddVerticalAlignTop();
                    tr.Cells.Add(td);
                    tr.AddBldGreyText();

                    tblAttLinks.Rows.Add(tr);
                    tbl_row++;
                    iCountDisplayedAtt = iCountDisplayedAtt + 1;
                }
            }

            if (count > 3)
            {
                lblAttCount.Text = " (" + iCountDisplayedAtt + " of " + count.ToString() + ") ";
            }
            else
            {
                lblAttCount.Text = " (" + count.ToString() + ") ";
            }

            if (count == 0 && bShowEmailIcon == true)
            {
                if (Page.User.IsInRole(((int)UserRoles.urBudgetDivisionAdmin).ToString()) == true || Page.User.IsInRole(((int)UserRoles.urOrganizationAdmin).ToString()) == true)
                {
                    hdnUserIsAdmin.Value = "1";
                    btnEmail.Visible     = true;
                }
                else
                {
                    hdnUserIsAdmin.Value = "0";
                    btnEmail.Visible     = false;
                }
            }
            else
            {
                hdnUserIsAdmin.Value = "0";
                btnEmail.Visible     = false;
            }

            if (bShowAddAttBtn == true)
            {
                btnAttachments.Visible = true;
            }
            else
            {
                if (count == 0)
                {
                    btnAttachments.Visible = false;
                    lblAttCount.Text       = "(0)";
                }

                if (count > 3)
                {
                    btnAttachments.Visible = true;
                }
                else
                {
                    btnAttachments.Visible = true;
                }
            }
        }