protected void btDel_Click(object sender, EventArgs e) { lbErr.Visible = false; CheckBox ch; LabMS.BLL.OpentProject bopentproject = new LabMS.BLL.OpentProject(); ExtendBLL.ProjectAppointment extendprojectapp = new ExtendBLL.ProjectAppointment(); try { for (int i = 0; i < gv_OpenProjectList.Rows.Count; i++) { ch = (CheckBox)gv_OpenProjectList.Rows[i].FindControl("checkdel"); if (ch.Checked) { extendprojectapp.Del(" where OP_ProjectCode='" + gv_OpenProjectList.DataKeys[i]["OP_ProjectCode"].ToString() + "'"); string CID = gv_OpenProjectList.DataKeys[i]["ID"].ToString(); bopentproject.Delete(int.Parse(CID)); } } //checkall.Checked = false; if (lbIsSearch.Text == "0") { bind(""); } else { string strWhere = " 1=1 "; if (ddlLab.SelectedValue != "0") { strWhere += "and Project_Lab = '" + ddlLab.SelectedValue + "'"; } if (ddlStatus.SelectedValue != "-1") { strWhere += "and OP_Audit = '" + ddlStatus.SelectedValue + "'"; } if (ddlYear.SelectedValue != "0") { strWhere += "and SYear = '" + ddlYear.SelectedValue + "'"; } if (ddlSemester.SelectedValue != "-1") { strWhere += "and Semester = '" + ddlSemester.SelectedValue + "'"; } if (!tbProjectName.Text.Trim().Equals("")) { strWhere += "and OP_ProjectName like '%" + tbProjectName.Text.Trim() + "%'"; } bind(strWhere); } Common.JShelper.JSAlert(Page, "success", "删除成功!"); } catch (Exception ex) { Common.JShelper.JSAlert(Page, "err", "删除失败!"); lbErr.Visible = true; lbErr.Text = ex.Message; } }
void IniPage(string strYear, string strSemester) { List<LabMS.Model.Lab> listlab = new List<LabMS.Model.Lab>(); LabMS.BLL.Lab blab = new LabMS.BLL.Lab(); try { listlab = blab.GetModelList(""); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; return; } List<LabMS.Model.OpentProject> listopproject = new List<LabMS.Model.OpentProject>(); LabMS.BLL.OpentProject bopproject = new LabMS.BLL.OpentProject(); List<LabMS.Model.Teacher> listmteacher = new List<LabMS.Model.Teacher>(); LabMS.BLL.Teacher bteacher = new LabMS.BLL.Teacher(); List<LabMS.Model.ProjectAppointment> listprojectapp = new List<LabMS.Model.ProjectAppointment>(); ExtendBLL.ProjectAppointment bprojectapp = new ExtendBLL.ProjectAppointment(); string strtotalTable = "<table cellpadding='5' cellspacing='0' border='1' style='width: 100%; border-collapse: collapse;' class='infoTable'>"; strtotalTable += "<thead>"; strtotalTable += "<tr class='header'>"; strtotalTable += "<th scope='col'>"; strtotalTable += "实验室"; strtotalTable += "</th>"; strtotalTable += "<th scope='col'>"; strtotalTable += "开放项目"; strtotalTable += "</th>"; strtotalTable += "</tr>"; strtotalTable += "</thead>"; strtotalTable += "<tbody>"; foreach (LabMS.Model.Lab l in listlab) { strtotalTable += "<tr>"; strtotalTable += "<td>"; strtotalTable += l.Lab_Name; strtotalTable += "</td>"; strtotalTable += "<td>"; try { listopproject = bopproject.GetModelList(" SYear=" + strYear + " and Semester = " + strSemester + " and Project_Lab='" + l.Lab_Code + "' order by ID"); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; return; } if (listopproject.Count > 0) { strtotalTable += "<table cellpadding='0' cellspacing='0' border='1' style='width: 100%; border-collapse: collapse;' class='infoTable'>"; strtotalTable += "<thead>"; strtotalTable += "<tr class='header'>"; strtotalTable += "<td scope='col'>"; strtotalTable += "实验项目"; strtotalTable += "</td>"; strtotalTable += "<td scope='col'>"; strtotalTable += "时间(周次)"; strtotalTable += "</td>"; strtotalTable += "<td scope='col'>"; strtotalTable += "指导老师"; strtotalTable += "</td>"; strtotalTable += "<td scope='col'>"; strtotalTable += "学生数"; strtotalTable += "</td>"; strtotalTable += "</tr>"; strtotalTable += "</thead>"; strtotalTable += "<tbody>"; foreach (LabMS.Model.OpentProject o in listopproject) { strtotalTable += "<tr>"; strtotalTable += "<td>"; strtotalTable += o.OP_ProjectName; strtotalTable += "</td>"; strtotalTable += "<td>"; strtotalTable += o.Project_StartWeek.Value.ToString() + "--" + o.Project_EndWeek.Value.ToString(); strtotalTable += "</td>"; strtotalTable += "<td>"; try { listmteacher = bteacher.GetModelList(" Teacher_Code= '" + o.OP_Teacher + "'"); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; return; } if (listmteacher.Count > 0) { o.OP_Teacher = listmteacher[0].Teacher_Name; } strtotalTable += o.OP_Teacher; strtotalTable += "</td>"; strtotalTable += "<td>"; try { listprojectapp = bprojectapp.GetModelList(" OP_ProjectCode ='" + o.OP_ProjectCode + "'"); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; return; } o.OP_OpenType = listprojectapp.Count.ToString(); strtotalTable += o.OP_OpenType; strtotalTable += "</td>"; strtotalTable += "</tr>"; } strtotalTable += "</tbody>"; strtotalTable += "</table>"; } else { strtotalTable += "无"; } strtotalTable += "</td>"; strtotalTable += "</tr>"; } strtotalTable += "</tbody>"; strtotalTable += "</table>"; lbSituation.Text = strtotalTable; }
void bind(string strwhere) { LabMS.Model.SysSetting msys = new LabMS.Model.SysSetting(); ExtendBLL.SysSetting extendsys = new ExtendBLL.SysSetting(); msys = extendsys.GetCurrentSetting(); List<LabMS.Model.OpentProject> listmopproject = new List<LabMS.Model.OpentProject>(); LabMS.BLL.OpentProject bopproject = new LabMS.BLL.OpentProject(); if (strwhere.Equals("")) { strwhere += " 1=1 "; } strwhere += " and SYear = " + msys.CurrentYear + " and Semester = " + msys.CurrentSemester; if (UserType == "teacher") { strwhere += " and OP_Teacher = '" + UserCode + "'"; } listmopproject = bopproject.GetModelList(strwhere + " order by ID desc "); foreach (LabMS.Model.OpentProject op in listmopproject) { List<LabMS.Model.Teacher> listmteacher = new List<LabMS.Model.Teacher>(); LabMS.BLL.Teacher bteacher = new LabMS.BLL.Teacher(); listmteacher = bteacher.GetModelList(" Teacher_Code= '" + op.OP_Teacher + "'"); if (listmteacher.Count > 0) { op.OP_Teacher = listmteacher[0].Teacher_Name; } LabMS.BLL.Lab blab = new LabMS.BLL.Lab(); List<LabMS.Model.Lab> mLab = new List<LabMS.Model.Lab>(); mLab = blab.GetModelList(" Lab_Code='"+ op.Project_Lab +"'"); if (mLab.Count > 0) { op.Project_Lab = mLab[0].Lab_Name; } ExtendBLL.Dictionary eDictionary = new ExtendBLL.Dictionary(); List<Model.Dictionary> listCClass = new List<LabMS.Model.Dictionary>(); listCClass = eDictionary.GetModelList("DClass = 'shiyanyaoqiu' and Code = '"+op.Project_Require+"'"); if (listCClass.Count > 0) { op.Project_Require = listCClass[0].Name; } op.OP_Phone = op.Project_StartWeek.ToString()+"--"+op.Project_EndWeek.ToString(); List<LabMS.Model.ProjectAppointment>listprojectapp = new List<LabMS.Model.ProjectAppointment>(); ExtendBLL.ProjectAppointment bprojectapp = new ExtendBLL.ProjectAppointment(); listprojectapp = bprojectapp.GetModelList(" OP_ProjectCode ='"+op.OP_ProjectCode+"'"); op.OP_OpenType = listprojectapp.Count.ToString(); listCClass = eDictionary.GetModelList("DClass = 'shiyanleixing' and Code = '" + op.Project_Type + "'"); if (listCClass.Count > 0) { op.Project_Type = listCClass[0].Name; } if (op.OP_Audit == "0") { } op.OP_Audit = LabMS.Common.Status.GetOpenProjectStatus(op.OP_Audit); } gv_OpenProjectList.DataSource = listmopproject; gv_OpenProjectList.DataBind(); }
protected void AttachItemDataBind() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { int ID = 0; if (int.TryParse(Request.QueryString["ID"], out ID)) { LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); LabMS.Model.OpentProject openprojectmodel = new LabMS.Model.OpentProject(); LabMS.BLL.AttachmentItem AttachItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); openprojectmodel = OpenProject.GetModel(ID); if (openprojectmodel != null) { if (openprojectmodel.Attachment != null) { int Attach_ID = openprojectmodel.Attachment.Value; if (Attach_ID != 0) { ls = AttachItem.GetModelList("Attach_ID=" + Attach_ID); if (ls.Count != 0) { string strHTML = "<table>"; for (int i = 0; i < ls.Count; i++) { strHTML += "<tr>"; strHTML += "<td style='display:none;'>"; strHTML += ls[i].ID; strHTML += "</td>"; strHTML += "<td>"; strHTML += "<a>"; strHTML += "删除"; strHTML += "</a>"; strHTML += "</td>"; strHTML += "<td>"; strHTML += ls[i].Item_Name; strHTML += "</td>"; strHTML += "</tr>"; } strHTML += "</table>"; itemlist.Value = strHTML; } } } } } } }
LabMS.Model.OpentProject checkQueryString(string strID) { LabMS.BLL.OpentProject bopproject = new LabMS.BLL.OpentProject(); string strWhere = "ID =" + strID; List<LabMS.Model.OpentProject> listmopproject = bopproject.GetModelList(strWhere); if (listmopproject.Count == 0) { return null; } return listmopproject[0]; }
protected void bnSave_Click(object sender, EventArgs e) { LabMS.BLL.OpentProject bopproject = new LabMS.BLL.OpentProject(); string strWhere = "ID =" + lbCID.Text; List<LabMS.Model.OpentProject> listmopproject = bopproject.GetModelList(strWhere); if (listmopproject.Count == 0) { Common.JShelper.JSAlert(Page, "err2", "开放实验项目不存在!"); } LabMS.Model.OpentProject moproject = listmopproject[0]; #region 验证 if (string.IsNullOrEmpty(tbProjectStartWeek.Text.Trim()) || string.IsNullOrEmpty(tbProjectEndWeek.Text.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "实验周次不能为空!"); return; } int iStartWeek = 0; int iEndWeek = 0; if (!(int.TryParse(tbProjectStartWeek.Text.Trim(), out iStartWeek) && int.TryParse(tbProjectEndWeek.Text.Trim(), out iEndWeek))) { LabMS.Common.JShelper.JSAlert(Page, "err", "实验周次只能输入数字!"); return; } if (iStartWeek > iEndWeek) { LabMS.Common.JShelper.JSAlert(Page, "err", "实验周次开始时间大于结束时间!"); return; } if (iStartWeek > 20 || iEndWeek > 20) { LabMS.Common.JShelper.JSAlert(Page, "err", "实验周次过大!"); return; } if (string.IsNullOrEmpty(tbTeacherCode.Value.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "指导老师不能为空!"); return; } if (string.IsNullOrEmpty(tb_StudentIDs.Value.Trim())) { LabMS.Common.JShelper.JSAlert(Page, "err", "实验学生不能为空!"); return; } #endregion moproject.OP_ProjectName = tbProjectName.Text.Trim(); moproject.OP_ProjectCode = tbProjectCode.Text.Trim(); moproject.Project_Category = ddlProjectCategory.SelectedValue; moproject.Project_EndWeek = iEndWeek; moproject.Project_Lab = ddlLabName.SelectedValue; moproject.Project_PartnerType = ddlProjectPartnerType.SelectedValue; moproject.Project_Require = ddlProjectRequire.SelectedValue; moproject.Project_StartWeek = iStartWeek; moproject.Project_Subject = tbProjectSubjectCode.Value; moproject.Project_Type = ddlProjectType.SelectedValue; moproject.OP_AppIntro = tbOPReason.Text.Trim(); moproject.OP_ProSource = ddlProjectComFrom.SelectedValue; moproject.OP_Professioanl = tbOPProfessioanl.Text.Trim(); moproject.OP_PlanningCourseTime = tbOPPlanningCourseTime.Text.Trim(); moproject.OP_Phone = tbOPPhone.Text.Trim(); moproject.OP_InCharge = tbOPInCharge.Text.Trim(); moproject.OP_Grade = ddlOPGrade.SelectedValue; moproject.OP_AppIntro = tbOPContent.Text.Trim(); moproject.OP_Teacher = tbTeacherCode.Value.Trim(); moproject.OP_OpenType = tbOPContent.Text.Trim();//实验内容 LabMS.Model.SysSetting msys = new LabMS.Model.SysSetting(); ExtendBLL.SysSetting extendsys = new ExtendBLL.SysSetting(); msys = extendsys.GetCurrentSetting(); moproject.SYear = msys.CurrentYear; moproject.Semester = msys.CurrentSemester; string strAlertContent = "保存成功!"; moproject.OP_Audit = "0"; if (((Button)sender).ID == "btnApp") { strAlertContent = "申请成功!"; moproject.OP_Audit = "1"; } moproject.OP_AppTime = DateTime.Now; moproject.OP_Applicant = lbAppPerson.Text; int iOpenProjectID = 0; try { bopproject.Update(moproject); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; return; } String[] listsID = tb_StudentIDs.Value.Split(','); LabMS.Model.ProjectAppointment projectapp = new LabMS.Model.ProjectAppointment(); ExtendBLL.ProjectAppointment bprojectapp = new ExtendBLL.ProjectAppointment(); bprojectapp.Del(" where OP_ProjectCode ='" + moproject.OP_ProjectCode + "'"); for (int i = 0; i < listsID.Length; ++i) { projectapp.Appoint_ClassID = "0"; projectapp.Appoint_ProID = 0; projectapp.OP_Appoint_ID = listsID[i].ToString(); projectapp.OP_ProjectCode = moproject.OP_ProjectCode; projectapp.OP_Score = ""; try { bprojectapp.Add(projectapp); } catch (Exception ex) { lbErr.Visible = true; lbErr.Text = ex.Message; bprojectapp.Del(" where OP_ProjectCode ='" + moproject.OP_ProjectCode + "'"); return; } } AttachmentItemSave(moproject); Common.JShelper.JSAlertAndRedirect(Page, "success", strAlertContent, "currentopenprojectlist.aspx"); }
protected bool AttachmentItemSave(LabMS.Model.OpentProject openprojectmodel) { if (openprojectmodel != null) { int Attach_ID = 0; if (openprojectmodel.Attachment != null) { Attach_ID = openprojectmodel.Attachment.Value; string[] array = itemIDs.Value.Split(','); if (array[0] != "") { for (int n = 0; n < array.Length; n++) { if (array[n] != "0") { LabMS.BLL.AttachmentItem Attach = new LabMS.BLL.AttachmentItem(); int itemID = 0; if (int.TryParse(array[n], out itemID)) { try { Attach.Delete(itemID); } catch { } } } } } } else { ///有上传文件 if (HttpContext.Current.Request.Files.Count - 1 > 0) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attamentmodel = new LabMS.Model.Attachment(); LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); try { Attach_ID = Attach.Add(attamentmodel); openprojectmodel.Attachment = Attach_ID; OpenProject.Update(openprojectmodel); } catch { lb_Error.Text = "保存上传文件错误"; } } } if (Attach_ID != 0) { return SaveItem(Attach_ID); } else { return false; } } return false; }
protected void Gv_File_DataBind() { if (!string.IsNullOrEmpty(Request.QueryString["ID"])) { if (IsNumber(Request.QueryString["ID"].Trim())) { int num=0; if (int.TryParse(Request.QueryString["ID"].Trim(), out num)) { LabMS.BLL.AttachmentItem AttachmentItem = new LabMS.BLL.AttachmentItem(); List<LabMS.Model.AttachmentItem> ls = new List<LabMS.Model.AttachmentItem>(); LabMS.Model.OpentProject openprojectmodel = new LabMS.Model.OpentProject(); LabMS.BLL.OpentProject OpenProject = new LabMS.BLL.OpentProject(); openprojectmodel= OpenProject.GetModel(num); if (openprojectmodel != null) { if (openprojectmodel.Attachment != null) { ls = AttachmentItem.GetModelList("Attach_ID=" + openprojectmodel.Attachment); } } Gv_File.DataSource = ls; Gv_File.DataBind(); } } } }