Ejemplo n.º 1
0
        private bool AddNewUser()
        {
            var isUserExist = new PersonQuery { IdNum = Id.Text }.GetByFilter().Any();
            if (isUserExist)
            {
                IdValidator.IsValid = false;
                return false;
            }

            var selected = PersonTypes.SelectedValue;

            switch (selected)
            {
                case "1":
                    {
                        var entity = new Entities.Child
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             PhoneNum = Phone.Text,
                                             Password = "******",
                                             Sensitivitieses = GetSensitivitieses()
                                         };

                        ChildEdit.Instance.Add(entity);
                        break;
                    }
                case "2":
                    {
                        var entity = new Entities.Teacher
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             Substitute =
                                                 Teachers.SelectedValue != ""
                                                     ? new TeachersQuery().Get(int.Parse(Teachers.SelectedValue))
                                                     : null,
                                             PhoneNum = Phone.Text,
                                             Seniority = Sen.Text != "" ? int.Parse(Sen.Text) : 0,
                                             Password = "******"
                                         };
                        TeacherEdit.Instance.Add(entity);
                        break;
                    }

                case "3":
                    {
                        var city = Enum.Parse(typeof(Entities.Cities), Cities.SelectedIndex.ToString(), true);

                        var entity = new Entities.Supervisor
                                         {
                                             IdNum = Id.Text,
                                             FirstName = FirstName.Text,
                                             LastName = LastName.Text,
                                             BirthDay = DateTime.Parse(BirthDate.Text),
                                             PhoneNum = Phone.Text,
                                             Password = "******",
                                             City = (Entities.Cities)city
                                         };
                        SupervisorEdit.Instance.Add(entity);
                        break;
                    }
            }
            return true;
        }
Ejemplo n.º 2
0
        private bool AddNewUser()
        {
            var isUserExist = new PersonQuery {
                IdNum = Id.Text
            }.GetByFilter().Any();

            if (isUserExist)
            {
                IdValidator.IsValid = false;
                return(false);
            }

            var selected = PersonTypes.SelectedValue;

            switch (selected)
            {
            case "1":
            {
                var entity = new Entities.Child
                {
                    IdNum           = Id.Text,
                    FirstName       = FirstName.Text,
                    LastName        = LastName.Text,
                    BirthDay        = DateTime.Parse(BirthDate.Text),
                    PhoneNum        = Phone.Text,
                    Password        = "******",
                    Sensitivitieses = GetSensitivitieses()
                };

                ChildEdit.Instance.Add(entity);
                break;
            }

            case "2":
            {
                var entity = new Entities.Teacher
                {
                    IdNum      = Id.Text,
                    FirstName  = FirstName.Text,
                    LastName   = LastName.Text,
                    BirthDay   = DateTime.Parse(BirthDate.Text),
                    Substitute =
                        Teachers.SelectedValue != ""
                                                     ? new TeachersQuery().Get(int.Parse(Teachers.SelectedValue))
                                                     : null,
                    PhoneNum  = Phone.Text,
                    Seniority = Sen.Text != "" ? int.Parse(Sen.Text) : 0,
                    Password  = "******"
                };
                TeacherEdit.Instance.Add(entity);
                break;
            }

            case "3":
            {
                var city = Enum.Parse(typeof(Entities.Cities), Cities.SelectedIndex.ToString(), true);

                var entity = new Entities.Supervisor
                {
                    IdNum     = Id.Text,
                    FirstName = FirstName.Text,
                    LastName  = LastName.Text,
                    BirthDay  = DateTime.Parse(BirthDate.Text),
                    PhoneNum  = Phone.Text,
                    Password  = "******",
                    City      = (Entities.Cities)city
                };
                SupervisorEdit.Instance.Add(entity);
                break;
            }
            }
            return(true);
        }