Пример #1
0
 public bool TeacherAdd(Entities db, Guid campusId, Guid departmentId, int ordinal, string name, string phone, string passwordInitial, State state, string email, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string account, bool? perstaff, bool sync, out Guid gid, string ex)
 {
     gid = db.GetId();
     try
     {
         string key, salt;
         var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
         var user = new User
         {
             Id = gid,
             Account = account,
             RealName = name,
             DisplayName = name,
             Stamp = Guid.NewGuid(),
             Type = UserType.教师,
             Password = password,
             PasswordEx = null,
             CryptoKey = key,
             CryptoSalt = salt,
             Icon = "~/CommonX/默认/用户.png",
             State = state,
             Ordinal = ordinal,
             Description = null
         };
         var userTeacher = new Homory.Model.Teacher
         {
             Id = user.Id,
             Phone = phone,
             Email = email,
             Gender = gender,
             Birthday = birthday,
             Birthplace = birthplace,
             Address = address,
             Nationality = nationality,
             IDCard = idCard,
             PerStaff = perstaff ?? true,
             Sync = sync
         };
         var relation = new DepartmentUser
         {
             DepartmentId = departmentId,
             UserId = user.Id,
             TopDepartmentId = campusId,
             Type = DepartmentUserType.部门主职教师,
             State = State.启用,
             Ordinal = 0,
             Time = DateTime.Now
         };
         db.User.Add(user);
         db.Teacher.Add(userTeacher);
         db.DepartmentUser.Add(relation);
         db.SaveChanges();
         try { UserHelper.InsertUserEx(name, "C984AED014AEC7623A54F0591DA07A85FD4B762D", sync, state, account, departmentId.ToString().ToUpper(), gid.ToString().ToUpper(), phone, idCard, ordinal, 0, "1000", ex); } catch { }
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #2
0
 public bool StudentAdd(Entities db, Guid campusId, Guid classId, int ordinal, string name, string account, string passwordInitial, State state, string uniqueId, string idCard, bool? gender, DateTime? birthday, string nationality, string birthplace, string address, string charger, string chargerContact)
 {
     try
     {
         string key, salt;
         var password = HomoryCryptor.Encrypt(passwordInitial, out key, out salt);
         var user = new User
         {
             Id = db.GetId(),
             Account = account,
             RealName = name,
             DisplayName = name,
             Stamp = Guid.NewGuid(),
             Type = UserType.学生,
             Password = password,
             PasswordEx = null,
             CryptoKey = key,
             CryptoSalt = salt,
             Icon = "~/Common/默认/用户.png",
             State = state,
             Ordinal = ordinal,
             Description = null
         };
         var userStudent = new Homory.Model.Student
         {
             Id = user.Id,
             UniqueId = uniqueId,
             Gender = gender,
             Birthday = birthday,
             Birthplace = birthplace,
             Address = address,
             Nationality = nationality,
             IDCard = idCard,
             Charger = charger,
             ChargerContact = chargerContact
         };
         var relation = new DepartmentUser
         {
             DepartmentId = classId,
             UserId = user.Id,
             TopDepartmentId = campusId,
             Type = DepartmentUserType.班级学生,
             State = State.启用,
             Ordinal = 0,
             Time = DateTime.Now
         };
         db.User.Add(user);
         db.Student.Add(userStudent);
         db.DepartmentUser.Add(relation);
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #3
0
 protected void charger_OnClick(object sender, EventArgs e)
 {
     var button = sender as RadButton;
     if (button == null) return;
     var classId = Guid.Parse(tree.SelectedNode.Value);
     var campusNode = tree.SelectedNode;
     while (campusNode.Level > 0)
     {
         campusNode = campusNode.ParentNode;
     }
     var campusId = Guid.Parse(campusNode.Value);
     var userId = Guid.Parse(button.CommandArgument);
     HomoryContext.Value.DepartmentUser.Where(o => o.DepartmentId == classId && o.State < State.删除 && o.Type == DepartmentUserType.班级班主任)
     .Update(o => new DepartmentUser { State = State.历史 });
     var cc = new DepartmentUser
     {
         DepartmentId = classId,
         UserId = userId,
         State = State.启用,
         Ordinal = 0,
         Type = DepartmentUserType.班级班主任,
         Time = DateTime.Now,
         TopDepartmentId = campusId
     };
     HomoryContext.Value.DepartmentUser.AddOrUpdate(cc);
     HomoryContext.Value.SaveChanges();
     LogOp(OperationType.编辑);
     HomoryContext = new Lazy<Entities>(() => new Entities());
     RebindBatch();
     LoadCharging();
     view.Rebind();
 }
Пример #4
0
        public bool StudentMove(Entities db, Guid id, Guid sourceDepartmentId, Guid targetDepartmentId, Guid targetCampusId)
        {
            try
            {
                var relation = db.DepartmentUser.Where(o => o.UserId == id && o.DepartmentId == sourceDepartmentId && o.Type == DepartmentUserType.班级学生 && o.State == State.启用).Update(o =>
                new DepartmentUser { State = State.历史 });
                var newRelation = new DepartmentUser
                {
                    DepartmentId = targetDepartmentId,
                    UserId = id,
                    TopDepartmentId = targetCampusId,
                    Type = DepartmentUserType.班级学生,
                    State = State.启用,
                    Time = DateTime.Now,
                    Ordinal = 0
                };
                db.DepartmentUser.AddOrUpdate(newRelation);
                db.SaveChanges();

                return true;
            }
            catch
            {
                return false;
            }
        }