DAL/LessonSelectService.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Model;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class LessonSelectService
    {
        //当选课人数已满的时候将选课状态转为已满
        public static bool UpdataState(LessonSelect ls)
        {
            string sql = $"UPDATE [dbo].[Lessoninfo] SET LessonState='已满' where LessonName='{ls.LessonName}' ";

            return DBHelper.updateData(sql);
        }
        //从数据库获取当前选课人数
        public static LessonSelect getMax(int id)
        {
            string sql = $"Select count(*) from LessonSelect where id='{id}'";
            SqlDataReader dr = DBHelper.getData(sql);
            LessonSelect ls = null;

            if (dr.Read())
            {
                ls = new LessonSelect()
                {
                    MaxNeed = dr.GetInt32(0)
                };
            }
            dr.Close();
            return ls;
        }
        //从数据库获取当前用户选课数量
        public static LessonSelect getSelect(int StudentNum)
        {
            string sql = $"Select count(*) from LessonSelect where StudentNum='{StudentNum}'";
            SqlDataReader dr = DBHelper.getData(sql);
            LessonSelect ls = null;

            if (dr.Read())
            {
                ls = new LessonSelect()
                {
                    UserSelect = dr.GetInt32(0)
                };
            }
            dr.Close();
            return ls;
        }
        //从数据库获取当前用户所选课程是否已过期或者未开始
        public static LessonSelect getTime(string LessonName, DateTime LessonTime)
        {
            string sql = $"select DATEDIFF(DAY,'{LessonTime}',GETDATE()) from Lessoninfo where LessonName='{LessonName}'";
            SqlDataReader dr = DBHelper.getData(sql);
            LessonSelect ls = null;

后面还有 36 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。