示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";//

            string Name = context.Request.QueryString["Name"].ToString();
            int UniversityId = Convert.ToInt32(context.Request.QueryString["University"]);
            string Des = context.Request.QueryString["Des"].ToString();

            if (Name.Length >= 1 && UniversityId != 0)
            {
                try
                {
                    College college = new College();
                    college.Name = Name;
                    college.UniversityID = UniversityId;
                    college.Des = Des;
                    college.DateCreated = DateTime.Now;
                    college.Save();
                    context.Response.Write("{success:true,msg:'新增成功。',DateCreated:'" + DateTime.Now.ToShortDateString() + "',collegeId:'" + college.Id + "'}");
                }
                catch (Exception ex)
                {
                    context.Response.Write("{success:false,msg:'" + ex.Message + "'}");
                }
            }
            else
            {
                context.Response.Write("{success:false,msg:'新增失败,名称和学校为必填项。'}");
            }
        }
示例#2
0
 static void Main(string[] args)
 {
     Order[] od = new Order[]{
         new Order(001,"王一"),
         new Order(002,"赵三"),
         new Order(003,"王一"),
         new Order(004,"张甲"),
         new Order(005,"赵三")
     };
     Order[] od2 = new Order[]{
         new Order(006,"刘亦"),
         new Order(007,"钱一") 
     };
     College[] cg = new College[]{
         new College(01,"电子"),
         new College(02,"计算机"),
         new College(03,"经管"),
         new College(04,"外语") 
     };
     College[] cg2 = new College[]{
         new College(01,"电子"),
         new College(02,"计算机"),
         new College(03,"工管"),
         new College(04,"外语"), 
         new College(05,"艺术"),
     };
     //Distinct避免重复操作
     var distinct =
         (from o in od
          select new { o.Name }
         ).Distinct();
     Console.WriteLine("去除重复项操作结果:");
     foreach (var item in distinct)
     {
         Console.WriteLine(item);
     }
     //Union合并操作
     var union = od.Union(od2);
     Console.WriteLine("合并操作结果:");
     foreach (var item in union)
     {
         Console.WriteLine(item);
     }
     //Intersect交集操作
     var intersect = cg2.Intersect(cg);
     Console.WriteLine("交集操作结果:");
     foreach (var item in intersect)
     {
         Console.WriteLine(item);
     }
     //Except差集操作
     var except = cg2.Except(cg);
     Console.WriteLine("差集操作结果:");
     foreach (var item in except)
     {
         Console.WriteLine(item);
     }
     Console.Read();
 }
        public CourseDelivery(Course course, College college, DateTime startDate, DateTime endDate)
        {
            Course = course;
            College = college;
            Version = VersionControl.GetInstance().GetNextMajor();
            DeliveryPeriod.Start = startDate;
            DeliveryPeriod.End = endDate;

        }
示例#4
0
 public static List<Account> GetAccounts(
     string name,
     int gender,
     string bloodType,
     int birthYear,
     int birthMonth,
     int birthDate,
     City hometownCity,
     Province homwtownProvince,
     City resideCity,
     Province resideProvince,
     ClassInfo classInfo,
     Grade grade,
     Major major,
     College college,
     University university,
     string code,
     bool? hasAvatar,
     string nickName,
     bool? isProtected,
     int minViewCount,
     int maxViewCount,
     bool? isPublic,
     int minYear,
     int maxYear,
     string interest,
     PagingInfo pagingInfo)
 {
     return provider.GetAccounts(
         name,
         gender,
         bloodType,
         birthYear,
         birthMonth,
         birthDate,
         hometownCity,
         homwtownProvince,
         resideCity,
         resideProvince,
         classInfo,
         grade,
         major,
         college,
         university,
         code,
         hasAvatar,
         nickName,
         isProtected,
         minViewCount,
         maxViewCount,
         isPublic,
         minYear,
         maxYear,
         interest,
         pagingInfo);
 }
 public static College GetByName(string Name)
 {
     DataTable dt = Database.ExecuteQuery("SELECT * FROM College WHERE Name='"+Name+"'");
     if (dt != null && dt.Rows.Count == 1)
     {
         College c = new College();
         c.Name = dt.Rows[0][0].ToString();
         c.Password = dt.Rows[0][1].ToString();
         return c;
     }
     return null;
 }
 public CompetenceActivitiesRoute()
 {
     PDFNAME        = "CompetenceActivities";
     RouteName      = "Competence Activities";
     PrimaryColor   = Color.Green;
     SecondaryColor = Color.Yellow;
     StartLevel.addSection(new ResourcePDF("Competence Activity Booklet", 0));
     StartLevel.addSection(Goals.asLevelContent());
     StartLevel.addSection(Needs.asLevelContent());
     StartLevel.addSection(Homework.asLevelContent());
     StartLevel.addSection(Studying.asLevelContent());
     StartLevel.addSection(Career.asLevelContent());
     StartLevel.addSection(College.asLevelContent());
 }
示例#7
0
        public void TestAddCoursesWithoutCircularReference()
        {
            //arrange
            var college     = new College();
            var courseName1 = "Course A";
            var courseName2 = "Course B";
            var courseName3 = "Course C";

            string[] courseList = { $"{courseName1}", $"{courseName2}: {courseName1}", $"{courseName3}: {courseName2}" };

            //act
            //assert
            Assert.DoesNotThrow(() => { college.AddCourses(courseList); });
        }
示例#8
0
 static CollegeViewModel MapToViewModel(College school)
 {
     return(new CollegeViewModel
     {
         Id = school.Id,
         Name = school.Name,
         Age = school.Age.ToString(),
         Address = school.Address,
         Country = school.Country != null ? $"{school.Country.Alpha2Code} {school.Country.Name}" : null,
         Contacts = school.Contacts,
         Students = StudentMapper.MapListToViewModel(school.Students),
         IsActive = school.IsActive
     });
 }
示例#9
0
        public async Task <PartialViewResult> EditCollege(int?id)
        {
            ViewBag.currentAction = "EditCollege";
            College college = await _collegeService.GetByIdAsync(id.Value);

            EditViewModel model = new EditViewModel
            {
                Id    = college.ID,
                Name  = college.Name,
                Title = college.Title,
            };

            return(PartialView("EditModel", model));
        }
示例#10
0
        bool VerifyIfCollegeExist(College model)
        {
            bool nameTest  = _collegeService.GetAll().Any(x => x.Name.ToLower() == model.Name.ToLower());
            bool titleTest = _collegeService.GetAll().Any(x => x.Title.ToLower() == model.Title.ToLower());

            if (nameTest || titleTest)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Oid,Cid,Name,DLI,Type,Address,Status")] College college)
        {
            if (ModelState.IsValid)
            {
                college.Status = true;
                db.Colleges.Add(college);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.Cid = new SelectList(db.Countries, "Cid", "CountryName", college.Cid);
            return(View(college));
        }
示例#12
0
        // GET: Colleges/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            College college = db.Colleges.Find(id);

            if (college == null)
            {
                return(HttpNotFound());
            }
            return(View(college));
        }
示例#13
0
        private static College AddCollege(QdbContext context, string identifier, string name, string nickname)
        {
            var college = new College
            {
                Identifier = identifier,
                Name       = name,
                Nickname   = nickname
            };

            context.Colleges.Add(college);
            context.SaveChanges();

            return(college);
        }
示例#14
0
        public void TestBorrow()
        {
            College            c    = new College();
            Person             stu1 = new Student("125747G", 0863636, "Jim", "15 Some Street", "*****@*****.**", "Post Gradute", 100001, 0);
            List <IBorrowable> testCanBeBorrowed = new List <IBorrowable>();
            List <IBorrowable> outList           = new List <IBorrowable>();

            testCanBeBorrowed.Add(new Book("Educational", "Book 1", "O'Reilly Media", 2004, 694, 5, 0, 0));

            string actual   = c.borrowItem("book 1", stu1.getID(), testCanBeBorrowed, outList);
            string expected = "\nBOOK BORROWED!\n";

            Assert.AreEqual(expected, actual);
        }
示例#15
0
 public bool Update(College College)
 {
     try
     {
         db.Entry(College).State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
示例#16
0
        public ActionResult Edit(int id, [Bind("ID,Name,Abbreviation")] College college)
        {
            if (id != college.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                DAL.UpdateCollege(college);
                return(RedirectToAction(nameof(Index)));
            }
            return(View(college));
        }
        public async Task <IHttpActionResult> DeleteCollege(int id)
        {
            College college = await db.Colleges.FindAsync(id);

            if (college == null)
            {
                return(NotFound());
            }

            db.Colleges.Remove(college);
            await db.SaveChangesAsync();

            return(Ok(college));
        }
        // GET: Auth/Colleges/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            College college = await db.Colleges.FindAsync(id);

            if (college == null)
            {
                return(HttpNotFound());
            }
            return(View(college));
        }
示例#19
0
文件: Fetcher.cs 项目: Maen1/ADroper
        public static async Task <IEnumerable <Course> > GetCoursesAsync(College college)
        {
            var config = Configuration.Default.WithDefaultLoader();
            var url    = $"http://myapps.iium.edu.my/StudentOnline/schedule1.php?kuly={college.Name}&sem={college.Semester}&ctype={college.Degree}&course=&action=view&ses={college.Session}&search=Submit";
            var doc    = await BrowsingContext.New(config).OpenAsync(url);

            var courses    = new List <Course>();
            var pagesCount = await GetPagesCountAsync(college);

            for (int i = 1; i <= pagesCount; i++)
            {
                var address = $"http://myapps.iium.edu.my/StudentOnline/schedule1.php?kuly={college.Name}&sem={college.Semester}&ctype={college.Degree}&view={ 50 * i}&course=&action=view&ses={college.Session}&search=Submit";
                doc = await BrowsingContext.New(config).OpenAsync(address);

                var cellSelector = "body > table:nth-child(4) > tbody > tr:nth-child(n+3):not(:last-child)";

                var entities = doc.QuerySelectorAll(cellSelector).Select(
                    entity => new
                {
                    Code      = entity.QuerySelector("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(1):not(:last-child)").TextContent,
                    Section   = entity.QuerySelector("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(2)").TextContent,
                    Title     = entity.QuerySelector("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(3)").TextContent,
                    Days      = entity.QuerySelectorAll("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(5) > table > tbody> tr > td:nth-child(1)").Select(a => a.TextContent),
                    Times     = entity.QuerySelectorAll("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(5) > table > tbody> tr > td:nth-child(2)").Select(a => a.TextContent),
                    Lecturers = entity.QuerySelectorAll("body > table:nth-child(4) > tbody > tr:nth-child(n+3) > td:nth-child(5) > table > tbody> tr > td:nth-child(4)").Select(a => a.TextContent)
                });

                var myCourses = entities.Select(entity => new Course
                {
                    Code     = entity.Code,
                    Title    = entity.Title,
                    Sections = new List <Section>
                    {
                        new Section
                        {
                            Number    = int.Parse(entity.Section),
                            Days      = entity.Days.ToArray(),
                            Times     = entity.Times.ToArray(),
                            Lecturers = entity.Lecturers.ToArray()
                        }
                    }
                });

                courses.AddRange(myCourses);
            }

            // MeregeSections(ref courses);
            return(courses);
        }
示例#20
0
        /// <summary>
        /// Adds extra data to a college
        /// </summary>
        /// <param name="college">College to add data to</param>
        public static void AddData(this College college)
        {
            var page = new HtmlWeb().Load(college.CollegeUrl).DocumentNode;

            /* CAMPUS CODE */
            var    campusCodeSelection = page.SelectSingleNode("//h2[contains(text(), 'UCAS campus code:')]");
            string campusCode          = campusCodeSelection.InnerText.Split(' ').Last();

            college.CampusCode = campusCode;

            /* OFFERED COURSES */
            var coursePage = new HtmlWeb().Load($"{college.CollegeUrl}#content-tab--3").DocumentNode;

            var courseList = coursePage.SelectSingleNode("//div[@id='content-tab--3']/ul");

            college.Courses = new List <string>();

            //temp hardcoded solution, planning to fix
            if (college.CampusCode == "P")
            {
                college.Courses.Add("Theology and Religion");
                college.Courses.Add("Philosophy and Theology");
            }

            else
            {
                foreach (var a in courseList.SelectNodes("li/a"))
                {
                    college.Courses.Add(a.InnerText);
                }
            }

            /* NUMBER OF STUDENTS */
            var studentNumSelection = page.SelectSingleNode("//h3[contains(text(), 'Student numbers')]").NextSibling;
            var textSections        = studentNumSelection.InnerHtml.Split("<br>");

            //Mathces 1 or more digits (for both regexes)
            college.UndergradStudents = Convert.ToInt32(Regex.Match(textSections[0], @"\d{1,}").Value);
            college.GradStudents      = Convert.ToInt32(Regex.Match(textSections[1], @"\d{1,}").Value);

            college.TotalStudents = college.UndergradStudents + college.GradStudents;

            /* FACILITIES */
            var facilityPage = new HtmlWeb().Load($"{college.CollegeUrl}#content-tab--2").DocumentNode;

            var facilities = facilityPage.SelectSingleNode("//h2[text()='College facilities']").ParentNode.SelectSingleNode("table/tbody");

            college.Facilities = new CollegeFacilities(facilities);
        }
示例#21
0
        public ActionResult DeleteConfirmed(int id)
        {
            var     db        = DAL.DbContext.Create();
            College college   = db.Colleges.Get(id);
            bool    IsDeleted = db.Colleges.Delete(id);

            if (IsDeleted)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View());
            }
        }
示例#22
0
        // GET: Admin/Colleges/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            College college = db.Colleges.Find(id);

            if (college == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Countryid = new SelectList(db.Countries, "Countryid", "CountryName", college.Countryid);
            return(View(college));
        }
示例#23
0
        public async Task <ActionResult> Create([Bind(Include = "id,CollegeName,CountryCode")] College college, int?id)
        {
            if (ModelState.IsValid)
            {
                var a = db.Countries.Where(x => x.id == id).ToList();
                college.CountryCode  = a[0].id.ToString();
                college.ccountryname = a[0].CountryName;
                db.Colleges.Add(college);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", "Colleges", new { id = id }));
            }

            return(View(college));
        }
示例#24
0
        // GET: College/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            College college = DAL.GetCollege((int)id);

            if (college == null)
            {
                return(NotFound());
            }
            return(View(college));
        }
示例#25
0
 private void SupBtn_Click(object sender, RoutedEventArgs e)
 {
     if (datagrid.SelectedItem != null)
     {
         int     Id         = (datagrid.SelectedItem as College).IdCollege;
         College RmvCollege = (from c in _db.Colleges where c.IdCollege == Id select c).Single();
         _db.Colleges.Remove(RmvCollege);
         _db.SaveChanges();
         datagrid.ItemsSource = _db.Colleges.ToList();
     }
     else
     {
         MessageBox.Show("Aucune Sélection faite", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#26
0
        public async Task UpdateCourseRelationships(AssistDbContext db, College userSelectedCollege, Year year)
        {
            // Our datasets are relatively small so load up everything we plan to touch into memory
            var otherColleges         = db.Colleges.Where(c => c.CollegeId != userSelectedCollege.CollegeId).ToList();
            var dbCourseSets          = db.CourseSets.Include("College").Include("Year").ToList();
            var dbCourseRelationships = db.CourseRelationships.Include("ToCourseSet").Include("FromCourseSet").ToList();
            var dbKnownRequests       = db.KnownRequests.ToList();

            foreach (var otherCollege in otherColleges)
            //foreach (var toCollege in new College[] { toColleges[0] }) //DEBUG
            {
                await UpdateCollegeYearBundleRelationships(db, userSelectedCollege, otherCollege, year, dbCourseSets, dbCourseRelationships, dbKnownRequests);
                await UpdateCollegeYearBundleRelationships(db, otherCollege, userSelectedCollege, year, dbCourseSets, dbCourseRelationships, dbKnownRequests);
            }
        }
示例#27
0
        public ActionResult Edit(College college)
        {
            ValidateCollege(college);

            if (ModelState.IsValid)
            {
                _collegesRepository.Update(college);

                TempData["Message"] = "Your college was successfully updated!";

                return(RedirectToAction("index"));
            }

            return(View(college));
        }
        public async Task <IActionResult> AddNewCollege(string name, string location, List <Major> majors)
        {
            if (await _repo.CollegeExists(name))
            {
                return(BadRequest("College exists"));
            }
            var college = new College {
                Name     = name,
                Location = location,
                Majors   = majors
            };
            var createdCollege = await _repo.AddNewCollege(college);

            return(StatusCode(201));
        }
示例#29
0
 /// <summary>
 /// 添加一个分院信息
 /// </summary>
 /// <param name="college">要添加的学院对象</param>
 /// <returns>返回受影响行数</returns>
 public int Insert(College college)
 {
     try
     {
         string   cmdText = "insert into T_College(collegeName) values(@collName)";
         string[] param   = { "@collName" };
         object[] values  = { college.ColName };
         int      row     = db.ExecuteNoneQuery(cmdText.ToString(), param, values);
         return(row);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#30
0
        public void TestReturnWrongItem()
        {
            College            c    = new College();
            Person             stu1 = new Student("125747G", 0863636, "Jim", "15 Some Street", "*****@*****.**", "Post Gradute", 100001, 0);
            List <IBorrowable> testCanBeBorrowed = new List <IBorrowable>();
            List <IBorrowable> outList           = new List <IBorrowable>();

            testCanBeBorrowed.Add(new Book("Educational", "Book 1", "O'Reilly Media", 2004, 694, 5, 0, 0));
            c.borrowItem("book 1", stu1.getID(), testCanBeBorrowed, outList);
            c.returnItem("book 2", stu1.getID(), testCanBeBorrowed, outList);
            int actual   = outList.Count;
            int expected = 1;

            Assert.AreEqual(expected, actual);
        }
示例#31
0
        public void TestAddCoursesWithBlankNames()
        {
            //arrange
            var college     = new College();
            var courseName1 = "Intro to Fire";
            var courseName2 = "   ";

            string[] courseList = { courseName1, courseName2 };

            //act
            college.AddCourses(courseList);

            //assert
            Assert.AreEqual(courseName1, college.Schedule);
        }
示例#32
0
        private void DisplayPopularListings(College school)
        {
            PopularListingsTitle.InnerHtml = "Popular " + school.ShortName + " Listings";

            List <Advertisement> advertisements = Database.GetAds(school.Id, "", 1, Order.Views);

            foreach (Advertisement ad in advertisements)
            {
                HtmlGenericControl listing = new HtmlGenericControl("div");
                listing.Attributes.Add("class", "column-item");
                listing.InnerHtml = "<div class='date'>" + ad.GetShortCreationDate() + "</div><a href='/listing/" + ad.Id + "'>" + ad.Title + "</a>";

                PopularListings.Controls.Add(listing);
            }
        }
示例#33
0
        /// <summary>
        /// 执行增加学院操作
        /// </summary>
        /// <param name="college">学院实体类</param>
        /// <returns>返回受影响行数</returns>
        public int AddCollege(College college)
        {
            int   i  = _iCollegeRespository.AddCollege(college);
            Users us = (Users)Session["User"];

            if (i > 0)
            {
                logs.Add(us.ID, "添加学院", 1);
            }
            else
            {
                logs.Add(us.ID, "添加学院", 0);
            }
            return(i);
        }
示例#34
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            College = await _context.Colleges.FirstOrDefaultAsync(m => m.Id == id);

            if (College == null)
            {
                return(NotFound());
            }
            return(Page());
        }
示例#35
0
 /// <summary>
 /// 修改一个学院的名称
 /// </summary>
 /// <param name="college">要修改的学院对象</param>
 /// <returns>返回受影响行数</returns>
 public int Update(College college)
 {
     try
     {
         string   cmdText = "update T_College set collegeName = @collName where collegeId = @collId";
         string[] param   = { "@collName", "@collId" };
         object[] values  = { college.ColName, college.ColID };
         int      row     = db.ExecuteNoneQuery(cmdText, param, values);
         return(row);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#36
0
 public CourseDelivery(Course course, College college, string callOccCode, ISemesterDates semester)
     : this(course, college, semester.Dates["termOneStart"], semester.Dates["termTwoEnd"])
 {
     CallOccCode = callOccCode;
 }
示例#37
0
 public CourseDelivery(Course course, College college, string callOccCode, DateTime startDate, DateTime endDate, List<SubjectDelivery> subjects)
     : this(course, college, callOccCode, startDate, endDate)
 {
     Subjects = subjects;
 }
示例#38
0
 public List<CourseDelivery> FetchCourses(FakeSemester semester, College college)
 {
     return repo.GetAll(college, semester);
 }
示例#39
0
 public CourseDelivery(Course course, College college, string callOccCode, DateTime startDate, DateTime endDate)
     : this(course, college, startDate, endDate)
 {
     CallOccCode = callOccCode;
 }
示例#40
0
        // ��̨����
        public List<Account> GetAccounts(
            string name,
            int gender,
            string bloodType,
            int birthYear,
            int birthMonth,
            int birthDate,
            City hometownCity,
            Province homwtownProvince,
            City resideCity,
            Province resideProvince,
            ClassInfo classInfo,
            Grade grade,
            Major major,
            College college,
            University university,
            string code,
            bool? hasAvatar,
            string nickName,
            bool? isProtected,
            int minViewCount,
            int maxViewCount,
            bool? isPublic,
            string Sort,
            PagingInfo pagingInfo)
        {
            List<Account> accountlist = new List<Account>();
            SqlServerUtility sql = new SqlServerUtility(connectionString);
            System.Text.StringBuilder sbFilter = new StringBuilder();

            #region Build filter

            sbFilter.Append("1=1 ");

            if (!string.IsNullOrEmpty(name))
            {
                sbFilter.Append(" And [Name] like '%");
                sbFilter.Append(name.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("%'");
            }

            if (gender == 1 || gender == 0)
            {
                sbFilter.Append(" And [Gender] = ");
                sbFilter.Append(gender);
            }

            if (!string.IsNullOrEmpty(bloodType))
            {
                sbFilter.Append(" And BloodType = '");
                sbFilter.Append(bloodType.Replace("'", "").Replace("\"", ""));
                sbFilter.Append(" '");
            }

            if (birthYear > 0)
            {
                sbFilter.Append(" And BirthYear = ");
                sbFilter.Append(birthYear);
            }

            if (birthMonth > 0 && birthMonth < 13)
            {
                sbFilter.Append(" And BirthMonth = ");
                sbFilter.Append(birthMonth);
            }

            if (birthDate > 0 && birthDate < 32)
            {
                sbFilter.Append(" And BirthDate = ");
                sbFilter.Append(birthDate);
            }

            if (hometownCity != null)
            {
                if (hometownCity.Id > 0)
                {
                    sbFilter.Append(" And HometownCityId = ");
                    sbFilter.Append(hometownCity.Id);
                }
            }
            else
            {
                if (homwtownProvince != null && homwtownProvince.Id > 0)
                {
                    sbFilter.Append(" And HometownProvinceId = ");
                    sbFilter.Append(homwtownProvince.Id);
                }
            }

            if (resideCity != null)
            {
                if (resideCity.Id > 0)
                {
                    sbFilter.Append(" And ResideCityId = ");
                    sbFilter.Append(resideCity.Id);
                }
            }
            else
            {
                if (resideProvince != null && resideProvince.Id > 0)
                {
                    sbFilter.Append(" And ResideProvinceId = ");
                    sbFilter.Append(resideProvince.Id);
                }
            }

            if (classInfo != null)
            {
                if (classInfo.Id > 0)
                {
                    sbFilter.Append(" And ClassInfoId = ");
                    sbFilter.Append(classInfo.Id);
                }
            }
            else
            {
                if (grade != null && grade.Id > 0)
                {
                    sbFilter.Append(" And GradeId = ");
                    sbFilter.Append(grade.Id);
                }

                if (major != null)
                {
                    if (major.Id > 0)
                    {
                        sbFilter.Append(" And MajorId = ");
                        sbFilter.Append(major.Id);
                    }
                }
                else
                {
                    if (college != null)
                    {
                        if (college.Id > 0)
                        {
                            sbFilter.Append(" And CollegeId = ");
                            sbFilter.Append(college.Id);
                        }
                    }
                    else
                    {
                        if (university != null && university.Id > 0)
                        {
                            sbFilter.Append(" And UniversityID = ");
                            sbFilter.Append(university.Id);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(code))
            {
                sbFilter.Append(" And Code = '");
                sbFilter.Append(code.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (hasAvatar.HasValue)
            {
                sbFilter.Append(string.Format(" And HasAvatar = '{0}'", hasAvatar.Value ? "1" : "0"));
            }

            if (!string.IsNullOrEmpty(nickName))
            {
                sbFilter.Append(" And NickName = '");
                sbFilter.Append(nickName.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (isProtected.HasValue)
            {
                sbFilter.Append(string.Format(" And IsProtected = '{0}'", isProtected.Value ? "1" : "0"));
            }

            if ((minViewCount > 0) &&
                (maxViewCount > 0) &&
                (minViewCount < maxViewCount))
            {
                sbFilter.Append(string.Format(" And ViewNumber Between {0} and {1} ", minViewCount, maxViewCount));
            }

            if (isPublic.HasValue)
            {
                sbFilter.Append(" And IsPublic = '");
                sbFilter.Append(isPublic.Value ? "1" : "0");
                sbFilter.Append("'");
            }
            //ͨ��������֤�����û�
            sbFilter.Append(" And IsEmailChecked='1'");
            #endregion

            #region BackCode
            /*
            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pagingInfo != null)
            {
                pageSize = pagingInfo.PageSize;
                pageNumber = pagingInfo.CurrentPage;
            }

            String Fields1 = "Id,ViewNumber,DateCreated,IsProtected,HasAvatar,IsTeacher,Name,NickName,Code,Credit,IsPublic,BirthYear,BirthMonth," +
                            "BirthDate,Gender,LoveState,HometownProvinceId,HometownCityId,ResideProvinceId,ResideCityId,Birthday,IsEmailChecked," +
                            "Telephone,Email,QQ,MSN,BloodType,Theme,LibUserId,Password,Interest,MajorId,MajorName,CollegeId,CollegeName,UniversityID,UniversityName,GradeId,GradeYear," +
                            "HometownProvinceName,HometownCityName,ResideProvinceName,ResideCityName,IsShow,FriendCount";

            String Fields2 = "Id,Credit,DateCreated,IsProtected,HasAvatar,IsTeacher,IsPublic,ViewNumber,Name,NickName,Code,FriendCount";

            sql.AddParameter("@Tables", SqlDbType.VarChar, "view_account_all");
            sql.AddParameter("@PK", SqlDbType.VarChar, "Id");
            sql.AddParameter("@Fields", SqlDbType.VarChar, Fields2);//"Id"
            sql.AddParameter("@sort", SqlDbType.NVarChar, Sort + " DESC");
            sql.AddParameter("@Filter", SqlDbType.VarChar, sbFilter.ToString());
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNumber);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");
            */
            #endregion

            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pagingInfo != null)
            {
                pageSize = pagingInfo.PageSize;
                pageNumber = pagingInfo.CurrentPage;
            }

            sql.AddParameter("@PageNum", SqlDbType.Int, pageSize);
            sql.AddParameter("@Num", SqlDbType.Int, pageSize * (pageNumber - 1));

            String Column = "Id,Credit,DateCreated,IsProtected,HasAvatar,IsTeacher,IsPublic,ViewNumber,Name,NickName,Code,(SELECT COUNT(Friendship.Id) FROM Friendship WHERE (Friendship.AccountId = view_account_all.Id) AND (Friendship.IsChecked = 1)) AS FriendCount";
            StringBuilder sbSQL = new StringBuilder();
            sbSQL.Append("SELECT TOP (@PageNum) " + Column + " FROM view_account_all WHERE " + sbFilter.ToString() + " AND [Id] NOT IN ");
            sbSQL.Append("(SELECT TOP (@Num) [Id] FROM view_account_all WHERE " + sbFilter.ToString() + " ORDER BY " + Sort + " DESC) ORDER BY " + Sort + " DESC");

            SqlDataReader reader = sql.ExecuteSqlReader(sbSQL.ToString());

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.Account account = new Core.Business.Account();

                    if (!reader.IsDBNull(0)) account.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) account.Credit = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) account.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) account.IsProtected = reader.GetBoolean(3);
                    if (!reader.IsDBNull(4)) account.HasAvatar = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) account.IsTeacher = reader.GetBoolean(5);
                    if (!reader.IsDBNull(6)) account.IsPublic = reader.GetBoolean(6);
                    if (!reader.IsDBNull(7)) account.ViewNumber = reader.GetInt64(7);
                    if (!reader.IsDBNull(8)) account.Name = reader.GetString(8);
                    if (!reader.IsDBNull(9)) account.NickName = reader.GetString(9);
                    if (!reader.IsDBNull(10)) account.Code = reader.GetString(10);
                    if (!reader.IsDBNull(11)) account.FriendCount = reader.GetInt32(11);

                    account.MarkOld();
                    accountlist.Add(account);
                }
                reader.Close();
            }

            return accountlist;
        }
示例#41
0
 /// <summary>
 /// Create a new College object.
 /// </summary>
 /// <param name="ID">Initial value of Id.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="city">Initial value of City.</param>
 /// <param name="state">Initial value of State.</param>
 public static College CreateCollege(int ID, string name, string city, string state)
 {
     College college = new College();
     college.Id = ID;
     college.Name = name;
     college.City = city;
     college.State = state;
     return college;
 }
示例#42
0
 public static College College(int? count)
 {
     var rtValue = new College();
     rtValue.Name = "Name" + count.Extra();
     return rtValue;
 }
示例#43
0
        public CourseDelivery(Qualification qualification, string courseDescription, College college, string callOccCode, ISemesterDates semester)
            : this(new Course(courseDescription, qualification), college, callOccCode, semester)
        {

        }
示例#44
0
        public int GetAccountsCount(
            string name,
            int gender,
            string bloodType,
            int birthYear,
            int birthMonth,
            int birthDate,
            City hometownCity,
            Province homwtownProvince,
            City resideCity,
            Province resideProvince,
            ClassInfo classInfo,
            Grade grade,
            Major major,
            College college,
            University university,
            string code,
            bool? hasAvatar,
            string nickName,
            bool? isProtected,
            int minViewCount,
            int maxViewCount,
            bool? isPublic,
            int minYear,
            int maxYear,
            string interest
            )
        {
            System.Text.StringBuilder sbFilter = new StringBuilder();

            #region Build filter

            sbFilter.Append("Where 1=1 ");

            if (!string.IsNullOrEmpty(name))
            {
                sbFilter.Append(" And [Name] like '%");
                sbFilter.Append(name.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("%'");
            }

            if (gender == 1 || gender == 0)
            {
                sbFilter.Append(" And [Gender] = ");
                sbFilter.Append(gender);
            }

            if (!string.IsNullOrEmpty(bloodType))
            {
                sbFilter.Append(" And BloodType = '");
                sbFilter.Append(bloodType.Replace("'", "").Replace("\"", ""));
                sbFilter.Append(" '");
            }

            if (birthYear > 0)
            {
                sbFilter.Append(" And BirthYear = ");
                sbFilter.Append(birthYear);
            }

            if (birthMonth > 0 && birthMonth < 13)
            {
                sbFilter.Append(" And BirthMonth = ");
                sbFilter.Append(birthMonth);
            }

            if (birthDate > 0 && birthDate < 32)
            {
                sbFilter.Append(" And BirthDate = ");
                sbFilter.Append(birthDate);
            }

            if (hometownCity != null)
            {
                if (hometownCity.Id > 0)
                {
                    sbFilter.Append(" And HometownCityId = ");
                    sbFilter.Append(hometownCity.Id);
                }
            }
            else
            {
                if (homwtownProvince != null && homwtownProvince.Id > 0)
                {
                    sbFilter.Append(" And HometownProvinceId = ");
                    sbFilter.Append(homwtownProvince.Id);
                }
            }

            if (resideCity != null)
            {
                if (resideCity.Id > 0)
                {
                    sbFilter.Append(" And ResideCityId = ");
                    sbFilter.Append(resideCity.Id);
                }
            }
            else
            {
                if (resideProvince != null && resideProvince.Id > 0)
                {
                    sbFilter.Append(" And ResideProvinceId = ");
                    sbFilter.Append(resideProvince.Id);
                }
            }

            if (classInfo != null)
            {
                if (classInfo.Id > 0)
                {
                    sbFilter.Append(" And ClassInfoId = ");
                    sbFilter.Append(classInfo.Id);
                }
            }
            else
            {
                if (grade != null && grade.Id > 0)
                {
                    sbFilter.Append(" And GradeId = ");
                    sbFilter.Append(grade.Id);
                }

                if (major != null)
                {
                    if (major.Id > 0)
                    {
                        sbFilter.Append(" And MajorId = ");
                        sbFilter.Append(major.Id);
                    }
                }
                else
                {
                    if (college != null)
                    {
                        if (college.Id > 0)
                        {
                            sbFilter.Append(" And CollegeId = ");
                            sbFilter.Append(college.Id);
                        }
                    }
                    else
                    {
                        if (university != null && university.Id > 0)
                        {
                            sbFilter.Append(" And UniversityID = ");
                            sbFilter.Append(university.Id);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(code))
            {
                sbFilter.Append(" And Code = '");
                sbFilter.Append(code.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (hasAvatar.HasValue)
            {
                sbFilter.Append(string.Format(" And HasAvatar = '{0}'", hasAvatar.Value ? "1" : "0"));
            }

            if (!string.IsNullOrEmpty(nickName))
            {
                sbFilter.Append(" And NickName = '");
                sbFilter.Append(nickName.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (isProtected.HasValue)
            {
                sbFilter.Append(string.Format(" And IsProtected = '{0}'", isProtected.Value ? "1" : "0"));
            }

            if ((minViewCount > 0) &&
                (maxViewCount > 0) &&
                (minViewCount < maxViewCount))
            {
                sbFilter.Append(string.Format(" And ViewNumber Between {0} and {1} ", minViewCount, maxViewCount));
            }

            if (isPublic.HasValue)
            {
                sbFilter.Append(" And IsPublic = '");
                sbFilter.Append(isPublic.Value ? "1" : "0");
                sbFilter.Append("'");
            }
            if (minYear != 0 && maxYear != 0)
            {
                sbFilter.Append(string.Format(" And BirthYear Between {0} and {1} ", minYear, maxYear));
            }
            if (interest != string.Empty)
            {
                sbFilter.Append(string.Format(" And Interest like '{0}' ", interest));
            }
            //ͨ��������֤�����û�
            sbFilter.Append(" And IsEmailChecked='1'");// �߼����� AND [IsShow] = 0
            #endregion

            SqlServerUtility sql = new SqlServerUtility(connectionString);
            String strSql = "Select count(Id) From [view_account_all] " + sbFilter.ToString();
            SqlDataReader reader = sql.ExecuteSqlReader(strSql);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                int count = 0;

                if (!reader.IsDBNull(0)) count = reader.GetInt32(0);

                reader.Close();
                return count;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return 0;
            }
        }
示例#45
0
 /// <summary>
 /// There are no comments for Colleges in the schema.
 /// </summary>
 public void AddToColleges(College college)
 {
     base.AddObject("Colleges", college);
 }
示例#46
0
        public CourseDelivery(string courseName, string courseDescription, College college, string callOccCode, DateTime startDate, DateTime endDate)
            : this(new Course(courseName, courseDescription), college, callOccCode, startDate, endDate)
        {

        }
示例#47
0
        public ActionResult Edit(College college, int id)
        {
            var db = DAL.DbContext.Create();
            if (ModelState.IsValid)
            {
                db.Colleges.Update(college.Id, college);

                return RedirectToAction("Index");
            }

            return View(college);
        }
示例#48
0
        public List<Account> GetAccounts(
            string name,
            int gender,
            string bloodType,
            int birthYear,
            int birthMonth,
            int birthDate,
            City hometownCity,
            Province homwtownProvince,
            City resideCity,
            Province resideProvince,
            ClassInfo classInfo,
            Grade grade,
            Major major,
            College college,
            University university,
            string code,
            bool? hasAvatar,
            string nickName,
            bool? isProtected,
            int minViewCount,
            int maxViewCount,
            bool? isPublic,
            int minYear,
            int maxYear,
            string interest,
            PagingInfo pagingInfo)
        {
            List<Account> accounts = new List<Account>();
            System.Text.StringBuilder sbFilter = new StringBuilder();

            #region Build filter

            sbFilter.Append("1=1 ");

            if (!string.IsNullOrEmpty(name))
            {
                sbFilter.Append(" And [Name] like '%");
                sbFilter.Append(name.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("%'");
            }

            if (gender == 1 || gender == 0)
            {
                sbFilter.Append(" And [Gender] = ");
                sbFilter.Append(gender);
            }

            if (!string.IsNullOrEmpty(bloodType))
            {
                sbFilter.Append(" And BloodType = '");
                sbFilter.Append(bloodType.Replace("'", "").Replace("\"", ""));
                sbFilter.Append(" '");
            }

            if (birthYear > 0)
            {
                sbFilter.Append(" And BirthYear = ");
                sbFilter.Append(birthYear);
            }

            if (birthMonth > 0 && birthMonth < 13)
            {
                sbFilter.Append(" And BirthMonth = ");
                sbFilter.Append(birthMonth);
            }

            if (birthDate > 0 && birthDate < 32)
            {
                sbFilter.Append(" And BirthDate = ");
                sbFilter.Append(birthDate);
            }

            if (hometownCity != null)
            {
                if (hometownCity.Id > 0)
                {
                    sbFilter.Append(" And HometownCityId = ");
                    sbFilter.Append(hometownCity.Id);
                }
            }
            else
            {
                if (homwtownProvince != null && homwtownProvince.Id > 0)
                {
                    sbFilter.Append(" And HometownProvinceId = ");
                    sbFilter.Append(homwtownProvince.Id);
                }
            }

            if (resideCity != null)
            {
                if (resideCity.Id > 0)
                {
                    sbFilter.Append(" And ResideCityId = ");
                    sbFilter.Append(resideCity.Id);
                }
            }
            else
            {
                if (resideProvince != null && resideProvince.Id > 0)
                {
                    sbFilter.Append(" And ResideProvinceId = ");
                    sbFilter.Append(resideProvince.Id);
                }
            }

            if (classInfo != null)
            {
                if (classInfo.Id > 0)
                {
                    sbFilter.Append(" And ClassInfoId = ");
                    sbFilter.Append(classInfo.Id);
                }
            }
            else
            {
                if (grade != null && grade.Id > 0)
                {
                    sbFilter.Append(" And GradeId = ");
                    sbFilter.Append(grade.Id);
                }

                if (major != null)
                {
                    if (major.Id > 0)
                    {
                        sbFilter.Append(" And MajorId = ");
                        sbFilter.Append(major.Id);
                    }
                }
                else
                {
                    if (college != null)
                    {
                        if (college.Id > 0)
                        {
                            sbFilter.Append(" And CollegeId = ");
                            sbFilter.Append(college.Id);
                        }
                    }
                    else
                    {
                        if (university != null && university.Id > 0)
                        {
                            sbFilter.Append(" And UniversityID = ");
                            sbFilter.Append(university.Id);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(code))
            {
                sbFilter.Append(" And Code = '");
                sbFilter.Append(code.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (hasAvatar.HasValue)
            {
                sbFilter.Append(string.Format(" And HasAvatar = '{0}'", hasAvatar.Value ? "1" : "0"));
            }

            if (!string.IsNullOrEmpty(nickName))
            {
                sbFilter.Append(" And NickName = '");
                sbFilter.Append(nickName.Replace("'", "").Replace("\"", ""));
                sbFilter.Append("'");
            }

            if (isProtected.HasValue)
            {
                sbFilter.Append(string.Format(" And IsProtected = '{0}'", isProtected.Value ? "1" : "0"));
            }

            if ((minViewCount > 0) &&
                (maxViewCount > 0) &&
                (minViewCount < maxViewCount))
            {
                sbFilter.Append(string.Format(" And ViewNumber Between {0} and {1} ", minViewCount, maxViewCount));
            }

            if (isPublic.HasValue)
            {
                sbFilter.Append(" And IsPublic = '");
                sbFilter.Append(isPublic.Value ? "1" : "0");
                sbFilter.Append("'");
            }
            if (minYear != 0 && maxYear != 0)
            {
                sbFilter.Append(string.Format(" And BirthYear Between {0} and {1} ", minYear, maxYear));
            }
            if (interest != string.Empty)
            {
                sbFilter.Append(string.Format(" And Interest like '%{0}%' ", interest));
            }
            //ͨ��������֤�����û�
            sbFilter.Append(" And IsEmailChecked='1'");//�߼����� AND [IsShow] = 0
            #endregion

            int pageSize = int.MaxValue;
            int pageNumber = 1;
            if (pagingInfo != null)
            {
                pageSize = pagingInfo.PageSize;
                pageNumber = pagingInfo.CurrentPage;
            }

            SqlServerUtility sql = new SqlServerUtility(connectionString);

            sql.AddParameter("@Tables", SqlDbType.VarChar, "view_account_all");
            sql.AddParameter("@PK", SqlDbType.VarChar, "Id");
            sql.AddParameter("@Fields", SqlDbType.VarChar, "Id");
            sql.AddParameter("@sort", SqlDbType.NVarChar, "Id DESC");
            sql.AddParameter("@Filter", SqlDbType.VarChar, sbFilter.ToString());
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNumber);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);

            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    long id = reader.GetInt64(0);
                    Account account = Account.Load(id);

                    accounts.Add(account);
                }
                reader.Close();
            }

            return accounts;
        }