//删除文件 public void DeleteFile(int AttachId, string path) { BLHelper.BLLAttachment BLLattachment = new BLHelper.BLLAttachment(); if (File.Exists(path)) { FileInfo file = new FileInfo(path); if (file.Attributes.ToString().IndexOf("ReadOnly") != -1) { file.Attributes = FileAttributes.Normal; } File.Delete(path); } BLLattachment.Delete(AttachId); }
//保存 protected void Save_Click(object sender, EventArgs e) { try { if (txtReportPeople.Text.Trim() == "") { Alert.ShowInTop("姓名不能为空!"); txtReportPeople.Reset(); return; } if (txtReportUnit.Text.Trim() == "") { Alert.ShowInTop("报告人单位不能为空!"); txtReportUnit.Reset(); return; } if (txtReportName.Text.Trim() == "") { Alert.ShowInTop("学术报告名称不能为空!"); txtReportName.Reset(); return; } if (txtReportPlace.Text.Trim() == "") { Alert.ShowInTop("报告地点不能为空!"); txtReportPlace.Reset(); return; } if (DatePikerReportTime.Text == "") { Alert.ShowInTop("报告时间不能为空!"); DatePikerReportTime.Reset(); return; } if (txtPeopleCount.Text.Trim() == "") { Alert.ShowInTop("参与人数不能为空!"); txtPeopleCount.Reset(); return; } newacademicreporting = BLLNAR.FindByNAReportingID(Convert.ToInt32(Session["NewAcademicReporting"])); Newnareporting.ReportTime = Convert.ToDateTime(DatePikerReportTime.Text); Newnareporting.PeopleCount = Convert.ToInt32(txtPeopleCount.Text.Trim()); Newnareporting.SecrecyLevel = Convert.ToInt32(DropDownList_SecrecyLevel.SelectedValue); Newnareporting.Remark = Remark.Text; Newnareporting.ReportPeople = txtReportPeople.Text; Newnareporting.JobName = txtJobName.Text; Newnareporting.JobMission = txtJobMission.Text; Newnareporting.ReportUnit = txtReportUnit.Text; Newnareporting.Report = txtReport.Text; Newnareporting.ReportTele = txtReportTele.Text; Newnareporting.AcademicTitle = txtAcademicTitle.Text; Newnareporting.ReportName = txtReportName.Text; Newnareporting.ReportPlace = txtReportPlace.Text; Newnareporting.ApplyFund = txtApplyFund.Text; Newnareporting.Organizers = txtOrganizers.Text; Newnareporting.Coorganizer = txtCoorganizer.Text; Newnareporting.ReportType = txtReportType.Text; Newnareporting.MajorPeople = txtMajorPeople.Text; Newnareporting.EntryPerson = BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName; //用户等级为5级可直接通过 if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { Newnareporting.IsPass = true; } else { Newnareporting.IsPass = false; } int AttachID = pm.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: Newnareporting.AttachmentID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: Newnareporting.AttachmentID = AttachID; break; } if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { //操作日志表对象 Common.Entities.OperationLog operationLog = InsertOperationLog(); operationLog.OperationDataID = Convert.ToInt32(Session["NewAcademicReportingID"]); Newnareporting.EntryPerson = BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName; Newnareporting.IsPass = false; newacademicreporting.IsPass = false; BLLNAR.Insert(Newnareporting); operationLog.Remark = Newnareporting.NewAcademicReportingID.ToString(); BLLOL.Insert(operationLog); Alert.ShowInTop("您的数据已提交,请等待确认"); } else { Newnareporting.NewAcademicReportingID = Convert.ToInt32(Session["NewAcademicReportingID"]); BLLNAR.Update(Newnareporting); Alert.ShowInTop("保存成功"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); } catch (Exception ex) { //删除附件文件 string path = BLLattachment.FindPath(Convert.ToInt32(newacademicreporting.AttachmentID)); if (path != "") { pm.DeleteFile(Convert.ToInt32(newacademicreporting.AttachmentID), path); //删除附件表中的数据 BLLattachment.Delete(Convert.ToInt32(newacademicreporting.AttachmentID));//删除成功返回true } //BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); } //PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference() + Alert.GetShowInTopReference("保存成功!")); }
//删除 protected void btnDeleteReport_Click(object sender, EventArgs e) { try { int m; //取整数(不是四舍五入,全舍) int Pages = (int)Math.Floor(Convert.ToDouble(Grid_ReportInfo.RecordCount / this.Grid_ReportInfo.PageSize)); if (Grid_ReportInfo.PageIndex == Pages) { m = (Grid_ReportInfo.RecordCount - this.Grid_ReportInfo.PageSize * Grid_ReportInfo.PageIndex); } else { m = this.Grid_ReportInfo.PageSize; } List <int> selections = new List <int>(); for (int i = 0; i < m; i++) { if (CBoxSelect_Report.GetCheckedState(i)) { selections.Add(i); } } if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { int?attachid = BLLReport.Delete(Convert.ToInt32(Grid_ReportInfo.DataKeys[selections[i]][0].ToString())); if (attachid != 0 && attachid != null) {//删除附件 //在附件表中删除学术报告附件 BLLAttachment.Delete(Convert.ToInt32(attachid)); //删除附件文件 string path = BLLAttachment.FindPath(Convert.ToInt32(attachid)); if (path != "") { publicMethod.DeleteFile(Convert.ToInt32(attachid), path); } } } Grid_ReportInfo.PageIndex = 0; Grid_ReportInfo.PageSize = 20; btnDeleteReport.Enabled = false; DropDownList_Agency.SelectedValue = "0"; BindReport(); Alert.ShowInTop("删除成功!"); } else { for (int i = 0; i < selections.Count(); i++) { BLLReport.ChangePass(Convert.ToInt32(Grid_ReportInfo.DataKeys[selections[i]][0]), false); //向操作日志表插入信息 Common.Entities.OperationLog operationLog = new Common.Entities.OperationLog(); operationLog.LoginIP = " "; operationLog.LoginName = Session["LoginName"].ToString(); operationLog.OperationType = "删除"; operationLog.OperationContent = "ScienceReport"; operationLog.OperationTime = DateTime.Now; operationLog.OperationDataID = Convert.ToInt32(Grid_ReportInfo.DataKeys[selections[i]][0]); BLLOP.Insert(operationLog); } btnDeleteReport.Enabled = false; DropDownList_Agency.SelectedValue = "0"; Grid_ReportInfo.PageIndex = 0; Grid_ReportInfo.PageSize = 20; BindReport(); Alert.ShowInTop("您的数据已提交,请等待确认!"); } } catch (Exception ex) { BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); return; } }
//保存资料信息 protected void btnSave_Click(object sender, EventArgs e) { try { if (Session["LoginName"].ToString() == "") { Response.Redirect("login.aspx"); Alert.Show("登录超时!"); } if (txtContractHeadLine.Text.Trim() == "") { Alert.ShowInTop("资料题目不能为空!"); txtContractHeadLine.Reset(); return; } if (txtContractAuthors.Text.Trim() == "") { Alert.ShowInTop("资料保存人不能为空!"); txtContractAuthors.Reset(); return; } if (txtContractOriginal.Text.Trim() == "") { Alert.ShowInTop("原始文件保存人不能为空 ! "); txtContractOriginal.Reset(); return; } NewContract.ContractAuthors = txtContractAuthors.Text; NewContract.ContractHeadLine = txtContractHeadLine.Text; NewContract.ContractOriginal = txtContractOriginal.Text; NewContract.EntryPerson = BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName; NewContract.SecrecyLevel = Convert.ToInt32(DropDownList_SecrecyLevel.SelectedValue); //上传附件 int AttachID = pm.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: NewContract.AttachmentID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: NewContract.AttachmentID = AttachID; break; } if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { NewContract.IsPass = true; //向资料表中插入数据 BLLcontract.Insert(NewContract); Alert.ShowInTop("保存成功"); } else { NewContract.IsPass = false; //向资料表中插入数据 BLLcontract.Insert(NewContract); //向操作日志表中插入信息 operationLog.LoginIP = " "; operationLog.LoginName = Session["LoginName"].ToString(); operationLog.OperationType = "添加"; operationLog.OperationContent = "Contract"; operationLog.OperationTime = DateTime.Now; operationLog.OperationDataID = NewContract.ContractID; //向操作日志表中插入数据 BLLOL.Insert(operationLog); Alert.ShowInTop("您的数据已提交,请等待确认"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); } catch (Exception ex) { int ContractID = NewContract.ContractID; //删除资料附件 int AttactID = BLLcontract.FindAttachmentID(ContractID); string strPath; if (AttactID != 0) { strPath = BLLattachment.FindPath(AttactID); if (strPath != "") { //删除附件文件 pm.DeleteFile(AttactID, strPath); //在附件表中删除附件数据 BLLattachment.Delete(AttactID); } } //BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); } }
//删除获奖信息 protected void btnDelete_Click(object sender, EventArgs e) { //如果为超级管理员操作则直接删除,否则将IsPass置为false 向管理员发送删除信息 try { int m; //取整数(不是四舍五入,全舍) int Pages = (int)Math.Floor(Convert.ToDouble(Grid_Award.RecordCount / this.Grid_Award.PageSize)); if (Grid_Award.PageIndex == Pages) { m = (Grid_Award.RecordCount - this.Grid_Award.PageSize * Grid_Award.PageIndex); } else { m = this.Grid_Award.PageSize; } List <int> selections = new List <int>(); for (int i = 0; i < m; i++) { if (CBoxSelect.GetCheckedState(i)) { selections.Add(i); } } if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { int AcademicMeetingID = Convert.ToInt32(Grid_Award.DataKeys[selections[i]][0].ToString()); //删除获奖附件文件->删除附件表中的信息->删除学术会议信息 int AttactID = award.FindAttachmentID(AcademicMeetingID); string strPath; if (AttactID != 0) { strPath = BLLAttachment.FindPath(AttactID); if (strPath != "") { //删除附件文件 pm.DeleteFile(AttactID, strPath); //在附件表中删除附件数据 BLLAttachment.Delete(AttactID); } } //删除获奖信息 award.Delete(Convert.ToInt32(Grid_Award.DataKeys[selections[i]][0].ToString())); } Alert.ShowInTop("删除成功!"); btnSelect_All.Text = "全选"; } else { //录入人(非管理员)操作 for (int i = 0; i < selections.Count(); i++) { award.UpdateIsPass(Convert.ToInt32(Grid_Award.DataKeys[selections[i]][0]), false); //BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName operate.LoginName = Session["LoginName"].ToString(); operate.OperationTime = DateTime.Now; operate.LoginIP = " "; operate.OperationContent = "Award"; operate.OperationType = "删除"; operate.OperationDataID = Convert.ToInt32(Grid_Award.DataKeys[selections[i]][0]); op.Insert(operate); //BindData(); Alert.ShowInTop("操作已经提交,请等待管理员确认!"); } } Grid_Award.PageIndex = 0; Grid_Award.PageSize = 20; btnDelete.Enabled = false; InitData(); btnSelect_All.Text = "全选"; } catch (Exception ex) { BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); return; } }
//删除 protected void btnDelete_Click(object sender, EventArgs e) { List <int> selections = new List <int>(); for (int i = 0; i < Grid_Pact.RecordCount; i++) { if (BoxSelect_Pact.GetCheckedState(i)) { selections.Add(i); } } if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { int PactID = Convert.ToInt32(Grid_Pact.DataKeys[selections[i]][0].ToString()); //删除资料附件 int AttactID = BLLPact.FindAttachmentID(PactID); string strPath; if (AttactID != 0) { strPath = BLLAttachment.FindPath(AttactID); if (strPath != "") { //在附件表中删除附件数据 BLLAttachment.Delete(AttactID); //删除附件文件 publicMethod.DeleteFile(AttactID, strPath); } } //删除该合同的借阅记录 List <int> listRecordID = BLLLibraryRecord.FindLibraryID(PactID, "合同"); if (listRecordID != null) { for (int j = 0; j < listRecordID.Count(); j++) { BLLLibraryRecord.Delete(listRecordID[j]); } } //合同表删除 BLLPact.Delete(Convert.ToInt32(Grid_Pact.DataKeys[selections[i]][0].ToString())); } Alert.ShowInTop("删除数据成功!"); btnSelect_All.Text = "全选"; } else { for (int i = 0; i < selections.Count(); i++) { BLLPact.UpdateIsPass(Convert.ToInt32(Grid_Pact.DataKeys[selections[i]][0]), false); //将借阅记录表中与该资料有关的数据置为false List <int> listRecordID = BLLLibraryRecord.FindLibraryID(Convert.ToInt32(Grid_Pact.DataKeys[selections[i]][0]), "合同"); for (int j = 0; j < listRecordID.Count(); i++) { BLLLibraryRecord.UpdateIsPass(listRecordID[j], false); } operate.LoginName = Session["LoginName"].ToString(); operate.OperationTime = DateTime.Now; operate.LoginIP = " "; operate.OperationContent = "Pact"; operate.OperationType = "删除"; operate.OperationDataID = Convert.ToInt32(Grid_Pact.DataKeys[selections[i]][0]); op.Insert(operate); } Alert.ShowInTop("操作已经提交,请等待管理员确认!"); btnSelect_All.Text = "全选"; } btnDelete.Enabled = false; Grid_Pact.PageIndex = 0; Grid_Pact.PageSize = 20; BindData(); }
//保存 protected void btnSave_Click(object sender, EventArgs e) { try { if (txtLecturesName.Text.Trim() == "") { Alert.ShowInTop("姓名不能为空!"); txtLecturesName.Reset(); return; } if (txtWorkPlace.Text.Trim() == "") { Alert.ShowInTop("工作单位不能为空!"); txtWorkPlace.Reset(); return; } //原单位讲学对象 unitLectures = BLLUL.FindByUnitLecturesID(Convert.ToInt32(Session["UnitLecturesID"])); //单位讲学表对象 NewUnitLectures.LecturesName = txtLecturesName.Text; NewUnitLectures.AgencyID = BLLAgency.SelectAgencyID(DropDownList_Agency.SelectedText); NewUnitLectures.UReportName = txtUReportName.Text; NewUnitLectures.LecturesTime = Convert.ToDateTime(DatePikerLecturesTime.Text); NewUnitLectures.WorkUnit = txtWorkPlace.Text; NewUnitLectures.listenerNumber = Convert.ToInt32(txtlistenerNumber.Text); NewUnitLectures.SecrecyLevel = Convert.ToInt32(DropDownList_SecrecyLevel.SelectedValue); NewUnitLectures.LecturesPlace = txtLecturesPlace.Text; NewUnitLectures.WorkTitle = txtjobtitle.Text; NewUnitLectures.Identity = txtIDCard.Text; NewUnitLectures.Telephone = txtTel.Text; NewUnitLectures.Remark = Remark.Text; NewUnitLectures.EntryPerson = unitLectures.EntryPerson; //用户等级为5级可直接通过 if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { NewUnitLectures.IsPass = true; } else { NewUnitLectures.IsPass = false; } int AttachID = pm.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: NewUnitLectures.AttachmentID = unitLectures.AttachmentID; break; default: NewUnitLectures.AttachmentID = AttachID; break; } if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { //操作日志表对象 Common.Entities.OperationLog operationLog = InsertOperationLog(); operationLog.OperationDataID = Convert.ToInt32(Session["UnitLecturesID"]); NewUnitLectures.EntryPerson = BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName; NewUnitLectures.IsPass = false; unitLectures.IsPass = false; BLLUL.Insert(NewUnitLectures); //向单位讲学表插入信息 operationLog.Remark = NewUnitLectures.UnitLecturesID.ToString(); BLLOL.Insert(operationLog); //向操作日志表插入信息 Alert.ShowInTop("操数据已经提交,等待管理员确认!"); } else { NewUnitLectures.UnitLecturesID = Convert.ToInt32(Session["UnitLecturesID"]); BLLUL.Update(NewUnitLectures); Alert.ShowInTop("保存成功!"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); } catch (Exception ex) { //删除附件文件 string path = BLLattachment.FindPath(Convert.ToInt32(unitLectures.AttachmentID)); if (path != "") { pm.DeleteFile(Convert.ToInt32(unitLectures.AttachmentID), path); //删除附件表中的数据 BLLattachment.Delete(Convert.ToInt32(unitLectures.AttachmentID));//删除成功返回true } //BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); } }
//保存 protected void btnSave_Click(object sender, EventArgs e) { try { if (txtPactNum.Text.Trim() == "") { Alert.ShowInTop("合同编号不能为空!"); txtPactNum.Reset(); return; } if (txtPactType.Text.Trim() == "") { Alert.ShowInTop("合同类别不能为空!"); txtPactType.Reset(); return; } if (DatePicker_StartTime.SelectedDate > DatePicker_EndTime.SelectedDate) { Alert.ShowInTop("结束日期应该大于开始日期!"); return; } NewPact.EndTime = DatePicker_EndTime.SelectedDate; NewPact.EntryPerson = BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName; NewPact.PactNum = txtPactNum.Text; NewPact.PactType = txtPactType.Text; NewPact.ProjectID = BLLProject.SelectProjectID(DropDownList_Project.SelectedText); NewPact.SecrecyLevel = Convert.ToInt32(DropDownList_SecrecyLevel.SelectedValue); NewPact.StartTime = DatePicker_StartTime.SelectedDate; NewPact.PactName = txtPactName.Text; NewPact.ChargePerson = txtChargePerson.Text; NewPact.PactMoney = txtPactMoney.Text; NewPact.RealMoney = txtRealMoney.Text; NewPact.PactCompletion = txtPactCompletion.Text; NewPact.IsExistingFile = txtIsExistingFile.Text; NewPact.FileNum = txtFileNum.Text; if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { NewPact.IsPass = true; } else { NewPact.IsPass = false; } int AttachID = pm.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: NewPact.AttachmentID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: NewPact.AttachmentID = AttachID; break; } if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { NewPact.IsPass = false; } else { NewPact.IsPass = true; } //向合同档案表中插入数据 BLLPact.Insert(NewPact); //向操作日志表中插入数据 if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { operationLog.LoginIP = " "; operationLog.LoginName = Session["LoginName"].ToString(); operationLog.OperationType = "添加"; operationLog.OperationContent = "Pact"; operationLog.OperationTime = DateTime.Now; operationLog.OperationDataID = NewPact.PactID; BLLOp.Insert(operationLog); Alert.ShowInTop("您的数据已提交,请等待确认!"); } else { Alert.ShowInTop("保存成功!"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); } catch (Exception ex) { int PactID = Convert.ToInt32(NewPact.AttachmentID); //删除资料附件 int AttactID = BLLPact.FindAttachmentID(PactID); string strPath; if (AttactID != 0) { strPath = BLLattachment.FindPath(AttactID); if (strPath != "") { //在附件表中删除附件数据 BLLattachment.Delete(AttactID); //删除附件文件 pm.DeleteFile(AttactID, strPath); } } //BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); } }
//保存增加会议信息 protected void btnSave_Click(object sender, EventArgs e) { try { NewcademicMeeting = ObjectAcademicMeeting(); if (Session["LoginName"].ToString() == "") { Response.Redirect("login.aspx"); Alert.Show("登录超时!"); } string MeetingName = txtMeetingName.Text; int MeetingID = BLLAM.FindMeetingID(MeetingName); if (MeetingID != 0) { //txtMeetingName.Text = ""; txtMeetingName.Reset(); Alert.ShowInTop("该学术会议名称已存在,请重新输入!"); return; } if (DatePicker_EndTime != null) { if (DatePicker_StratTime.SelectedDate > DatePicker_EndTime.SelectedDate) { Alert.ShowInTop("结束日期应该大于开始日期!"); return; } } if (txtMeetingName.Text.Trim() == "") { Alert.ShowInTop("会议名称不能为空!"); txtMeetingName.Reset(); return; } if (txtOrganizer.Text.Trim() == "") { Alert.ShowInTop("主办方不能为空!"); txtOrganizer.Reset(); return; } if (txtMeetingPlace.Text.Trim() == "") { Alert.ShowInTop("会议地点不能为空!"); txtMeetingPlace.Reset(); return; } //int attachId = publicMethod.UpLoad(filePath); //学术会议表对象 //Common.Entities.AcademicMeeting NewcademicMeeting = ObjectAcademicMeeting(); int AttachID = publicMethod.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: NewcademicMeeting.AttachmentID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: NewcademicMeeting.AttachmentID = AttachID; break; } AttachID = publicMethod.UpLoadPhoto(photoupload); switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: NewcademicMeeting.PhotoID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: NewcademicMeeting.PhotoID = AttachID; break; } //向学术会议表插入信息 BLLAM.Insert(NewcademicMeeting); //非管理员登陆需要向操作日志表中插入信息,等待管理员审核 if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { //操作日志表对象 Common.Entities.OperationLog operationLog = InsertOperationLog(); operationLog.OperationDataID = NewcademicMeeting.AcademicMeetingID; //向操作日志表中插入信息 BLLOL.Insert(operationLog); Alert.ShowInTop("您的数据已提交,请等待确认"); } else { Alert.ShowInTop("保存成功"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); } catch (Exception ex) { int AttactID = BLLAM.FindAttachmentID(NewcademicMeeting.AcademicMeetingID); string strPath; if (AttactID != 0) { strPath = BLLattachment.FindPath(AttactID); if (strPath != "") { //删除附件文件 publicMethod.DeleteFile(AttactID, strPath); //在附件表中删除附件数据 BLLattachment.Delete(AttactID); } } BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); Alert.ShowInTop("保存失败!"); // return; } }
//保存 protected void btnSave_Click(object sender, EventArgs e) { try { scienceReport = InserScienceReport(); if (Session["LoginName"].ToString() == "") { Response.Redirect("login.aspx"); Alert.Show("登录超时!"); } if (txtReportName.Text.Trim() == "") { Alert.ShowInTop("报告名称不能为空!"); txtReportName.Reset(); return; } if (txtReportName.Text.Trim() == "") { Alert.ShowInTop("报告名称不能为空!"); txtReportName.Reset(); return; } if (txtReportPeople.Text.Trim() == "") { Alert.ShowInTop("报告人不能为空!"); txtReportPeople.Reset(); return; } //int attachId = publicMethod.UpLoad(fileupload); //Common.Entities.ScienceReport scienceReport = InserScienceReport(); //上传文件并向附件表中插入数据 int AttachID = publicMethod.UpLoadFile(fileupload).Attachid; switch (AttachID) { case -1: Alert.ShowInTop("文件类型不符,请重新选择!"); return; case 0: Alert.ShowInTop("文件名已经存在!"); return; case -2: Alert.ShowInTop("文件不能大于150M"); return; case -3: scienceReport.AccessoryID = null; break; //Alert.ShowInTop("请上传附件"); //return; default: scienceReport.AccessoryID = AttachID; break; } //向学术报告表中插入数据 BLLScience.Insert(scienceReport); Common.Entities.OperationLog OL = InsertOperationLog(); if (Convert.ToInt32(Session["SecrecyLevel"]) != 5) { //向操作日志表中插入数据 OL.OperationDataID = scienceReport.ScienceReportID; operationLog.Insert(OL); Alert.ShowInTop("您的数据已提交,请等待确认"); } else { Alert.ShowInTop("保存成功"); } PageContext.RegisterStartupScript(ActiveWindow.GetConfirmHideRefreshReference()); //Reset(); } catch (Exception ex) { int?attachid = scienceReport.AccessoryID; if (attachid != 0 && attachid != null) {//删除附件 //在附件表中删除学术报告附件 BLLattachment.Delete(Convert.ToInt32(attachid)); //删除附件文件 string path = BLLattachment.FindPath(Convert.ToInt32(attachid)); if (path != "") { publicMethod.DeleteFile(Convert.ToInt32(attachid), path); } } BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); return; } }
//删除资料 protected void btnDelete_Click(object sender, EventArgs e) { try { int m; //取整数(不是四舍五入,全舍) int Pages = (int)Math.Floor(Convert.ToDouble(Grid_Contract.RecordCount / this.Grid_Contract.PageSize)); if (Grid_Contract.PageIndex == Pages) { m = (Grid_Contract.RecordCount - this.Grid_Contract.PageSize * Grid_Contract.PageIndex); } else { m = this.Grid_Contract.PageSize; } List <int> selections = new List <int>(); for (int i = 0; i < m; i++) { if (BoxSelect_Contract.GetCheckedState(i)) { selections.Add(i); } } if (Convert.ToInt32(Session["SecrecyLevel"]) == 5) { for (int i = 0; i < selections.Count(); i++) { int ContractID = Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0].ToString()); //删除资料附件 int AttactID = BLLContract.FindAttachmentID(ContractID); string strPath; if (AttactID != 0) { strPath = BLLAttachment.FindPath(AttactID); if (strPath != "") { //删除附件文件 publicMethod.DeleteFile(AttactID, strPath); //在附件表中删除附件数据 BLLAttachment.Delete(AttactID); } } //删除资料借阅记录 List <int> listRecordID = BLLLibraryRecord.FindLibraryID(ContractID, "资料"); if (listRecordID != null) { for (int j = 0; j < listRecordID.Count(); j++) { BLLLibraryRecord.Delete(listRecordID[j]); } } //删除资料 BLLContract.Delete(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0].ToString())); } Alert.ShowInTop("删除成功!"); btnSelect_All.Text = "全选"; } else { for (int i = 0; i < selections.Count(); i++) { BLLContract.UpdateIsPass(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]), false); List <int> listRecordID = BLLLibraryRecord.FindLibraryID(Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]), "资料"); for (int j = 0; j < listRecordID.Count(); i++) { BLLLibraryRecord.UpdateIsPass(listRecordID[j], false); } //BLLUser.FindByLoginName(Session["LoginName"].ToString()).UserName operate.LoginName = Session["LoginName"].ToString(); operate.OperationTime = DateTime.Now; operate.LoginIP = " "; operate.OperationContent = "Contract"; operate.OperationType = "删除"; operate.OperationDataID = Convert.ToInt32(Grid_Contract.DataKeys[selections[i]][0]); op.Insert(operate); //BindData(); Alert.ShowInTop("操作已经提交,请等待管理员确认!"); btnSelect_All.Text = "全选"; } } btnDelete.Enabled = false; BindData(); Grid_Contract.PageIndex = 0; Grid_Contract.PageSize = 20; BindData(); } catch (Exception ex) { BLCommon.PublicMethod pm = new BLCommon.PublicMethod(); pm.SaveError(ex, this.Request); } }