예제 #1
0
 private TicketInfo CreateTicket(User entity)
 {
     TicketInfo ticket = null;
     ticket = new TicketInfo();
     if (entity.Student != null)
     {
         ticket.ClassName = entity.Student.Class.ClassName;
     }
     ticket.LoginTime = DateTime.Now;
     ticket.UserInfo = entity;
     return ticket;
 }
예제 #2
0
        public bool AddUser(User user,Student student,Teacher teacher)
        {
            if(student!=null)
            entities.Students.AddObject(student);

            if(teacher !=null)
                entities.Teachers.AddObject(teacher);

            entities.Users.AddObject(user);
            if (entities.SaveChanges() > 0)
                return true;
            return false;
        }
예제 #3
0
 /// <summary>
 /// 复制
 /// </summary>
 public void Clone(User entity)
 {
     this.UserID = entity.UserID;
         this.Sex = entity.Sex;
         this.Realname = entity.Realname;
         this.Birthday = entity.Birthday;
         this.Email = entity.Email;
         this.Mobile = entity.Mobile;
         this.Address = entity.Address;
         this.Introduction = entity.Introduction;
         this.QQ = entity.QQ;
         this.Password = entity.Password;
         this.UserRoleID = entity.UserRoleID;
         this.UserRole = entity.UserRole;
 }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            UserBLL bll = new UserBLL();
            try
            {
                User itemUser = new User();
                Student itemStudent = null;
                Teacher itemTeacher = null;

                if (radStudent.IsChecked.Value)
                {
                    itemStudent = new Student();
                    itemStudent.SClassID = Convert.ToInt32(this.cboData.SelectedValue);
                    itemUser.UserRole = (int)ClassRoom.Enum.UserRoleTypeEnum.Student;
                    itemUser.Student = itemStudent;
                }

                if (radTeacher.IsChecked.Value)
                {
                    itemTeacher = new Teacher();
                    itemTeacher.CourseID = Convert.ToInt32(this.cboData.SelectedValue);
                    itemUser.UserRole = (int)ClassRoom.Enum.UserRoleTypeEnum.Teacher;
                    itemUser.Teacher = itemTeacher;
                    //TeacherBLL.AddTeacher(itemTeacher);
                }

                itemUser.Sex = this.radioButton1.IsChecked;
                itemUser.Realname = this.tbRealName.Text;
                itemUser.Email = this.tbEmail.Text;
                itemUser.Password = this.tbPassword.Text;

                bool result = bll.AddUser(itemUser, itemStudent, itemTeacher);

                if (result)
                {
                    MessageBox.Show("保存成功!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }
        }
 /// <summary>
 /// 用于向 Users EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToUsers(User user)
 {
     base.AddObject("Users", user);
 }
 /// <summary>
 /// 创建新的 User 对象。
 /// </summary>
 /// <param name="userID">UserID 属性的初始值。</param>
 /// <param name="password">Password 属性的初始值。</param>
 /// <param name="userRoleID">UserRoleID 属性的初始值。</param>
 public static User CreateUser(global::System.Int32 userID, global::System.String password, global::System.Int32 userRoleID)
 {
     User user = new User();
     user.UserID = userID;
     user.Password = password;
     user.UserRoleID = userRoleID;
     return user;
 }