Exemplo n.º 1
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                this.category.Name       = NativeRules.CheckString(txtName.Text.ToString().Trim(), "Nombre inválido", 1, 25);
                this.category.BlockedAge = Convert.ToInt32(txtAge.Text.ToString().Trim());
                this.category.Status     = (new StatusRepository()).FindStatusByCode(comboStatus.SelectedValue.ToString());

                (new CategoryRepository()).EditCategory(category);
                MessageBox.Show("La categoría se ha editado exitosamente!");
                this.btnBack_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                Entity.Category category = new Entity.Category
                {
                    Name       = NativeRules.CheckString(txtName.Text.ToString().Trim(), "Nombre inválido", 1, 25),
                    BlockedAge = Convert.ToInt32(txtAge.Text.ToString().Trim())
                };

                (new CategoryRepository()).AddCategory(category);
                MessageBox.Show("La categoría se ha creado exitosamente!");
                this.btnBack_Click(sender, e);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 3
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                Entity.Gender gender = new Entity.Gender
                {
                    Name         = NativeRules.CheckString(txtName.Text.ToString().Trim(), "Nombre inválido", 5, 50),
                    MediaType    = (new MediaTypeRepository()).FindById(int.Parse(comboMediaType.SelectedValue.ToString())),
                    ParentGender = (new GenderRepository()).FindById(int.Parse(comboParentGender.SelectedValue.ToString()))
                };

                (new GenderRepository()).Add(gender);
                MessageBox.Show("El género se ha creado exitosamente!");
                this.btnBack_Click(sender, e);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 4
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                this.ChangeFormStatus();
                var user = new AbstractUser();

                if (this.chkModerator.Checked)
                {
                    user = new Moderator();
                }
                else
                {
                    user = new Administrator();
                }

                user.Name        = NativeRules.CheckString(txtName.Text.ToString().Trim(), "Nombre inválido", 5, 50);
                user.LastName    = NativeRules.CheckString(txtLastName.Text.ToString().Trim(), "Apellido inválido", 5, 50);
                user.Email       = NativeRules.CheckString((new MailAddress(txtEmail.Text.ToString().Trim())).Address, "Email inválido", int.MinValue, 100);
                user.BornDate    = dateBornDate.Value;
                user.Gender      = radioF.Checked ? 'F' : radioM.Checked ? 'M' : 'O';
                user.Nationality = new NationRepository().GetNation(comboNationality.SelectedValue.ToString());
                user.Status      = new StatusRepository().FindStatusByCode("N");

                if (this.chkModerator.Checked)
                {
                    new ModeratorRepository().Add((Moderator)user);
                    MessageBox.Show("El Moderador se ha creado exitosamente!");
                }
                else
                {
                    new AdministratorRepository().Add((Administrator)user);
                    MessageBox.Show("El Administrador se ha creado exitosamente!");
                }
                this.btnBack_Click(sender, e);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            } finally
            {
                this.ChangeFormStatus();
            }
        }
Exemplo n.º 5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                this.user.Name        = NativeRules.CheckString(txtName.Text.ToString().Trim(), "Nombre inválido", 5, 50);
                this.user.LastName    = NativeRules.CheckString(txtLastName.Text.ToString().Trim(), "Apellido inválido", 5, 50);
                this.user.Email       = NativeRules.CheckString((new MailAddress(txtEmail.Text.ToString().Trim())).Address, "Email inválido", int.MinValue, 100);
                this.user.BornDate    = dateBornDate.Value;
                this.user.Gender      = radioF.Checked ? 'F' : radioM.Checked ? 'M' : 'O';
                this.user.Nationality = new NationRepository().GetNation(comboNationality.SelectedValue.ToString());
                this.user.Status      = new StatusRepository().FindStatusByCode(comboStatus.SelectedValue.ToString());

                new UserRepository().Edit(this.user);
                MessageBox.Show("El Usuario se ha editado exitosamente!");
                this.btnBack_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }