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) { } } }
/// <summary> /// �ύ�� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Submit_Click(object sender, EventArgs e) { 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 #region validate if (string.IsNullOrEmpty(ResourceTitle.Text.Trim())) { WriteBackScript("alert('��Դ���ⲻ��Ϊ��')"); return; } else if (ResourceTitle.Text.Length > 50) { WriteBackScript("alert('��Դ���ⳤ�Ȳ��ܳ���50')"); return; } if (string.IsNullOrEmpty(ResourceContent.Text)) { WriteBackScript("alert('��Դ���ݲ���Ϊ��')"); return; } #endregion LabMS.Model.Resource resourceInfo; ExtendBLL.Resource resource = new ExtendBLL.Resource(); resourceInfo = resource.GetModel(id); if (resourceInfo == null) { return; } resourceInfo.ResourceTitle = ResourceTitle.Text; resourceInfo.ResourceContent = Server.HtmlEncode(ResourceContent.Text); resourceInfo.LabID = int.Parse(ResourceLab.SelectedValue); // resourceInfo.ResourceType = 1; // TBD string[] tags = ResourceTags.Text.Split(',', '��'); #region Upload file if (ResourceAttachmentFile.HasFile) { resourceInfo.ResourceAttachmentPath = "Attachment/" + Guid.NewGuid().ToString() + "." + ExtendBLL.FileUtility.GetFileExtension(ResourceAttachmentFile.FileName); ResourceAttachmentFile.PostedFile.SaveAs(Server.MapPath(resourceInfo.ResourceAttachmentPath)); } #endregion resource.Update(resourceInfo, tags); WriteBackScript("alert('����Դ�ɹ�');window.location.href='List.aspx';window.close();"); } catch (Exception ex) { } }