public static int Create(String MatchID, String Statu, String UserID, String Date) { #region 检查输入的合法性 if (string.IsNullOrEmpty(Statu)) { return(0); } int matchid, userid; DateTime date; try { matchid = Convert.ToInt32(MatchID); userid = Convert.ToInt32(UserID); date = Convert.ToDateTime(Date); } catch { return(0); } #endregion #region 把数据组装成一个对象 Models.DB.CupProjectModel model = new Models.DB.CupProjectModel(); model.MatchID = matchid; model.UserID = userid; model.Statu = Statu; model.DeclarationDate = date; #endregion return(DAL.Create.CreateOneReturnID(model)); }
protected void Page_Load(object sender, EventArgs e) { accessControl(); if (String.IsNullOrEmpty(Request["ProjectID"]) || String.IsNullOrEmpty(Request["MID"])) { Response.Redirect("Default.aspx"); } ProjectID = Request["ProjectID"].ToString(); MatchID = Request["MID"].ToString(); Match = BLL.Match.SelectOne(Convert.ToInt32(MatchID)); Projects = BLL.CupProjectModel.FindByInt(ProjectID, "ID"); if (Projects.Count > 0) { Project = Projects[0]; } else { Project = new Models.DB.CupProjectModel(); } Declarant = BLL.CupDeclarantInfo.SelectOneByProjectID(ProjectID); TeamMember = BLL.CupTeamMemberInfo.SelectByProjectId(ProjectID); Recommender = BLL.RecommendInfo.SelectByProjectId(ProjectID); Student = BLL.StudentInfoModel.SelectOneByUserId(Project.UserID.ToString()); if (Project.Category == "自然科学类学术论文") { WorkInfoList = BLL.CupWorksInfo.FindByInt(ProjectID, "ProjectID"); if (WorkInfoList.Count > 0) { WorkInfo = WorkInfoList[0]; } else { WorkInfo = new Models.DB.CupWorksInfo(); } } else if (Project.Category == "哲学社会科学类社会调查报告和学术论文") { SurveyInfoList = BLL.CupWorksSurvey.FindByInt(ProjectID, "ProjectID"); if (SurveyInfoList.Count > 0) { SurveyInfo = SurveyInfoList[0]; } else { SurveyInfo = new Models.DB.CupWorksSurvey(); } } else if (Project.Category == "科技发明制作") { InventionInfoList = BLL.CupWorksInvention.FindByInt(ProjectID, "ProjectID"); if (InventionInfoList.Count > 0) { InventionInfo = InventionInfoList[0]; } else { InventionInfo = new Models.DB.CupWorksInvention(); } } }
public static List <Models.DB.CupProjectModel> SelectOnePage(int page_size, int current_page, string order_field, string order_value) { DataTable dt = DAL.Select.GetSome("Tb_CupProjectModel", page_size, current_page, order_field, order_value); List <Models.DB.CupProjectModel> list = new List <Models.DB.CupProjectModel>(); for (int i = 0; i < dt.Rows.Count; ++i) { Models.DB.CupProjectModel e = new Models.DB.CupProjectModel(); e.ID = Convert.ToInt32(dt.Rows[i]["ID"]); e.MatchID = Convert.ToInt32(dt.Rows[i]["MatchID"]); e.DeclarationType = dt.Rows[i]["DeclarationType"].ToString(); e.Category = dt.Rows[i]["Category"].ToString(); e.PaperDoc = dt.Rows[i]["PaperDoc"].ToString(); e.Material = dt.Rows[i]["Material"].ToString(); e.DeclarationDate = Convert.ToDateTime(dt.Rows[i]["DeclarationDate"]); e.ProjectPic = dt.Rows[i]["ProjectPic"].ToString(); e.ProjectVideo = dt.Rows[i]["ProjectVideo"].ToString(); e.Remark = dt.Rows[i]["Remark"].ToString(); e.PdfUrl = dt.Rows[i]["PdfUrl"].ToString(); e.Statu = dt.Rows[i]["Statu"].ToString(); e.UserID = Convert.ToInt32(dt.Rows[i]["UserID"]); e.Name = dt.Rows[i]["Name"].ToString(); list.Add(e); } return(list); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; Models.DB.CupProjectModel Project = new Models.DB.CupProjectModel(); // 上传文件 HttpPostedFile fileData = context.Request.Files["Filedata"]; //Filedata是定死的 if (fileData != null) { string result = null; try { //TODO通过Session获取id:"../upload/Material/"+Session["id"].ToString() if (context.Session["user"] == null) { context.Response.Redirect("~/Web/Login/Default.aspx"); } if (context.Session["ProjectType"] == null || context.Session["ProjectID"] == null) { context.Response.Redirect("~/Web/CupInfoCreate/UploadPaper.aspx"); } String UserID = context.Session["user"].ToString(); String ProjectType = context.Session["ProjectType"].ToString(); String ProjectID = context.Session["ProjectID"].ToString(); if (ProjectType == "CupProjectModel") { Project = BLL.CupProjectModel.FindByInt(ProjectID, "ID")[0]; } else { } String MatchName = BLL.Match.SelectOne(Project.MatchID).MatchName; string fileExt = Path.GetExtension(fileData.FileName); string fileName = Project.ID + fileExt; string dir = context.Server.MapPath("~/Web/upload/Material/" + MatchName + "/PaperDoc"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileData.SaveAs(Path.Combine(dir, fileName)); result = "~/Web/upload/Material/" + MatchName + "/PaperDoc/" + fileName; } catch { result = null; } context.Response.Write(result); context.Response.End(); } context.Response.End(); }
/// <summary> /// 根据MatchId查询一页数据 /// </summary> /// <param name="current_page"></param> /// <param name="page_size"></param> /// <param name="MatchId"></param> /// <returns></returns> public static List <Models.DB.CupProjectModel> SelectOnePage(int current_page, int page_size, string MatchId) { List <Models.DB.CupProjectModel> Projects = new List <Models.DB.CupProjectModel>(); int matchId = 0; if (string.IsNullOrEmpty(MatchId)) { return(Projects); } try { matchId = Convert.ToInt32(MatchId); } catch { return(Projects); } Models.DB.CupProjectModel Project = new Models.DB.CupProjectModel(); Project.MatchID = matchId; Project.Statu = "提交"; string[] targets = { "MatchID", "Statu" }; System.Data.DataTable dt = DAL.Select.GetSome(Project, targets, page_size, current_page, "UserID", "asc"); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Project = new Models.DB.CupProjectModel(); Project.ID = Convert.ToInt32(dt.Rows[i]["ID"]); Project.MatchID = Convert.ToInt32(dt.Rows[i]["MatchID"]); Project.DeclarationType = dt.Rows[i]["DeclarationType"].ToString(); Project.Category = dt.Rows[i]["Category"].ToString(); Project.PaperDoc = dt.Rows[i]["PaperDoc"].ToString(); Project.Material = dt.Rows[i]["Material"].ToString(); Project.DeclarationDate = Convert.ToDateTime(dt.Rows[i]["DeclarationDate"]); Project.ProjectPic = dt.Rows[i]["ProjectPic"].ToString(); Project.ProjectVideo = dt.Rows[i]["ProjectVideo"].ToString(); Project.Remark = dt.Rows[i]["Remark"].ToString(); Project.PdfUrl = dt.Rows[i]["PdfUrl"].ToString(); Project.Statu = dt.Rows[i]["Statu"].ToString(); Project.UserID = Convert.ToInt32(dt.Rows[i]["UserID"]); Project.Name = dt.Rows[i]["Name"].ToString(); Projects.Add(Project); } } return(Projects); }
/// <summary> /// 更新PdfUrl /// </summary> /// <param name="Project"></param> /// <param name="FileOne"></param> public static int UpdataPdfUrl(string ProjectID, string Url) { if (string.IsNullOrEmpty(ProjectID) || string.IsNullOrEmpty(Url)) { return(0); } List <Models.DB.CupProjectModel> Projects = FindByInt(ProjectID, "ID"); if (Projects.Count > 0) { Models.DB.CupProjectModel Project = Projects[0]; Project.PdfUrl = Url; return(DAL.Update.ChangeSome(Project, "ID")); } return(0); }
/// <summary> /// 根据比赛统计数据 /// </summary> /// <param name="MatchId"></param> /// <returns></returns> public static double CountByMatchId(string MatchId) { int matchId = 0; if (string.IsNullOrEmpty(MatchId)) { return(0); } try { matchId = Convert.ToInt32(MatchId); } catch { return(0); } Models.DB.CupProjectModel Project = new Models.DB.CupProjectModel(); Project.MatchID = matchId; return(DAL.Select.GetCount(Project, "MatchID")); }
/// <summary> /// 单一条件查询Int型 /// </summary> /// <param name="Value"></param> /// <param name="ValueName"></param> /// <returns></returns> public static List <Models.DB.CupProjectModel> FindByInt(String Value, String ValueName) { #region 输入合法性检查 int valueInt; try { valueInt = Convert.ToInt32(Value); } catch { return(null); } #endregion List <Models.DB.CupProjectModel> list = new List <Models.DB.CupProjectModel>(); DataTable dt = DAL.Select.QueryOne(valueInt, "Tb_CupProjectModel", ValueName); for (int i = 0; i < dt.Rows.Count; ++i) { Models.DB.CupProjectModel e = new Models.DB.CupProjectModel(); e.ID = Convert.ToInt32(dt.Rows[i]["ID"]); e.MatchID = Convert.ToInt32(dt.Rows[i]["MatchID"]); e.DeclarationType = dt.Rows[i]["DeclarationType"].ToString(); e.Category = dt.Rows[i]["Category"].ToString(); e.PaperDoc = dt.Rows[i]["PaperDoc"].ToString(); e.Material = dt.Rows[i]["Material"].ToString(); e.DeclarationDate = Convert.ToDateTime(dt.Rows[i]["DeclarationDate"]); e.ProjectPic = dt.Rows[i]["ProjectPic"].ToString(); e.ProjectVideo = dt.Rows[i]["ProjectVideo"].ToString(); e.Remark = dt.Rows[i]["Remark"].ToString(); e.PdfUrl = dt.Rows[i]["PdfUrl"].ToString(); e.Statu = dt.Rows[i]["Statu"].ToString(); e.UserID = Convert.ToInt32(dt.Rows[i]["UserID"]); e.Name = dt.Rows[i]["Name"].ToString(); list.Add(e); } return(list); }
public static int Updata(String ProjectID, String ProjectName, String DeclarationType, String Category, String DeclarationDate, String MatchID, String UserID) { #region 输入合法性检测 if (string.IsNullOrEmpty(Category) || string.IsNullOrEmpty(DeclarationType) || string.IsNullOrEmpty(ProjectName)) { return(0); } DateTime date; int matchid; int userid; try { date = Convert.ToDateTime(DeclarationDate); matchid = Convert.ToInt32(MatchID); userid = Convert.ToInt32(UserID); } catch { return(0); } #endregion #region 把数据组装成一个对象 Models.DB.CupProjectModel model = new Models.DB.CupProjectModel(); model.Name = ProjectName; model.DeclarationType = DeclarationType; model.Category = Category; model.DeclarationDate = date; model.UserID = userid; model.MatchID = matchid; model.ID = Convert.ToInt32(ProjectID); if (model.Name == null) { model.Name = "未填写作品名称"; } return(DAL.Update.ChangeSome(model, "ID")); #endregion }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(Request["MatchID"]) || String.IsNullOrEmpty(Request["Index"]) || String.IsNullOrEmpty(Request["currentPage"])) { Response.Redirect("../Project/Default.aspx?MatchID=" + MatchID); } currentPage = 1; try { currentPage = Convert.ToInt32(Request["currentPage"]); index = Convert.ToInt32(Request["Index"]); } catch { Response.Redirect("../Project/Default.aspx?MatchID=" + MatchID); } MatchID = Request["MatchID"]; Match = BLL.Match.SelectOne(Convert.ToInt32(MatchID)); /*************根据模型*************************/ if (Match.MatchModel == 1) { Projects = BLL.CupProjectModel.FindByInt(MatchID, "MatchID"); for (int i = 0; i < Projects.Count; i++) { CheckRecrod = BLL.CheckRecord.FindOne(Projects[i].ID.ToString(), Match.MatchModel.ToString()); if (CheckRecrod == null || CheckRecrod.AfterStatus != "初审通过") { Projects.RemoveAt(i); i--; continue; } } ProjectCount = Projects.Count; try{ Project = Projects[Math.Max((currentPage - 1) * 10, 0) + (index - 1)]; } catch { Project = new Models.DB.CupProjectModel(); } ProjectID = Project.ID.ToString(); if (Project.PdfUrl != "") { String swf = Project.PdfUrl.Substring(0, Project.PdfUrl.LastIndexOf('.')); if (Utility.PDF2Swf.DoPDF2Swf(Server.MapPath(Project.PdfUrl), Server.MapPath(swf + ".swf"))) { FilePath = ResolveUrl(swf + ".swf"); showPdf = true; } else { Response.Write("<script language=\"javascript\" type=\"text/javascript\">"); Response.Write("alert(\"无法找到源文件\");"); Response.Write("</script>"); showPdf = false; // Response.Redirect("../Project/Default.aspx"); } } else { showPdf = false; } } else if (Match.MatchModel == 2) { Innovations = BLL.InnovationProjectModel.FindByInt(MatchID, "MatchID"); for (int i = 0; i < Innovations.Count; i++) { CheckRecrod = BLL.CheckRecord.FindOne(Innovations[i].Id.ToString(), Match.MatchModel.ToString()); if (CheckRecrod == null || CheckRecrod.AfterStatus != "初审通过") { Innovations.RemoveAt(i); i--; continue; } } ProjectCount = Innovations.Count; try { Innovation = Innovations[Math.Max((currentPage - 1) * 10, 0) + (index - 1)]; } catch { Innovation = new Models.DB.InnovationProjectModel(); } ProjectID = Innovation.Id.ToString(); if (Innovation.PdfUrl != "") { String swf = Innovation.ProjectDoc.Substring(0, Innovation.ProjectDoc.LastIndexOf('.')); if (Utility.PDF2Swf.DoPDF2Swf(Server.MapPath(Innovation.ProjectDoc), Server.MapPath(swf + ".swf"))) { FilePath = ResolveUrl(swf + ".swf"); showPdf = true; } else { Response.Write("<script language=\"javascript\" type=\"text/javascript\">"); Response.Write("alert(\"无法找到源文件\");"); Response.Write("</script>"); showPdf = false; // Response.Redirect("../Project/Default.aspx"); } } else { showPdf = false; } } /**************************************/ if (Session["user"] == null) { Response.Redirect(ResolveUrl("~/Web/Login/Default.aspx")); } UserID = Session["user"].ToString(); JudgeList = BLL.JudgeInfoModel.FindByInt(UserID, "UserID"); if (JudgeList.Count > 0) { Judge = JudgeList[0]; } else { Judge = new Models.DB.JudgeInfoModel(); } Score = BLL.ProjectScore.FindOne(ProjectID, Match.MatchModel.ToString(), Judge.Id.ToString()); if (Score == null) { HasRecord = false; Score = new Models.DB.ProjectScore(); } else { HasRecord = true; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string dowhat = context.Request["dowhat"]; if (dowhat == null) { dowhat = ""; } #region 确认提交 if (dowhat == "SubmitProject") { String type = context.Request["Type"].ToString(); String ProjectID = context.Request["ProjectID"].ToString(); if (type == "CupProjectModel") { Models.DB.CupProjectModel Project = BLL.CupProjectModel.FindByInt(ProjectID, "ID")[0]; Models.DB.Match Match = BLL.Match.SelectOne(Convert.ToInt32(Project.MatchID)); if (Match == null) { return; } else if (System.DateTime.Compare(System.DateTime.Now, Match.DeclarantDeadLine) > 0) { context.Response.Write("deadline"); context.Response.End(); return; } if (Project.Statu == "提交") { context.Response.Write("Submited"); context.Response.End(); return; } if (BLL.CupProjectModel.UpdateStatus("提交", ProjectID) > 0) { context.Response.Write("success"); } else { context.Response.Write("failed"); } context.Response.End(); return; } else if (type == "InnovationProjectModel") { Models.DB.InnovationProjectModel Project = BLL.InnovationProjectModel.FindByInt(ProjectID, "Id")[0]; Models.DB.Match Match = BLL.Match.SelectOne(Convert.ToInt32(Project.MatchID)); if (Match == null) { return; } else if (System.DateTime.Compare(System.DateTime.Now, Match.DeclarantDeadLine) > 0) { context.Response.Write("deadline"); context.Response.End(); return; } if (Project.Statu == "提交") { context.Response.Write("Submited"); context.Response.End(); return; } if (BLL.InnovationProjectModel.UpdateStatus("提交", ProjectID) > 0) { context.Response.Write("success"); } else { context.Response.Write("failed"); } context.Response.End(); return; } } #endregion #region 除项目 if (dowhat == "DeleteProject") { String type = context.Request["Type"].ToString(); String ProjectID = context.Request["ProjectID"].ToString(); if (type == "CupProjectModel") { Models.DB.CupProjectModel Project = BLL.CupProjectModel.FindByInt(ProjectID, "ID")[0]; if (Project.Statu == "提交") { context.Response.Write("Submited"); context.Response.End(); return; } if (BLL.Delete.Word("Tb_CupProjectModel", ProjectID) > 0) { BLL.Delete.WordList(ProjectID, "Tb_CupProjectModel"); context.Response.Write("success"); } else { context.Response.Write("failed"); } context.Response.End(); return; } else if (type == "InnovationProjectModel") { Models.DB.InnovationProjectModel Project = BLL.InnovationProjectModel.FindByInt(ProjectID, "Id")[0]; if (Project.Statu == "提交") { context.Response.Write("Submited"); context.Response.End(); return; } if (BLL.Delete.Word("Tb_InnovationProjectModel", ProjectID) > 0) { BLL.Delete.WordList(ProjectID, "Tb_InnovationProjectModel"); context.Response.Write("success"); } else { context.Response.Write("failed"); } context.Response.End(); return; } } #endregion }