//删除 protected void Delete_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(Request.QueryString["id"].ToString()); int[] attachId = pa.FindAttachmentID(id); string srcPath = at.FindPath(attachId[0]); if (attachId[0] == 0 || srcPath == "") { Alert.Show("该专利不存在相关文档"); } else { pm.DeleteFile(attachId[0], srcPath); Common.Entities.Patent pat = pa.FindAll(id).FirstOrDefault(); pat.Attachment_Patent = null; pa.Update(pat); //Alert.Show("删除成功!"); PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideReference() + Alert.GetShowInTopReference("删除成功!")); } } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
//更新保存 protected void Save_Click(object sender, EventArgs e) { try { //if (tPatentName.Text.Trim() == "") //{ // Alert.Show("专利名称不能为空!"); // return; //} //if (tPatentNumber.Text.Trim() == "") //{ // Alert.Show("专利号不能为空!"); // return; //} //if (tGivenUnit.Text.Trim() == "") //{ // Alert.Show("授予机构不能为空!"); // return; //} //if (tState.Text.Trim() == "") //{ // Alert.Show("状态不能为空!"); // return; //} //if (PatentPeople.Text.Trim() == "") //{ // Alert.Show("发明人不能为空!"); // return; //} //if (FirstPeople.Text.Trim() == "") //{ // Alert.Show("第一发明人不能为空!"); // return; //} //if (tAccreditTime.SelectedDate < tApplicationTime.SelectedDate) //{ // Alert.ShowInTop("授权时间不能小于申请时间!"); // return; //} List <string> list = new List <string>(); string unit = ""; list.Add(tPatentDepartment1.Text.ToString()); list.Add(tPatentDepartment2.Text.ToString()); list.Add(tPatentDepartment3.Text.ToString()); List <string> newlist = new List <string>(); for (int i = 0; i < 3; i++) { if (!string.IsNullOrEmpty(list[i].ToString())) { newlist.Add(list[i].ToString()); } } if (newlist.Count != 0) { for (int j = 0; j < newlist.Count; j++) { unit += newlist[j].ToString(); if (j == newlist.Count() - 1) { break; } unit += ","; } pat.PatentDepartment = unit; } else { pat.PatentDepartment = null; } //lby ↓ int[] AttachmentID = patent.FindAttachmentID(Convert.ToInt32(Session["PatentID"])); UpdateValue(); if (Convert.ToInt32(Session["SecrecyLevel"]) == 5)//如果等于5级 { string path_Patent, path_Application; if (AttachmentID != null) { path_Patent = at.FindPath(AttachmentID[0]); path_Application = at.FindPath(AttachmentID[1]); } else { path_Patent = null; path_Application = null; } pat.IsPass = true; pat.PatentID = Convert.ToInt32(Session["PatentID"]); //lby ↓ int attachid = pm.UpLoadFile(PatentFile).Attachid; if (attachid != -3)//上传控件是否有值 { switch (attachid) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; } pat.Attachment_Patent = attachid;//附件为新插入的附件ID pm.DeleteFile(AttachmentID[0], path_Patent); } else //上传控件没有值 { if (AttachmentID != null && AttachmentID[0] != 0) { pat.Attachment_Patent = AttachmentID[0]; } } attachid = pm.UpLoadFile(ApplicationFile).Attachid; if (attachid != -3)//上传控件是否有值 { switch (attachid) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; } pat.Attachment_Application = attachid;//附件为新插入的附件ID pm.DeleteFile(AttachmentID[1], path_Application); } else //上传控件没有值 { if (AttachmentID != null && AttachmentID[1] != 0) { pat.Attachment_Application = AttachmentID[1]; } } patent.Update(pat);//更新 PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("更新成功!")); } else//小于5级 { string username = user.FindByLoginName(Session["LoginName"].ToString()).UserName; operate.LoginName = username; operate.OperationTime = DateTime.Now; operate.LoginIP = " "; operate.OperationContent = "Patent"; operate.OperationType = "更新"; pat.IsPass = false; //lby ↓ int attachid = pm.UpLoadFile(PatentFile).Attachid; if (attachid != -3)//上传控件是否有值 { switch (attachid) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; } pat.Attachment_Patent = attachid;//附件为新插入的附件ID } else//上传控件没有值 { if (AttachmentID[0] != 0)//原来有附件 { pat.Attachment_Patent = AttachmentID[0]; } } attachid = pm.UpLoadFile(ApplicationFile).Attachid; if (attachid != -3)//上传控件是否有值 { switch (attachid) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; } pat.Attachment_Application = attachid;//附件为新插入的附件ID } else//上传控件没有值 { if (AttachmentID[1] != 0)//原来有附件 { pat.Attachment_Application = AttachmentID[1]; } } patent.Insert(pat);//插入 operate.OperationDataID = Convert.ToInt32(Session["PatentID"]); operate.Remark = pat.PatentID.ToString(); op.Insert(operate);//将成果更新插入操作表 patent.UpdateIsPass(Convert.ToInt32(Session["PatentID"]), false); PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("数据已缓存,正在等待审核!")); } } catch (Exception ex) { //lby ↓ if (pat.Attachment_Patent != null && pat.Attachment_Application != null) { int[] attachid = { pat.Attachment_Patent.Value, pat.Attachment_Application.Value }; string path_Patent = at.FindPath(attachid[0]); string path_Application = at.FindPath(attachid[1]); pm.DeleteFile(attachid[0], path_Patent); pm.DeleteFile(attachid[1], path_Application); } pm.SaveError(ex, this.Request); } }