public IHttpActionResult GetById(string id) { if (string.IsNullOrEmpty(id) || !Guid.TryParse(id, out var _)) { return(BadRequest()); } try { Course result = _manageservice.GetById(id); return(result == null?NotFound() : (IHttpActionResult)Ok(result)); } catch (InvalidOperationException ex) { return(InternalServerError(ex)); } catch (AccessViolationException) { try { CourseInfo result = _manageservice.GetCourseInfo(id); return(result == null?NotFound() : (IHttpActionResult)Ok(result)); } } }
private static List <int> GetHandicapAdjustments(CourseInfo courseInfo, int golferHandicap) { List <int> retVal = new List <int>(); for (int i = 0; i < 9; i++) { retVal.Add(0); } Dictionary <int, int> holeToHandicaptoIndex = new Dictionary <int, int>(); for (int i = 0; i < 9; i++) { holeToHandicaptoIndex.Add(courseInfo.holeHandicaps[i], i); } List <int> holeHandicapList = holeToHandicaptoIndex.Keys.ToList(); holeHandicapList.Sort(); //holeHandicapList.Reverse(); if (golferHandicap > 0) { for (int i = 0; i < golferHandicap; i++) { int holeToAddStrokeTo = holeToHandicaptoIndex[holeHandicapList[i % 9]]; retVal[holeToAddStrokeTo] += 1; } } return(retVal); }
protected void BindRelation(ProductInfo product) { ProductSearchInfo info2; if (product.RelationArticle != string.Empty) { ArticleSearchInfo articleSearch = new ArticleSearchInfo(); articleSearch.InArticleID = product.RelationArticle; this.Article.DataSource = ArticleBLL.SearchArticleList(articleSearch); this.Article.DataTextField = "Title"; this.Article.DataValueField = "ID"; this.Article.DataBind(); } if (product.RelationProduct != string.Empty) { info2 = new ProductSearchInfo(); info2.InProductID = product.RelationProduct; this.Product.DataSource = ProductBLL.SearchProductList(info2); this.Product.DataTextField = "Name"; this.Product.DataValueField = "ID"; this.Product.DataBind(); } if (product.Accessory != string.Empty) { CourseInfo courseSearch = new CourseInfo(); courseSearch.Condition = product.Accessory; courseSearch.Field = "CourseId"; this.Accessory.DataSource = CourseBLL.ReadList(courseSearch); this.Accessory.DataTextField = "CourseName"; this.Accessory.DataValueField = "CourseId"; this.Accessory.DataBind(); } }
public bool UpdateInfoAsync(CourseInfo model) { using (var conn = DapperFactory.GetConnection()) { var fields = model.ToFields(removeFields: new List <string> { "CreateTime" }); if (fields == null || fields.Count == 0) { return(false); } var fieldList = new List <string>(); foreach (var field in fields) { fieldList.Add(string.Format("{0}=@{0}", field)); } model.ModifyTime = DateTime.Now; string sql = string.Format("update [CourseInfo] set {0};", string.Join(",", fieldList)); return(conn.Execute(sql, model) > 0); } }
public CourseAndClassList(CourseInfo courseInfo, CourseClass courseClass, String courseName) { this.courseInfo = courseInfo; courseClasses = new List <CourseClass>(); this.courseClasses.Add(courseClass); this.courseName = courseName; }
public JsonResult CourseInfoByDeptId(int id) { var course = db.Courses.Where(x => x.DepartmentId == id).ToList(); List <CourseInfo> courses = new List <CourseInfo>(); foreach (var aCourse in course) { CourseInfo courseInfo = new CourseInfo(); courseInfo.CourseCode = aCourse.CourseCode; courseInfo.CourseName = aCourse.CourseName; var sem = db.Semesters.FirstOrDefault(x => x.SemesterId == aCourse.SemesterId); courseInfo.SemesterName = sem.SemesterName; var assignedToInfo = db.AssignedCourses.FirstOrDefault(x => x.CourseId == aCourse.CourseId); if (assignedToInfo != null) { Teacher assignedTo = db.Teachers.FirstOrDefault(x => x.TeacherId == assignedToInfo.TeacherId); courseInfo.AssignedTo = assignedTo.TeacherName; } else { courseInfo.AssignedTo = "Not Assigned Yet"; } courses.Add(courseInfo); } return(Json(courses)); }
/// <summary> /// 返回指定CateId下的课程数 /// </summary> /// <param name="CateId"></param> /// <returns></returns> public static int ReadCourseNumByCateID(int cateID) { CourseInfo Model = new CourseInfo(); Model.CateId = cateID; return(ReadList(Model).Count); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var UserProfile = from ur in db.Users join pr in db.Profiles on ur.UserID equals pr.UserID where ur.UserID == id select new UserView { UserID = ur.UserID, UserName = ur.UserName, Email = ur.Email, Password = ur.Password, Admin = ur.Admin, Photo = pr.Photo, Handicap = pr.Handicap, HomeClubID = pr.HomeClubID }; UserView uView = new UserView(); foreach (var item in UserProfile) { uView = item; } // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.HomeClubID = courseInfo.GetCourseList(); if (UserProfile == null) { return(HttpNotFound()); } return(View(uView)); }
public async Task <IActionResult> Edit(int id, [Bind("CourseID,CourseName")] CourseInfo courseInfo) { if (id != courseInfo.CourseID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(courseInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CourseInfoExists(courseInfo.CourseID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(courseInfo)); }
public Task <EditProfile> GetEditProfile(int UserID) { return(Task.Run(() => { using (MIUEntities db = new MIUEntities()) { try { User data = db.Users.Where(x => x.IsDelete != true && x.ID == UserID).SingleOrDefault(); EditProfile info = new EditProfile(); BatchInfo batchInfo = new BatchInfo(); CourseInfo courseInfo = new CourseInfo(); if (data != null) { PropertyCopier <User, EditProfile> .Copy(data, info); if (data.DOB != null) { info.DOB = data.DOB.Value.Date; } if (!string.IsNullOrEmpty(data.ProfilePicture)) { info.FileName = MIUFileServer.GetFileUrl("ProfileImages", data.ProfilePicture); } } ; return info; } catch (Exception) { return null; } } })); }
protected void AddTA_Button_Click(object sender, EventArgs e) { if (Session["UserInfo"] != null) { System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$"); if (!rex.IsMatch(TAID.Text.Trim()) || int.Parse(TAID.Text.Trim()) <= 9999) { ScriptManager.RegisterStartupScript(Page, GetType(), "errortype", "alert('输入ID格式错误!');", true); //HttpContext.Current.Response.Write("<script type='text/javascript'>alert('输入ID格式错误!');location.href='" + Request.Url.AbsoluteUri + "'</script>"); } else { CourseInfo c = new CourseInfo(); c.CourseID = course.CourseID; c.UserID = int.Parse(TAID.Text.Trim()); if (1 == c.SelectCourseAssistant()) { AllDataBind(); } else { ScriptManager.RegisterStartupScript(Page, GetType(), "addfailed", "alert('添加失败');", true); } } } else { HttpContext.Current.Response.Write("<script type='text/javascript'>alert('闲置时间过长,请重新登录');location.href='" + Request.Url.AbsoluteUri + "'</script>"); } }
// This method will check if a course exists, returning true if it does. // This method makes a series of HTTP requests to gain authorization, then attempts to find the input course. public async Task <bool> CheckCourseExists(CourseInfo course) { HttpRequestMessage request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Get, Constants.WebAdvisorInitialConnectionUrl); HttpResponseMessage response = await httpClient.SendAsync(request); string token = requestsHelper.GetTokenFromResponse(response); request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Get, Constants.WebAdvisorInitialConnectionUrl + token); response = await httpClient.SendAsync(request); token = requestsHelper.GetTokenFromResponse(response); string postUrl = requestsHelper.CreatePostUrl(token); request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Post, postUrl); request.Content = requestsHelper.CreateFormData(course); response = await httpClient.SendAsync(request); string responseHtml = await response.Content.ReadAsStringAsync(); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(responseHtml); HtmlNode mainContentNode = htmlDoc.GetElementbyId("main"); HtmlNodeCollection errorNodes = mainContentNode.SelectNodes("//div[contains(@class, 'errorText')]"); if (errorNodes != null && errorNodes.Any()) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { int queryString = RequestHelper.GetQueryString <int>("ID"); CourseCateInfo CourseCateModel = new CourseCateInfo(); CourseCateModel.Condition = systemCompanyId.ToString(); this.CateId.DataSource = CourseCateBLL.ReadCourseCateNamedList(CourseCateModel); this.CateId.DataTextField = "CateName"; this.CateId.DataValueField = "CateId"; this.CateId.DataBind(); this.CateId.Items.Insert(0, new ListItem("请选择类别", "-1")); if (queryString != int.MinValue) { base.CheckAdminPower("UpdateCourse", PowerCheckType.Single); CourseInfo CourseModel = CourseBLL.ReadCourse(queryString); //if (CompanyId.Items.Contains(CompanyId.Items.FindByValue(CourseModel.CompanyId.ToString()))) CompanyId.Items.FindByValue(CourseModel.CompanyId.ToString()).Selected = true; if (this.CateId.Items.Contains(this.CateId.Items.FindByValue(CourseModel.CateId.ToString()))) { this.CateId.Items.FindByValue(CourseModel.CateId.ToString()).Selected = true; } this.CourseName.Text = CourseModel.CourseName; //this.CourseCode.Text = CourseModel.CourseCode; this.OrderIndex.Text = CourseModel.OrderIndex.ToString(); } else { base.CheckAdminPower("AddCourse", PowerCheckType.Single); } } //Control control = FindControlById(this, "CompanyId1"); //if (control != null) ScriptHelper.Alert("找到了"); }
// This method will get the capacity of the input course. // This method makes a series of HTTP requests to gain authorization, then get the required course info. public async Task <CourseCapacity> GetCapacity(CourseInfo course) { try { HttpRequestMessage request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Get, Constants.WebAdvisorInitialConnectionUrl); HttpResponseMessage response = await httpClient.SendAsync(request); string token = requestsHelper.GetTokenFromResponse(response); request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Get, Constants.WebAdvisorInitialConnectionUrl + token); response = await httpClient.SendAsync(request); token = requestsHelper.GetTokenFromResponse(response); string postUrl = requestsHelper.CreatePostUrl(token); request = requestsHelper.CreateHttpRequestMessage(HttpMethod.Post, postUrl); request.Content = requestsHelper.CreateFormData(course); response = await httpClient.SendAsync(request); string responseHtml = await response.Content.ReadAsStringAsync(); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(responseHtml); HtmlNode capacityNode = htmlDoc.GetElementbyId(Constants.CapacityNodeID); CourseCapacity capacity = requestsHelper.GetCourseCapacity(capacityNode); return(capacity); } catch (Exception e) { logger.LogInformation($"An exception occured in GetCapacity request: {e.Message}"); throw; } }
/// <summary> /// Returns GetStudentAgeReport() data for a single course, plus the teacher and the list of registered students /// </summary> /// <param name="theCourseId">Course Id</param> /// <returns>Corresponding course information</returns> public CourseInfo GetCourseInfo(string theCourseId) { if (dbContext == null) { //Log the error return(null); } CourseInfo aCourseInfo = new CourseInfo(); //Find the course in the DB Course aCourse = dbContext.Courses.Find(theCourseId); if (!CourseExists(theCourseId)) { //Log the error return(null); } //Get the details from DbContext class. aCourseInfo.Id = aCourse.Id; aCourseInfo.MaxAge = aCourse.Students.Max(st => st.Age); aCourseInfo.MinAge = aCourse.Students.Min(st => st.Age); aCourseInfo.AvgAge = aCourse.Students.Average(st => st.Age); aCourseInfo.Teacher = aCourse.Lecturer; aCourseInfo.Current = aCourse.Students.Count; aCourseInfo.StudentCollection = aCourse.Students.ToList(); return(aCourseInfo); }
public List <CourseInfo> GetAllCourseInfoByDepartmentId(int departmentId) { string query = "SELECT * FROM CourseInfo WHERE CourseDepartmentId=@depId Order By CourseCode ASC"; SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@depId", departmentId); connection.Open(); reader = command.ExecuteReader(); List <CourseInfo> courseList = new List <CourseInfo>(); while (reader.Read()) { CourseInfo aCourse = new CourseInfo(); aCourse.CourseId = Convert.ToInt32(reader["CourseId"]); aCourse.CourseCode = (reader["CourseCode"]).ToString(); aCourse.CourseTitle = (reader["CourseName"]).ToString(); aCourse.Semester = (reader["SemesterName"]).ToString(); string type = reader["AssignType"].ToString(); if (type == "1") { aCourse.CourseTeacherName = (reader["TeacherName"]).ToString(); } else if (type != "1") { aCourse.CourseTeacherName = "Not Assigned Yet"; } courseList.Add(aCourse); } connection.Close(); return(courseList); }
public async Task <ValidationModel> Createcourse(CourseInfo courseInfo) { try { var validation = courseInfo.IsValid(); if (!validation.IsValid) { return new ValidationModel { IsValid = false, Message = validation.Message } } ; _courseUnitOfWork.CourseRepository.Add(courseInfo.Course); await _courseUnitOfWork.SaveChangesAsync(); return(new ValidationModel { IsValid = true, Message = $"{courseInfo.Course.Title} has been successfully created." }); } catch (Exception ex) { //Implement serilog for logging the error message throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { int id = RequestHelper.GetQueryString <int>("ID"); string Action = RequestHelper.GetQueryString <string>("Action"); if (Action == "Delete") { if (id != int.MinValue) { base.CheckAdminPower("DeleteCourse", PowerCheckType.Single); CourseBLL.DeleteCourse(id); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("Course"), id); } } base.CheckAdminPower("ReadCourse", PowerCheckType.Single); if (!IsPostBack) { //在此处加载搜索框的类别信息 CourseCateInfo CourseCateModel = new CourseCateInfo(); CourseCateModel.Condition = CompanyBLL.SystemCompanyId.ToString(); SearchCategory.DataSource = CourseCateBLL.ReadCourseCateNamedList(CourseCateModel); SearchCategory.DataTextField = "CateName"; SearchCategory.DataValueField = "CateId"; SearchCategory.DataBind(); SearchCategory.Items.Insert(0, new ListItem("可以指定类别", "-1")); CourseInfo Model = new CourseInfo(); Model.CourseName = RequestHelper.GetQueryString <string>("CourseName"); Model.CateIdCondition = RequestHelper.GetQueryString <string>("CateIdCondition"); Model.Condition = CompanyBLL.SystemCompanyId.ToString(); Model.Field = "CompanyId"; base.BindControl(CourseBLL.ReadList(Model, base.CurrentPage, base.PageSize, ref this.Count), this.RecordList, this.MyPager); } }
public ActionResult ShowUser(int UserID) { var UserProfile = (from ur in db.Users join pr in db.Profiles on ur.UserID equals pr.UserID where ur.UserID == UserID select new UserView { UserID = ur.UserID, UserName = ur.UserName, Email = ur.Email, Password = ur.Password, Admin = ur.Admin, Photo = pr.Photo, Handicap = pr.Handicap, HomeClubID = pr.HomeClubID }).SingleOrDefault(); // Get Club Names For Drop Down List var courseInfo = new CourseInfo(); ViewBag.HomeClubID = courseInfo.GetCourseList(); return(PartialView("_UserDetails", UserProfile)); }
public async Task <bool> UpdateCourse(CourseInfo chcourse) { Course dbcoursetwo = await _courseprDbContext.Course .Include(u => u.courseTime) .Where(m => m.courseId == chcourse.courseId) .FirstOrDefaultAsync(); var originalItem = dbcoursetwo.courseTime.SingleOrDefault(i => i.courseId == dbcoursetwo.id); //if(originalItem == null) //return false; dbcoursetwo.courseId = chcourse.courseId; originalItem.StartDate = chcourse.startDate; originalItem.EndDate = chcourse.endDate; originalItem.days = chcourse.days; originalItem.hours = chcourse.hours; dbcoursetwo.courseId = chcourse.courseId; // dbcoursetwo.teacherId = chcourse.courseId; dbcoursetwo.name = chcourse.courseName; dbcoursetwo.description = chcourse.description; dbcoursetwo.image = chcourse.image; return(await _courseprDbContext.SaveChangesAsync() > 0); }
protected void AddDropCourse_Button_Click(object sender, CommandEventArgs e) { if (Session["UserInfo"] != null) { CourseInfo course = new CourseInfo(); course.UserID = user.UserID; string[] arg = e.CommandArgument.ToString().Split(','); string courseid = arg[0]; string ischosen = arg[1]; course.CourseID = int.Parse(courseid); if (int.Parse(ischosen) == 0) { course.SelectCourse(); } if (int.Parse(ischosen) == 1) { course.DropCourse(); } allcourse = course.GetAllCourse(coursenum, coursename, teacher); AspNetPager.RecordCount = allcourse.Tables["AllCourse"].Rows.Count; CourseList_DataList.DataSource = FilterTable(allcourse.Tables["AllCourse"], AspNetPager.StartRecordIndex - 1, AspNetPager.EndRecordIndex - 1); CourseList_DataList.DataBind(); //Response.Redirect(Request.Url.AbsoluteUri); } else { HttpContext.Current.Response.Write("<script type='text/javascript'>alert('闲置时间过长,请重新登录');location.href='" + Request.Url.AbsoluteUri + "'</script>"); } }
/// <summary> /// 【学生管理】 /// </summary> /// <returns></returns> public ActionResult StudentManage() { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { TeacherInfo t1 = TeacherInfo.GetTeacherInfo(Session["UserNum"].ToString()); //获取教师发布的课程,并且通过管理员的验证的(State:待检验-----> 正常) string sql = "Select * from CourseInfo where TeacherNum = @TeacherNum and DelFlag = 0 and State = '正常' "; List <CourseInfo> list = CourseInfo.GetCourseInfoByTeacherNum(Session["UserNum"].ToString(), sql); ViewBag.Teacher = t1; ViewBag.CourseList = list; return(View()); } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
public async Task GetCapacity_Should_ReturnValidCapacity(CourseInfo course) { CourseCapacity capacity = await requests.GetCapacity(course); capacity.CurrentCapacity.Should().BeGreaterOrEqualTo(0); capacity.TotalCapacity.Should().BeGreaterThan(0); }
}// /// <summary> /// 插入课程信息或者修改课程信息 /// </summary> /// <param name="form">课程信息表单</param> /// <returns></returns> public ActionResult ExecuteInsertAndUpdateCourseInfo(FormCollection form) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { if (form["Action"] == "New") { CourseInfo c1 = FormToCourseInfo(form); if (c1.IsCheck) { if (CourseInfo.ExecuteInsertCourseInfo(c1) > 0) { return(Content("Success")); } else { return(Content("Error")); } } else { return(Content("Error")); } } else if (form["Action"] == "Save") { CourseInfo c1 = FormToCourseInfo(form); if (c1.IsCheck) { c1.CourseNum = form["CourseNum"]; if (CourseInfo.UpdateCourseInfo(c1) > 0) { return(Content("Success")); } else { return(Content("Error")); } } else { return(Content("Error")); } } else { return(Content("Error")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// Update course. /// </summary> /// <param name="course"></param> /// <returns></returns> public async Task <Result <CourseInfo> > UpdateAsync(CourseInfo course) { var courseDb = _courseRepository.GetByIdAsync(course.CourseId).GetAwaiter().GetResult(); if (courseDb == null) { return((Result <CourseInfo>)Result.Fail($"Invalid course. Course doesn't exist")); } courseDb.Name = course.Name; courseDb.Level = course.Level; courseDb.Raiting = course.Raiting; courseDb.Description = course.Description; courseDb.Price = course.Price; try { await _courseRepository.UpdateAsync(courseDb); return(Result <CourseInfo> .Ok(_mapper.Map <CourseInfo>(courseDb))); } catch (DbUpdateConcurrencyException e) { return((Result <CourseInfo>)Result.Fail($"Cannot update course. {e.Message}")); } catch (DbUpdateException e) { return((Result <CourseInfo>)Result.Fail($"Cannot update course. Duplicate field. {e.Message}")); } catch (DbEntityValidationException e) { return((Result <CourseInfo>)Result.Fail($"Invalid course. {e.Message}")); } }
/// <summary> /// 展示教师修改课程信息 /// </summary> /// <returns></returns> public ActionResult UpdateCourseInfo() { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { TeacherInfo t1 = TeacherInfo.GetTeacherInfo(Session["UserNum"].ToString()); string sql = "Select * from CourseInfo where TeacherNum = @TeacherNum and DelFlag = 0"; List <CourseInfo> list = CourseInfo.GetCourseInfoByTeacherNum(Session["UserNum"].ToString(), sql); ViewBag.Teacher = t1; ViewBag.CourseList = list; return(View()); } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
public static List <CourseInfo> ReadList(int cateID) { CourseInfo course = new CourseInfo(); course.CateId = cateID; return(ReadList(course)); }
/// <summary> /// 教师删除提交的课程信息 /// </summary> /// <param name="courseNum"></param> /// <returns></returns> public ActionResult DelCourseInfo(string courseNum) { if (Session["UserType"] != null && Session["UserType"].ToString() == "Teacher") { if (Session["UserNum"] != null) { if (courseNum != "") { //执行删除操作 if (CourseInfo.DelCourseInfoByCourseNum(courseNum, Session["UserNUm"].ToString()) > 0) { return(Content("Success")); } else { return(Content("Error")); } } else { return(Content("Error")); } } else { return(RedirectToAction("../Home/Login")); } } else { return(RedirectToAction("../Home/Login")); } }
/// <summary> /// 该数据访问对象的属性值装载到数据库更新参数数组 /// </summary> /// <remarks></remarks> protected IDbDataParameter[] ValueParas(CourseInfo Model) { SqlParameter[] par = { new SqlParameter("@CourseId", SqlDbType.VarChar, 50), new SqlParameter("@CourseName", SqlDbType.VarChar, 50), new SqlParameter("@CourseCode", SqlDbType.VarChar, 50), new SqlParameter("@CourseScore", SqlDbType.VarChar, 50), new SqlParameter("@CateId", SqlDbType.VarChar, 50), new SqlParameter("@OrderIndex", SqlDbType.VarChar, 50), new SqlParameter("@CreateDate", SqlDbType.VarChar, 50), new SqlParameter("@CompanyId", SqlDbType.VarChar, 50), new SqlParameter("@BrandId", SqlDbType.VarChar, 50) }; par[0].Value = Model.CourseId; par[1].Value = Model.CourseName; par[2].Value = Model.CourseCode; par[3].Value = Model.CourseScore; par[4].Value = Model.CateId; par[5].Value = Model.OrderIndex; par[6].Value = Model.CreateDate; par[7].Value = Model.CompanyId; par[8].Value = Model.BrandId; return(par); }
public void ConstructorWithCourseNameAndCreator_WhenCalled_SetPropertiesCorrectly() { _sut = new CourseInfo("course name", "creator name"); Assert.That(_sut.CourseName, Is.EqualTo("course name")); Assert.That(_sut.CreatorName, Is.EqualTo("creator name")); }
public List<CourseInfo> getTimetable(int sid) { int startyear = int.Parse(new StudentBusiness().getStuBySid(sid).Startyear.ToString()); int year = DateTime.Now.Year; int month = DateTime.Now.Month; int semester = (month >= 1 && month <= 6) ? 2 * (year - startyear) : 2 * (year - startyear) + 1; courseModelList = new CourseService().getAllCourseBySid(sid, semester); if (courseModelList != null) { foreach (CourseModel cModel in courseModelList) { tModel = new TeacherService().getTeacherByTid(cModel.Tid); pModel = new PlaceService().getPlacebyPid(cModel.Pid); precName = (new CourseService().getCoursebyCid(cModel.Precourse)).Cname; courseInfo = new CourseInfo(cModel, tModel, pModel, precName); courseInfoList.Add(courseInfo); } } return courseInfoList; }
private void CourseInfoInput_Click(object sender, EventArgs e) { CourseInfo objCourseInfo = new CourseInfo(); objCourseInfo.MdiParent = this; objCourseInfo.Show(); }
protected void Page_Load(object sender, EventArgs e) { if (Request.HttpMethod == "POST") { #region 检查输入是否完整且合法。 //实验名称。 if (Request.Form["Name"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('实验名称不能为空!');</script>"); return; } //学时。 if (Request.Form["ClassHour"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('学时不能为空!');</script>"); return; } //指导老师。 if (Request.Form["TeacherId"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('指导老师不能为空!');</script>"); return; } //实验简介。 if (Request.Form["Introduction"].isNullorWhiteSpace()) { Response.Write("<script type=\"text/javascript\"> alert('实验简介不能为空!');</script>"); return; } //照片。 if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0) { Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>"); return; } #endregion HttpPostedFile photo = Request.Files["Photo"]; string photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1]; try { CourseInfo course = new CourseInfo { Name = Request.Form["Name"].Trim(), Address = Request.Form["Address"].Trim(), ClassHour = Convert.ToInt16(Request.Form["ClassHour"]), TeacherInfo = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["TeacherId"]), Introduction = Request.Form["Introduction"].Trim(), ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["ExperimentId"]), PhotoUrl = "../Datas/Photos/Course/" + photoName, }; photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Course\\" + photoName); LabDB.CourseInfo.InsertOnSubmit(course); LabDB.SubmitChanges(); Response.Write("<script type=\"text/javascript\"> alert('操作成功!');</script>"); Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id="+Experiment.Id+"'</script>"); //return; //Response.Redirect("CourseManage.aspx", true); } catch { Response.Write("<script type=\"text/javascript\"> alert('操作失败!请检查输入!');</script>"); Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id=" + Experiment.Id + "'</script>"); // return; } } }
private void ProcessCourses(int FinishWaypoint) { DateTime StartAnalyzTime = DateTime.Now; int LastWaypoint = -1; int WaypointsSearchRange = DetectWPSearchRange(); for (int i = 0; i < Courses.Count; i++) { if ((DateTime.Now - StartAnalyzTime).TotalSeconds > 10) goto Output; LastWaypoint = Courses[i][Courses[i].Count - 1]; while (LastWaypoint != FinishWaypoint) { LastWaypoint = Courses[i][Courses[i].Count - 1]; List<WaypointsInfo> ClosestWaypoints = GetClosestWPList(LastWaypoint, i, WaypointsSearchRange, FinishWaypoint); for (int w = 0; w < ClosestWaypoints.Count; w++) if (w != 0) AddCoursesWithNewWaypoint(i, ClosestWaypoints[w].Index); if (ClosestWaypoints.Count >= 1) Courses[i].Add(ClosestWaypoints[0].Index); LastWaypoint = Courses[i][Courses[i].Count - 1]; if (ClosestWaypoints.Count == 0) { if (LastWaypoint != FinishWaypoint) { CourseInfo T = new CourseInfo(); T.Bad = true; T.BadTime = DateTime.Now; T.Index = i; if (CourseIsBad(i) == false) BadCourses.Add(T); Courses[i].Add(FinishWaypoint); LastWaypoint = Courses[i][Courses[i].Count - 1]; } } } } Output: CalculateCourses(); CalculatedCourses.Sort((a, b) => a.Range.CompareTo(b.Range)); List<String> OutData = new List<String>(); for (int i = 0; i < CalculatedCourses.Count; i++) { StringBuilder Sb = new StringBuilder(); for (int c = 0; c < Courses[CalculatedCourses[i].Index].Count; c++) { Sb.Append(Courses[CalculatedCourses[i].Index][c].ToString() + " "); } OutData.Add("Course lenght: " + CalculatedCourses[i].Range+"|"+ Sb.ToString()); } OutData.Add("Analiz time: " + ((DateTime.Now - StartAnalyzTime).TotalMilliseconds).ToString()); File.WriteAllLines("C:\\WPProcessTest.txt", OutData.ToArray()); return; }
public CourseInfo getCourseInfobyCid(int cid) { CourseModel cModel = new CourseService().getCoursebyCid(cid); TeacherModel tModel = new TeacherService().getTeacherByTid(cModel.Tid); PlaceModel pModel = new PlaceService().getPlacebyPid(cModel.Pid); string precName = (new CourseService().getCoursebyCid(cModel.Precourse)).Cname; CourseInfo courseInfo = new CourseInfo(cModel, tModel, pModel, precName); return courseInfo; }