//绑定结课资料规则数据 public void DataBindArchivesItems(string teacherType) { ltlAttachments.Text = string.Empty; DalOperationAboutArchivesItems doac = new DalOperationAboutArchivesItems(); DataTable dv = doac.GetArchivesItemByTeacherType(teacherType, termtag).Tables[0]; DalOperationAboutArchives doaa = new DalOperationAboutArchives(); DalOperationAttachments attachment = new DalOperationAttachments(); Literal ltl = new Literal(); if (dv.Rows.Count == 0) { ltl = new Literal(); ltl.Text = "当前暂无上传结课资料要求<br />"; phUpload.Controls.Add(ltl); } else { StringBuilder sb = new StringBuilder(); sb.Append(string.Format("<table class=\"datagrid2\"><tr><th>以下为{0}上传的结课资料:</th></tr>", teacherType)); for (int i = 0; i < dv.Rows.Count; i++) { sb.Append("<tr><td>" + dv.Rows[i]["archiveItemName"].ToString().Trim() + "</td></tr>"); DataTable dt = doaa.FindArchivesByCourseNo(courseNo, classID, termtag, teacherType, int.Parse(dv.Rows[i]["archiveItemId"].ToString().Trim())).Tables[0]; List<string> attachmentIds = new List<string>(); for (int j = 0; j < dt.Rows.Count; j++) { attachmentIds.Add(dt.Rows[j]["attachmentIds"].ToString().Trim()); } string attachments = attachment.GetAttachmentsList(string.Join(",", attachmentIds.ToArray()), ref iframeCount, false, string.Empty); sb.Append(attachments.Trim().Length == 0 ? "<tr><td>上传文件列表:未上传</td></tr>" : "<tr><td>上传文件列表:" + attachments + "</td></tr>"); } sb.Append("</table>"); ltl = new Literal(); ltl.Text = sb.ToString(); phUpload.Controls.Add(ltl); } }
public int fileFolderType = (int)FileFolderType.archives; //结课资料文件 #endregion Fields #region Methods //绑定结课资料规则数据 public void DataBindArchivesItems() { DalOperationAboutArchivesItems doac = new DalOperationAboutArchivesItems(); DataTable dv = doac.GetArchivesItemByTeacherType(Master.teacherType, Master.termtag).Tables[0]; DalOperationAboutArchives doaa = new DalOperationAboutArchives(); DalOperationAttachments attachment = new DalOperationAttachments(); Literal ltl = new Literal(); if (dv.Rows.Count == 0) { btnUpload.Visible = false; ltl = new Literal(); ltl.Text = "当前暂无上传结课资料要求"; phUpload.Controls.Add(ltl); return; } Table tb = new Table(); tb.CssClass = "tableAddStyleNone"; tb.Width = Unit.Percentage(100); for (int i = 0; i < dv.Rows.Count; i++) { TableRow tr = new TableRow(); TableCell td = new TableCell(); td.HorizontalAlign = HorizontalAlign.Left; td.CssClass = "border"; td.Width = Unit.Percentage(10); HiddenField hid = new HiddenField(); hid.ID = "hid_" + dv.Rows[i]["archiveItemId"].ToString().Trim(); hid.ClientIDMode = ClientIDMode.Static; ltl = new Literal(); ltl.Text = dv.Rows[i]["archiveItemName"].ToString().Trim() + ":"; td.Controls.Add(ltl); td.Controls.Add(hid); tr.Cells.Add(td); td = new TableCell(); td.HorizontalAlign = HorizontalAlign.Left; td.CssClass = "border"; DataTable dt = doaa.FindArchivesByCourseNo(Master.courseNo, Master.classID, Master.termtag, Master.teacherType, int.Parse(dv.Rows[i]["archiveItemId"].ToString().Trim())).Tables[0]; List<string> attachmentIds = new List<string>(); for (int j = 0; j < dt.Rows.Count; j++) { attachmentIds.Add(dt.Rows[j]["attachmentIds"].ToString().Trim()); } string attachments = attachment.GetAttachmentsList(string.Join(",", attachmentIds.ToArray()), ref Master.iframeCount, true, (i + 1).ToString()); ltl = new Literal(); ltl.Text = (attachments.Trim().Length == 0 ? "未上传" : attachments)+ " <input type=\"button\" value=\"为" + dv.Rows[i]["archiveItemName"].ToString().Trim() + "添加一个附件\"" + " onclick=\"addIframe(" + fileFolderType + "," + (i + 1).ToString() + "," + (i + 1).ToString() + ");\" />" + " <b>上传文件大小不超过</b>" + ConfigurationManager.AppSettings["uploadFileLimit"] + "<div id=\"iframes" + (i + 1).ToString() + "\"></div><br />"; hid = new HiddenField(); hid.ID = "hidAttachmentId" + (i + 1).ToString(); hid.ClientIDMode = ClientIDMode.Static; hid.Value = string.Join(",", attachmentIds.ToArray()); td.Controls.Add(ltl); td.Controls.Add(hid); tr.Cells.Add(td); tb.Rows.Add(tr); } phUpload.Controls.Add(tb); }
protected string GetArchivesList(string teacherType, string courseNo, string classID, string termtag) { //已经有的附件数,页面初始化时与前端JS进行交互 int iframeCount = 0; DalOperationAboutArchivesItems doac = new DalOperationAboutArchivesItems(); DataTable dv = doac.GetArchivesItemByTeacherType(teacherType, termtag).Tables[0]; DalOperationAboutArchives doaa = new DalOperationAboutArchives(); DalOperationAttachments attachment = new DalOperationAttachments(); Literal ltl = new Literal(); if (dv.Rows.Count == 0) { return "当前暂无" + teacherType + "上传结课资料的要求<br />"; } else { StringBuilder sb = new StringBuilder(); sb.Append(string.Format("<table class=\"datagrid2\"><tr><th colspan=\"2\">以下为{0}上传的结课资料:</th></tr>", teacherType)); for (int i = 0; i < dv.Rows.Count; i++) { sb.Append("<tr><td width=\"15%\">" + dv.Rows[i]["archiveItemName"].ToString().Trim() + ":</td>"); DataTable dt = doaa.FindArchivesByCourseNo(courseNo, classID, termtag, teacherType, int.Parse(dv.Rows[i]["archiveItemId"].ToString().Trim())).Tables[0]; List<string> attachmentIds = new List<string>(); for (int j = 0; j < dt.Rows.Count; j++) { attachmentIds.Add(dt.Rows[j]["attachmentIds"].ToString().Trim()); } string attachments = attachment.GetAttachmentsList(string.Join(",", attachmentIds.ToArray()), ref iframeCount, false, string.Empty); sb.Append(attachments.Trim().Length == 0 ? "<td>上传文件列表:未上传</td></tr>" : "<td>上传文件列表:" + attachments + "</td></tr>"); } sb.Append("</table>"); return sb.ToString(); } }