/// <summary> /// 此课堂能否预约。 /// </summary> /// <param name="arrange"></param> /// <param name="student"></param> /// <returns></returns> protected bool CanBeBooked(PackageArrange arrange, StudentInfo student) { if (student == null || arrange == null || arrange.Capacity <= arrange.PackageBookInfo.Count || IsBooked(student, arrange.CoursePackage)) { return(false); } else { return(true); } }
protected void Page_Load(object sender, EventArgs e) { //修改安排。 if (Request.QueryString["packageId"].isNullorWhiteSpace()) { Arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]); Package = Arrange.CoursePackage; } //添加新安排。 else { Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["packageId"]); } if (Request.HttpMethod == "POST") { if (Arrange == null) { Arrange = new PackageArrange { CoursePackage = Package }; LabDB.PackageArrange.InsertOnSubmit(Arrange); } //收集安排信息。 Arrange.CustomTime = Request.Form["CustomTime"]; try { Arrange.Capacity = Int32.Parse(Request.Form["Capacity"]);//Int32的Parse方法可能会抛出错误。 LabDB.SubmitChanges(); } catch { } Response.Redirect("PackageArrangeManage.aspx?packageId="+Package.Id); } }
protected void Page_Load(object sender, EventArgs e) { //修改安排。 if (Request.QueryString["packageId"].isNullorWhiteSpace()) { Arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]); Package = Arrange.CoursePackage; } //添加新安排。 else { Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["packageId"]); } if (Request.HttpMethod == "POST") { if (Arrange == null) { Arrange = new PackageArrange { CoursePackage = Package }; LabDB.PackageArrange.InsertOnSubmit(Arrange); } //收集安排信息。 Arrange.CustomTime = Request.Form["CustomTime"]; try { Arrange.Capacity = Int32.Parse(Request.Form["Capacity"]);//Int32的Parse方法可能会抛出错误。 LabDB.SubmitChanges(); } catch { } Response.Redirect("PackageArrangeManage.aspx?packageId=" + Package.Id); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; PackageArrange arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == context.Request["arrangeId"]); LabDB.PackageArrange.DeleteOnSubmit(arrange); try { LabDB.SubmitChanges(); LabDB.Connection.Close(); } catch (Exception ex) { //删除失败返回错误信息。 context.Response.Write(ex.Message); return; } //删除成功返回1。 context.Response.Write("1"); }