//添加
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtArchiveItemName.Text.Trim().Length == 0)
            {
                Javascript.GoHistory(-1, "请输入要上传的资料名称!", Page);
            }
            else
            {
                DalOperationAboutArchivesItems dal = new DalOperationAboutArchivesItems();
                ArchivesItems model = new ArchivesItems();
                model.archiveItemName = txtArchiveItemName.Text.Trim();
                model.remark = txtRemark.Text.Trim();
                model.teacherType = ddlTeacherType.SelectedValue;
                model.termTag = ddlTermTags.SelectedValue;

                try
                {
                    dal.AddArchivesItems(model);//添加
                    Javascript.RefreshParentWindow("添加结课资料规则成功!", "/Administrator/ArchivesManage.aspx?fragment=2", Page);
                }
                catch (Exception ex)
                {
                    MongoDBLog.LogRecord(ex);
                    Javascript.GoHistory(-1, "添加结课资料规则失败,请检查格式是否有误!", Page);
                }

            }
        }
Exemple #2
0
    //绑定结课资料规则数据
    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 void InitialNotifyEdit(int archiveItemId)
        {
            DalOperationAboutArchivesItems dal = new DalOperationAboutArchivesItems();
            DataTable dt = dal.GetArchivesItemById(archiveItemId).Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                txtArchiveItemName.Text = dt.Rows[i]["archiveItemName"].ToString().Trim();

                txtRemark.Text = dt.Rows[i]["remark"].ToString().Trim();

                if(dt.Rows[i]["teacherType"].ToString().Trim() == "教师")
                {
                    ddlTeacherType.Items.Add(new ListItem("教师", "教师"));
                    ddlTeacherType.Items.Add(new ListItem("助教", "助教"));
                }
                else
                {
                    ddlTeacherType.Items.Add(new ListItem("助教", "助教"));
                    ddlTeacherType.Items.Add(new ListItem("教师", "教师"));
                }

                DalOperationAboutCourses doac = new DalOperationAboutCourses();
                DataTable _dt = doac.FindAllTermTags().Tables[0];

                string termTag = string.Empty;

                for (int j = 0; j < _dt.Rows.Count; j++)
                {
                    termTag = _dt.Rows[j]["termTag"].ToString().Trim();
                    ListItem li = new ListItem(CommonUtility.ChangeTermToString(termTag), termTag);
                    ddlTermTags.Items.Add(li);
                }

                for (int x = 0; x < ddlTermTags.Items.Count; x++)
                {
                    if (dt.Rows[i]["termTag"].ToString().Trim() == ddlTermTags.Items[x].Value)
                    {
                        ddlTermTags.SelectedIndex = x;
                    }
                }
            }
        }
        /// <summary>
        /// 绑定结课资料规则数据
        /// </summary>
        public void DataBindArchivesItems()
        {
            DalOperationAboutArchivesItems doac = new DalOperationAboutArchivesItems();
            UserCookiesInfo user = new UserCookiesInfo();

            DataView dv = doac.GetAllArchivesItem().Tables[0].DefaultView;

            this.dlstArchivesItems.DataSource = dv;
            this.dlstArchivesItems.DataBind();

            if (dv.Count == 0)
            {
                this.dlstArchivesItems.ShowFooter = true;
            }
            else
            {
                this.dlstArchivesItems.ShowFooter = false;
            }
        }
    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)+ "&nbsp;&nbsp;<input type=\"button\" value=\"为" + dv.Rows[i]["archiveItemName"].ToString().Trim() + "添加一个附件\"" + " onclick=\"addIframe(" + fileFolderType +
        "," + (i + 1).ToString() + "," + (i + 1).ToString() + ");\" />" + "&nbsp;&nbsp;<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();
            }
        }
        /// <summary>
        /// 搜索到的学生列表操作
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void dlstArchivesItems_ItemCommand(object source, DataListCommandEventArgs e)
        {
            DalOperationAboutArchivesItems dos = new DalOperationAboutArchivesItems();

            if (e.CommandName == "delete")
            {
                int archiveItemId = int.Parse(dlstArchivesItems.DataKeys[e.Item.ItemIndex].ToString());//取选中行学生编号

                if (dos.DeleteArchivesItemById(archiveItemId) > 0)
                {
                    Javascript.AlertAndRedirect("删除成功!", "/Administrator/ArchivesManage.aspx?fragment=2", Page);
                }
                else
                {
                    Javascript.GoHistory(-1, "删除失败!", Page);
                }
            }
        }