// מחיקה

        public static void DeleteTeachers(string id)
        {
            using (var context = new PARENTSEntities())
            {
                teachers teachers = context.teachers.Where(p => p.id.Equals(id)).FirstOrDefault();
                context.teachers.Remove(teachers);
                context.SaveChanges();
            }
        }
 //הוספת
 public static string AddTeachers(teachers teachers)
 {
     using (var context = new PARENTSEntities())
     {
         teachers t = context.teachers.Add(teachers);
         context.SaveChanges();
         return(t.id);
     }
 }
 /// <summary>
 /// 更改教师登录密码
 /// </summary>
 /// <param name="n">教师信息实体类</param>
 public void UpdatePwd(teachers n)
 {
     SqlParameter[] paras = new SqlParameter[]
     {
         new SqlParameter("@pwd", n.Pwd),
         new SqlParameter("@modifier", n.Modifier),
         new SqlParameter("@teacherId", n.TeacherId),
     };
     sqlhelper.ExecuteQuery("UPDATE teachers SET pwd = @pwd,modifier = @modifier,lastmodify = getdate() where teachers.teacherId=@teacherId", paras, CommandType.Text);
 }
 /// <summary>
 /// 更新教师信息
 /// </summary>
 /// <param name="n">教师信息实体类</param>
 public void Update(teachers n)
 {
     SqlParameter[] paras = new SqlParameter[]
     {
         new SqlParameter("@name", n.Name),
         new SqlParameter("@post", n.Post),
         new SqlParameter("@college", n.College),
         new SqlParameter("@phone", n.Phone),
         new SqlParameter("@email", n.Email),
         new SqlParameter("@modifier", n.Modifier),
         new SqlParameter("@teacherId", n.TeacherId),
     };
     sqlhelper.ExecuteQuery("UPDATE teachers SET name = @name,post = @post,college=@college,phone = @phone,email = @email,modifier = @modifier,lastmodify = getdate() where teacherId=@teacherId", paras, CommandType.Text);
 }
 //עדכון
 public static void UpdateTeachers(teachers teachers)
 {
     using (var context = new PARENTSEntities())
     {
         teachers t = context.teachers.Where(x => x.id == teachers.id).FirstOrDefault();
         if (t != null)
         {
             t.code_instation = teachers.code_instation;
             t.id             = teachers.id;
             t.NAME           = teachers.NAME;
             t.telefone       = teachers.telefone;
             context.SaveChanges();
         }
     }
 }
        /// <summary>
        /// 增加新教师信息
        /// </summary>
        /// <param name="n">教师信息实体类</param>
        /// <returns></returns>
        public bool Insert(teachers n)
        {
            bool flag = false;

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@teacherId", n.TeacherId),
                new SqlParameter("@phone", n.Phone),
                new SqlParameter("@post", n.Post),
                new SqlParameter("@college", n.College),
                new SqlParameter("@creater", n.Creater),
                new SqlParameter("@email", n.Email),
                new SqlParameter("@modifier", n.Creater),
                new SqlParameter("@name", n.Name),
                new SqlParameter("@pwd", n.Pwd),
            };
            int res = sqlhelper.ExecuteNonQuery("INSERT INTO teachers (teacherId, name, pwd, post, college, phone, email, creater, modifier) VALUES (@teacherId,@name,@pwd,@post,@college,@phone,@email,@creater,@creater)", paras, CommandType.Text);

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