コード例 #1
0
        // מחיקה

        public static void DeleteClass(int code)
        {
            using (var context = new PARENTSEntities())
            {
                classes classes = context.classes.Where(p => p.code == code).FirstOrDefault();
                context.classes.Remove(classes);
                context.SaveChanges();
            }
        }
コード例 #2
0
 //הוספת
 public static int AddClass(classes classes)
 {
     using (var context = new PARENTSEntities())
     {
         classes c = context.classes.Add(classes);
         context.SaveChanges();
         return(c.code);
     }
 }
コード例 #3
0
 /// <summary>
 /// 更新班级信息
 /// </summary>
 /// <param name="n">班级信息实体类</param>
 public void UpdateClass(classes n)
 {
     SqlParameter[] paras = new SqlParameter[]
     {
         new SqlParameter("@name", n.Name),
         new SqlParameter("@term", n.Term),
         new SqlParameter("@teacherId", n.TeacherId),
         new SqlParameter("@modifier", n.Modifier),
         new SqlParameter("@classId", n.ClassId),
     };
     sqlhelper.ExecuteQuery("UPDATE classes SET name = @name,term = @term,teacherId=@teacherId,modifier = @modifier,lastmodify = getdate() where classId=@classId", paras, CommandType.Text);
 }
コード例 #4
0
        //הוספת
        public static int AddClass(classes classes)
        {
            using (var context = new PARENTSEntities1())
            {
                context.Database.ExecuteSqlCommand("set identity_insert [dbo].[classes] on");

                classes c = context.classes.Add(classes);
                context.SaveChanges();
                context.Database.ExecuteSqlCommand("set identity_insert [dbo].[classes] of");

                return(c.code);
            }
        }
コード例 #5
0
 //עדכון
 public static void UpdateClass(classes classes)
 {
     using (var context = new PARENTSEntities())
     {
         classes pro = context.classes.Where(p => p.code == classes.code).FirstOrDefault();
         if (pro != null)
         {
             pro.code       = classes.code;
             pro.num_class  = classes.num_class;
             pro.id_teacher = classes.id_teacher;
             context.SaveChanges();
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// 删除班级
        /// </summary>
        /// <param name="n">班级信息实体类</param>
        /// <returns></returns>
        public bool DeleteClass(classes n)
        {
            bool flag = false;

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@classId", n.ClassId),
            };
            int res = sqlhelper.ExecuteNonQuery("DELETE FROM classes where classId=@classId", paras, CommandType.Text);

            if (res > 0)
            {
                flag = true;
            }
            return(flag);
        }
コード例 #7
0
        /// <summary>
        /// 新增班级
        /// </summary>
        /// <param name="n">班级信息实体类</param>
        /// <returns></returns>
        public bool InsertClass(classes n)
        {
            bool flag = false;

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@classId", n.ClassId),
                new SqlParameter("@name", n.Name),
                new SqlParameter("@teacherId", n.TeacherId),
                new SqlParameter("@term", n.Term),
                new SqlParameter("@creater", n.Creater),
                new SqlParameter("@modifier", n.Creater),
            };
            int res = sqlhelper.ExecuteNonQuery("INSERT INTO classes (classId, name, teacherId, term,  creater, modifier) VALUES (@classId,@name,@teacherId,@term,@creater,@creater)", paras, CommandType.Text);

            if (res > 0)
            {
                flag = true;
            }
            return(flag);
        }