Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("QBZY");

            if (!UserType.Equals("mana")) { modify.Style.Add("display", "none"); }

            if (!Page.IsPostBack)
            {
                try
                {
                    #region Get id

                    int id;

                    if (string.IsNullOrEmpty(Request.QueryString["id"]))
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    try
                    {
                        id = int.Parse(Request.QueryString["id"]);
                    }
                    catch
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    #endregion

                    LabMS.Model.Resource resourceInfo;
                    ExtendBLL.Resource resource = new ExtendBLL.Resource();

                    resourceInfo = resource.GetModel(id);

                    if (resourceInfo == null)
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    LabMS.BLL.Lab lab = new LabMS.BLL.Lab();
                    LabMS.Model.Lab labInfo = lab.GetModel(resourceInfo.LabID.Value);

                    ResourceLab.Text = (labInfo == null) ? "ȫ��" : labInfo.Lab_Name;

                    if (resourceInfo.RecorderType == 0) // ����Ա
                    {
                        BLL.UserTable staff = new LabMS.BLL.UserTable();
                        LabMS.Model.UserTable staffInfo = staff.GetModel(resourceInfo.ResourceRecorder.HasValue ? resourceInfo.ResourceRecorder.Value : 0);

                        ResourceRecorder.Text = (staffInfo == null) ? "<del>��ɾ���û�</del>" : staffInfo.UserName + " ����Ա";
                    }
                    else if (resourceInfo.RecorderType == 1)
                    {
                        LabMS.BLL.Teacher teacher = new LabMS.BLL.Teacher();
                        LabMS.Model.Teacher teacherInfo = teacher.GetModel(resourceInfo.ResourceRecorder.HasValue ? resourceInfo.ResourceRecorder.Value : 0);
                        ResourceRecorder.Text = (teacherInfo == null) ? "<del>��ɾ���û�</del>" : teacherInfo.Teacher_Name + " ��ʦ";
                    }

                    // ResourceType.Text = resourceInfo.ResourceType.HasValue ? resourceInfo.ResourceType.Value.ToString() : ""; // TBD

                    ResourceTitle.Text = resourceInfo.ResourceTitle;
                    ResourceContent.Text = Server.HtmlDecode(resourceInfo.ResourceContent);
                    ResourceVisitTime.Text = (resourceInfo.ResourceVisitTime.Value + 1).ToString();
                    ResourceRecordTime.Text = resourceInfo.ResourceRecordTime.Value.ToString("yyyy��MM��dd�� HH:mm");

                    if (!string.IsNullOrEmpty(resourceInfo.ResourceAttachmentPath))
                    {
                        ResourceAttachment.Text = "<a target='_blank' href='" + resourceInfo.ResourceAttachmentPath + "' >������ظ���</a>";
                    }
                    else
                    {
                        ResourceAttachment.Text = "<label style='color: #ff0000;'>���޸���</label>";
                    }

                    #region Tags

                    DataSet dsTags = resource.GetTags(resourceInfo);

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();

                    for (int i = dsTags.Tables[0].Rows.Count - 1; i > -1; i--)
                    {
                        sb.Append(dsTags.Tables[0].Rows[i]["TagName"]);

                        if (i != 0) { sb.Append(","); }
                    }

                    ResourceTags.Text = sb.ToString();

                    #endregion

                    resourceInfo.ResourceVisitTime += 1;
                    resource.Update(resourceInfo);

                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("QBZY");
            strPageUserType.Add("mana");
            strPageUserType.Add("teacher");

            if (!Page.IsPostBack)
            {
                try
                {
                    #region Get id

                    int id;

                    if (string.IsNullOrEmpty(Request.QueryString["id"]))
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    try
                    {
                        id = int.Parse(Request.QueryString["id"]);
                    }
                    catch
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    #endregion

                    LabMS.Model.Resource resourceInfo;
                    ExtendBLL.Resource resource = new ExtendBLL.Resource();

                    resourceInfo = resource.GetModel(id);

                    if (resourceInfo == null)
                    {
                        throw new Exception("�Բ����������ʵ�ҳ�治����");
                    }

                    #region ��ȡʵ����

                    LabMS.BLL.Lab lab = new LabMS.BLL.Lab();
                    DataSet dsLabs = lab.GetList(" Lab_ParentID is null ");
                    ResourceLab.Items.Add(new ListItem("ȫ��", "-1"));
                    foreach (DataRow dr in dsLabs.Tables[0].Rows)
                    {
                        ListItem li = new ListItem();
                        li.Text = dr["Lab_Name"].ToString();
                        li.Value = dr["ID"].ToString();

                        if (resourceInfo.LabID.Equals(int.Parse(li.Value)))
                        {
                            li.Selected = true;
                        }

                        ResourceLab.Items.Add(li);
                    }

                    #endregion

                    if (resourceInfo.RecorderType.Equals(0)) // ����Ա
                    {
                        LabMS.BLL.UserTable staff = new LabMS.BLL.UserTable();
                        LabMS.Model.UserTable staffInfo = staff.GetModel(resourceInfo.ResourceRecorder.HasValue ? resourceInfo.ResourceRecorder.Value : 0);

                        ResourceRecorder.Text = (staffInfo == null) ? "<del>��ɾ���û�</del>" : staffInfo.UserName + " ����Ա";
                    }
                    else if (resourceInfo.RecorderType == 1)
                    {
                        LabMS.BLL.Teacher teacher = new LabMS.BLL.Teacher();
                        LabMS.Model.Teacher teacherInfo = teacher.GetModel(resourceInfo.ResourceRecorder.HasValue ? resourceInfo.ResourceRecorder.Value : 0);
                        ResourceRecorder.Text = (teacherInfo == null) ? "<del>��ɾ���û�</del>" : teacherInfo.Teacher_Name + " ��ʦ";
                    }

                    // ResourceType.Text = resourceInfo.ResourceType.HasValue ? resourceInfo.ResourceType.Value.ToString() : ""; // TBD

                    ResourceTitle.Text = resourceInfo.ResourceTitle;
                    ResourceContent.Text = Server.HtmlDecode(resourceInfo.ResourceContent);
                    ResourceVisitTime.Text = (resourceInfo.ResourceVisitTime.Value + 1).ToString();
                    ResourceRecordTime.Text = resourceInfo.ResourceRecordTime.Value.ToString("yyyy��MM��dd�� hh:mm");

                    if (!string.IsNullOrEmpty(resourceInfo.ResourceAttachmentPath))
                    {
                        ResourceAttachment.Text = "<a target='_blank' href='" + resourceInfo.ResourceAttachmentPath + "' >������ظ���</a>";
                    }
                    else
                    {
                        ResourceAttachment.Text = "<label style='color: #ff0000;'>���޸���</label>";
                    }

                    #region Tags

                    DataSet dsTags = resource.GetTags(resourceInfo);

                    System.Text.StringBuilder sb = new System.Text.StringBuilder();

                    for (int i = dsTags.Tables[0].Rows.Count - 1; i > -1; i--)
                    {
                        sb.Append(dsTags.Tables[0].Rows[i]["TagName"]);

                        if (i != 0) { sb.Append(","); }
                    }

                    ResourceTags.Text = sb.ToString();

                    #endregion
                }
                catch (Exception ex)
                {
                }
            }
        }