private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrWhiteSpace(NombresTextBox.Text))
            {
                MyErrorProvider.SetError(NombresTextBox, "El campo Nombres no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(ApellidosTextBox.Text))
            {
                MyErrorProvider.SetError(ApellidosTextBox, "El campo Apellidos no puede estar vacio");
                ApellidosTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(TelefonoMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(TelefonoMaskedTextBox, "El campo Telefono no puede estar vacio");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CelularMaskedTextBox, "El campo Celular no puede estar vacio");
                CelularMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El campo Email no puede estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                MyErrorProvider.SetError(DireccionTextBox, "El campo Direccion no puede estar vacio");
                DireccionTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(NombreUsuarioTextBox.Text))
            {
                MyErrorProvider.SetError(NombreUsuarioTextBox, "El campo Nobre Usuario no puede estar vacio");
                NombreUsuarioTextBox.Focus();
                paso = false;
            }

            if (ConfirmarClaveTextBox.Text != ClaveUsuarioTextBox.Text)
            {
                MyErrorProvider.SetError(ConfirmarClaveTextBox, "Las claves no coinciden");
                ConfirmarClaveTextBox.Focus();
                paso = false;
            }
            return(paso);
        }
Exemplo n.º 2
0
        private bool IsFormValidate()
        {
            if (FullNameTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Full Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FullNameTextBox.Clear();
                FullNameTextBox.Focus();
                return(false);
            }
            if (FatherNameTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Father Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FatherNameTextBox.Clear();
                FatherNameTextBox.Focus();
                return(false);
            }
            if (MotherNameTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Mother Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MotherNameTextBox.Clear();
                MotherNameTextBox.Focus();
                return(false);
            }
            if (AddressTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Address is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                AddressTextBox.Clear();
                AddressTextBox.Focus();
                return(false);
            }
            if (EmailTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Email Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                EmailTextBox.Clear();
                EmailTextBox.Focus();
                return(false);
            }
            if (MobileTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Mobile number is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MobileTextBox.Clear();
                MobileTextBox.Focus();
                return(false);
            }
            if (BloodGroupTextBox.Text.Trim() == "")
            {
                MessageBox.Show("Blood Group is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BloodGroupTextBox.Clear();
                BloodGroupTextBox.Focus();
                return(false);
            }

            if (GenderComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Gender is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (BranchComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Branch is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }
        private bool Validar()
        {
            bool paso = true;

            MyErrorProvider.Clear();
            if (string.IsNullOrWhiteSpace(NombresTextBox.Text))
            {
                MyErrorProvider.SetError(NombresTextBox, "El campo Nombres no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }


            if (string.IsNullOrWhiteSpace(GrupoSangineoComboBox.Text))
            {
                MyErrorProvider.SetError(GrupoSangineoComboBox, "El campo GrupoSangineo no puede estar vacio");
                GrupoSangineoComboBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(CedulaMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CedulaMaskedTextBox, "El campo Cedula no puede estar vacio");
                CedulaMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(TelefonoMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(TelefonoMaskedTextBox, "El campo Telefono no puede estar vacio");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CelularMaskedTextBox, "El campo Celular no puede estar vacio");
                CelularMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(SeguroMedicoComboBox.Text))
            {
                MyErrorProvider.SetError(SeguroMedicoComboBox, "El campo Seguro Medico no puede estar vacio");
                SeguroMedicoComboBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                MyErrorProvider.SetError(DireccionTextBox, "El campo Direccion no puede estar vacio");
                DireccionTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El campo Seguro Medico no puede estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ObservacionTextBox.Text))
            {
                MyErrorProvider.SetError(ObservacionTextBox, "El campo Seguro Medico no puede estar vacio");
                ObservacionTextBox.Focus();
                paso = false;
            }
            if (FechaNacimientoDateTimePicker.Value > FechaIngresoDateTimePicker.Value)
            {
                MyErrorProvider.SetError(FechaNacimientoDateTimePicker, "No se puede registrar esta fecha.");
                FechaNacimientoDateTimePicker.Focus();
                paso = false;
            }
            if (FechaIngresoDateTimePicker.Value > DateTime.Now)
            {
                MyErrorProvider.SetError(FechaIngresoDateTimePicker, "No se puede registrar esta fecha.");
                FechaIngresoDateTimePicker.Focus();
                paso = false;
            }


            return(paso);
        }
        //Validacion de los campos de la clase
        public bool Validar()
        {
            bool paso = true;

            ErrorProvider.Clear();
            if (NombresTextBox.Text == string.Empty)
            {
                ErrorProvider.SetError(NombresTextBox, "El campo no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }
            if (DireccionTextBox.Text == string.Empty)
            {
                ErrorProvider.SetError(DireccionTextBox, "La direccion no puede esta vacia");
                DireccionTextBox.Focus();
                paso = false;
            }
            if (EmailTextBox.Text == string.Empty)
            {
                ErrorProvider.SetError(EmailTextBox, "El Email no puede esta vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(NombresTextBox.Text))
            {
                ErrorProvider.SetError(NombresTextBox, "El campo no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                ErrorProvider.SetError(DireccionTextBox, "La direccion no puede esta vacia");
                DireccionTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                ErrorProvider.SetError(EmailTextBox, "El Email no puede esta vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (CedulaMaskedTextBox.MaskFull == false)
            {
                ErrorProvider.SetError(CedulaMaskedTextBox, "No puede haber espacios en blanco");
                CedulaMaskedTextBox.Focus();
                paso = false;
            }
            if (TelefonoMaskedTextBox.MaskFull == false)
            {
                ErrorProvider.SetError(TelefonoMaskedTextBox, "No puede haber espacios en blanco");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }
            if (ValidarEmail(EmailTextBox.Text) == false)
            {
                ErrorProvider.SetError(EmailTextBox, "Correo invalido");
                EmailTextBox.Focus();
                paso = false;
            }
            if (MasculinoRadioButton.Checked == false && FemeninoRadioButton.Checked == false)
            {
                ErrorProvider.SetError(FemeninoRadioButton, "Es campo sexo no puede esta vacio");
                FemeninoRadioButton.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 5
0
        private bool Validar()
        {
            bool paso = true;

            if (NombreUsuarioTextBox.Text == string.Empty)
            {
                MyErrorProvider.SetError(NombreUsuarioTextBox, "El campo nombre no puede estar vacio");
                NombreUsuarioTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El Email no puede estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(AliasTextBox.Text))
            {
                MyErrorProvider.SetError(AliasTextBox, "El campo Alias no puede estar vacio");
                AliasTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(RolComboBox.Text))
            {
                MyErrorProvider.SetError(RolComboBox, "Debe agregar un rol especifico");
                RolComboBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ClaveTextBox.Text))
            {
                MyErrorProvider.SetError(ClaveTextBox, "Debe asignar una clave a su usuario");
                ClaveTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ConfirmarClaveTextBox.Text))
            {
                MyErrorProvider.SetError(ConfirmarClaveTextBox, "Debe confirmar la clave");
                ConfirmarClaveTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(Fecha.Text))
            {
                MyErrorProvider.SetError(Fecha, "Debe agregar una fecha de registro");
                Fecha.Focus();
                paso = false;
            }
            if (ClaveTextBox.Text != ConfirmarClaveTextBox.Text)
            {
                MyErrorProvider.SetError(ConfirmarClaveTextBox, "Las contrseñas deben ser iguales.");
                ConfirmarClaveTextBox.Focus();
                MyErrorProvider.SetError(ClaveTextBox, "Las contraseñas deben ser iguales.");
                ClaveTextBox.Focus();
                paso = false;
            }
            if (UsuariosBLL.ExisteAlias(AliasTextBox.Text))
            {
                MyErrorProvider.SetError(AliasTextBox, "Los Alias no pueden repetirse!");
                AliasTextBox.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 6
0
        private bool Validar()
        {
            bool paso = true;

            if (UsuarioIdTextBox.Text == string.Empty)
            {
                MessageBox.Show("UsuarioId Vacio");
                UsuarioIdTextBox.Focus();
                paso = false;
            }
            else if (NombresTextBox.Text == string.Empty)
            {
                MessageBox.Show("Nombres Vacio");
                NombresTextBox.Focus();
                paso = false;
            }
            else if (TelefonoTextBox.Text == string.Empty)
            {
                MessageBox.Show("Telefono Vacio");
                TelefonoTextBox.Focus();
                paso = false;
            }
            else if (CelularTextBox.Text == string.Empty)
            {
                MessageBox.Show("Celular Vacio");
                CelularTextBox.Focus();
                paso = false;
            }
            else if (EmailTextBox.Text == string.Empty)
            {
                MessageBox.Show("Email Vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            else if (SexoComboBox.SelectedItem == null)
            {
                MessageBox.Show("Sexo Vacio");
                SexoComboBox.Focus();
                paso = false;
            }
            else if (CedulaTextBox.Text == string.Empty)
            {
                MessageBox.Show("Cedula Vacia");
                CedulaTextBox.Focus();
                paso = false;
            }
            else if (DireccionTextBox.Text == string.Empty)
            {
                MessageBox.Show("Direccion Vacio");
                DireccionTextBox.Focus();
                paso = false;
            }
            else if (TipoUsuarioComboBox.SelectedItem == null)
            {
                MessageBox.Show("Tipo de Usuario Vacio");
                TipoUsuarioComboBox.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e) //add guest
        {
            if ((myState == FormState.Add) || ((myState == FormState.WhileBooking) && button2.Text == "Add Guest") ||
                (myState == FormState.Edit))
            {
                Regex validateEmail = new Regex(@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                                                @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$");


                //https://msdn.microsoft.com/en-us/library/01escwtf(v=vs.110).aspx



                Regex testForNonNumeric = new Regex(@"\D");

                Regex testForLetters = new Regex(@"^[a-zA-Z ]+$"); // @"^[a-zA-Z ]+$" for space character



                if (FirstNameTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter First Name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //https://msdn.microsoft.com/en-us/library/system.windows.forms.messageboxicon(v=vs.110).aspx
                    FirstNameTextBox.Focus(); //focuses on text box with error

                    return;
                }

                else if (LastNameTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Last Name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LastNameTextBox.Focus();
                    return;
                }



                else if (TelephoneTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter Your Telephone Number", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (TelephoneTextBox.TextLength < 10)
                {
                    MessageBox.Show("Telephone number must contains 10 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (TelephoneTextBox.TextLength > 10)
                {
                    MessageBox.Show("Telephone number must contains 10 digits", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (testForNonNumeric.IsMatch(TelephoneTextBox.Text))
                {
                    MessageBox.Show("Telephone number must contain digits only", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TelephoneTextBox.Focus();
                    return;
                }

                else if (EmailTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter An Email Address", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTextBox.Focus();
                    return;
                }

                else if (!validateEmail.IsMatch(EmailTextBox.Text))
                {
                    MessageBox.Show("Invalid Email Address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    EmailTextBox.Focus();
                    return;
                }


                else
                {
                    //go to next form
                    if (myState == FormState.Add)
                    {
                        guest = PopulateObject();
                        guestController.ADD(guest);
                        MessageBox.Show("Guest successfully added", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        ClearAll();
                        this.Hide();
                    }
                    if (myState == FormState.WhileBooking)
                    {
                        guest = PopulateObject();
                        aBooking.DepositPaid = "false";
                        aBooking.GuestID     = guest.GuestID;

                        bookingController.ADD(aBooking);
                        guestController.ADD(guest);
                        MessageBox.Show("Guest successfully added and booking successfully made", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        //would they like to pay now
                        DialogResult result = MessageBox.Show("Would you like to pay now", "Pay now?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            PaymentDetailsForm paymentDetailsForm = new PaymentDetailsForm(paymentController,
                                                                                           aBooking, guest, bookingController);
                            paymentDetailsForm.MdiParent     = (Home)this.MdiParent;    // Setting the MDI Parent
                            paymentDetailsForm.StartPosition = FormStartPosition.CenterParent;
                            this.Hide();
                            paymentDetailsForm.Show();
                        }
                        else
                        {
                            //go straight to the email

                            ConfirmationForm cf = new ConfirmationForm(guest, aBooking);

                            cf.StartPosition = FormStartPosition.CenterParent;
                            cf.Show();
                            this.Hide();
                        }
                        ClearAll();
                    }
                    if (myState == FormState.Edit)
                    {
                        Guest g = new Guest();
                        g.GuestID   = textBox1.Text;
                        g.FirstName = FirstNameTextBox.Text;
                        g.Surname   = LastNameTextBox.Text;

                        g.TelephoneNumber = TelephoneTextBox.Text;
                        g.EmailAddress    = EmailTextBox.Text;


                        DialogResult result = MessageBox.Show("Are you sure you want to edit guest", "Edit Guest", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        //populate the text boxes
                        if (result == DialogResult.Yes)
                        {
                            //we must delete the guest tell them guest has been successfully deleted
                            guestController.Edit(g);
                            MessageBox.Show("Guest successfully editted", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ClearAll();

                            this.Hide();
                        }
                        else
                        {
                            //reset the controls
                            showRequiredFields(FormState.Edit);
                        }
                    }
                }
            }

            else if (((myState == FormState.WhileBooking) && (button2.Text == "Verify Guest")) || (myState == FormState.Delete))
            {
                if (GuestIDTextBox.Text == "")
                {
                    MessageBox.Show("Please Enter A Guest ID to search for", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    GuestIDTextBox.Focus();
                    return;
                }
                else if (guestController.FindByGuestID(GuestIDTextBox.Text) == null)
                {
                    MessageBox.Show("Guest not found", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    GuestIDTextBox.Focus();
                    return;
                }
                else
                {
                    Guest temp = guestController.FindByGuestID(GuestIDTextBox.Text);
                    FirstNameTextBox.Text = temp.FirstName;
                    LastNameTextBox.Text  = temp.Surname;

                    TelephoneTextBox.Text = temp.TelephoneNumber;

                    EmailTextBox.Text   = temp.EmailAddress;
                    GuestIDTextBox.Text = temp.GuestID;


                    if (myState == FormState.WhileBooking)
                    {
                        MessageBox.Show("Guest has been verified", "Verified", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //add the booking
                        aBooking.GuestID     = temp.GuestID;
                        aBooking.DepositPaid = "false";
                        bookingController.ADD(aBooking);
                        MessageBox.Show("Booking has been successfully made", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);


                        //populate the text boxes
                        DialogResult result = MessageBox.Show("Would you like to pay now", "Pay now?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            PaymentDetailsForm paymentDetailsForm = new PaymentDetailsForm(paymentController, aBooking, temp, bookingController);
                            paymentDetailsForm.MdiParent     = (Home)this.MdiParent;        // Setting the MDI Parent
                            paymentDetailsForm.StartPosition = FormStartPosition.CenterParent;
                            this.Hide();
                            paymentDetailsForm.Show();
                        }
                        else
                        {
                            //go straight to the email

                            ConfirmationForm cf = new ConfirmationForm(temp, aBooking);

                            cf.StartPosition = FormStartPosition.CenterParent;
                            cf.Show();
                            this.Hide();
                        }
                    }
                    if (myState == FormState.Delete)
                    {
                        DialogResult result = MessageBox.Show("Are you sure you want to delete guest", "Delete guest", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        //populate the text boxes
                        if (result == DialogResult.Yes)
                        {
                            //we must delete the guest tell them guest has been successfully deleted
                            guestController.Delete(temp);
                            MessageBox.Show("Guest has been deleted", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Hide();
                        }
                        else
                        {
                            //reset the controls
                            showRequiredFields(FormState.Delete);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            bool paso = false;
            {
                if (!Validar())
                {
                    return;
                }
                if (ClienteIdTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Cliente Id) está vacío.\n\nAsigne un Id al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    ClienteIdTextBox.Text = "0";
                    ClienteIdTextBox.Focus();
                    ClienteIdTextBox.SelectAll();
                    return;
                }
                if (UsuarioIdComboBox.Text == string.Empty)
                {
                    MessageBox.Show("El Campo (Usuario Id) está vacío.\n\nPorfavor, Seleccione su Nombre de Usuario.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    UsuarioIdComboBox.IsDropDownOpen = true;
                    return;
                }
                if (NombresTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Nombres) está vacío.\n\nAsigne un Nombre al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    NombresTextBox.Clear();
                    NombresTextBox.Focus();
                    return;
                }

                if (ApellidoTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Apellidos) está vacío.\n\nAsigne un Apellidos al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    ApellidoTextBox.Clear();
                    ApellidoTextBox.Focus();
                    return;
                }

                if (CedulaTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Cédula) está vacío.\n\nAsigne una Cedula al Cedula.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CedulaTextBox.Text = "0";
                    CedulaTextBox.Focus();
                    CedulaTextBox.SelectAll();
                    return;
                }
                if (CedulaTextBox.Text.Length != 11)
                {
                    MessageBox.Show($"La Cédula ({CedulaTextBox.Text}) no es válida.\n\nLa cedula debe tener 11 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CedulaTextBox.Focus();
                    return;
                }

                if (FemeninoRadioButton.IsChecked.Value == false && MasculinoRadioButton.IsChecked.Value == false)
                {
                    MessageBox.Show("El Campo (Género) está vacío.\n\nAsigne un Genero al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    FemeninoRadioButton.Focus();
                    return;
                }

                if (TelefonoTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Teléfono) está vacío.\n\nAsigne un Teléfono al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    TelefonoTextBox.Text = "0";
                    TelefonoTextBox.Focus();
                    TelefonoTextBox.SelectAll();
                    return;
                }
                if (TelefonoTextBox.Text.Length != 10)
                {
                    MessageBox.Show($"El Teféfono ({TelefonoTextBox.Text}) no es válido.\n\nEl Teléfono debe tener 10 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    TelefonoTextBox.Focus();
                    return;
                }

                if (FechaDatePicker.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Fecha Nacimiento) está vacío.\n\nAsigne una Fecha de Nacimiento al Nacimiento.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    FechaDatePicker.Focus();
                    return;
                }

                if (DireccionTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Dirección) está vacío.\n\nAsigne una Dirección al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    DireccionTextBox.Clear();
                    DireccionTextBox.Focus();
                    return;
                }
                if (CelularTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Teléfono) está vacío.\n\nAsigne un Teléfono al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CelularTextBox.Text = "0";
                    CelularTextBox.Focus();
                    CelularTextBox.SelectAll();
                    return;
                }
                if (CelularTextBox.Text.Length != 10)
                {
                    MessageBox.Show($"El Celular ({CelularTextBox.Text}) no es válido.\n\nEl Celular debe tener 10 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    CelularTextBox.Focus();
                    return;
                }

                if (EmailTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Email) está vacío.\n\nAsigne una Correo al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    EmailTextBox.Clear();
                    EmailTextBox.Focus();
                    return;
                }

                if (EstadoCivilTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Estado Civil) está vacío.\n\nAsigne un Estado Civil al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    EstadoCivilTextBox.Clear();
                    EstadoCivilTextBox.Focus();
                    return;
                }
                if (OcupacionTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Nombres) está vacío.\n\nAsigne un Nombre al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    OcupacionTextBox.Clear();
                    OcupacionTextBox.Focus();
                    return;
                }
                if (ReligionTextBox.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("El Campo (Nombres) está vacío.\n\nAsigne un Nombre al Cliente.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                    ReligionTextBox.Clear();
                    ReligionTextBox.Focus();
                    return;
                }



                if (!editando)
                {
                    paso = ClientesBLL.Guardar(clientes);
                }
                else
                {
                    paso = ClientesBLL.Modificar(clientes);
                }

                if (paso)
                {
                    Limpiar();
                    MessageBox.Show("Transacción Exitosa", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    MessageBox.Show("Transacción Fallida", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemplo n.º 9
0
 private void EndViewOnLoaded(object sender, RoutedEventArgs e)
 {
     EmailTextBox.Focus();
     EmailTextBox.SelectAll();
 }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            password = ConfirmPassword.Text;
            //string encryptedPassword = Encrypt(password);
            int    phoneNumber = PhoneText.Text.Length;
            int    passLength  = PasswordText.Text.Length;
            string gender      = "";

            if (MaleButton.Checked)
            {
                gender = MaleButton.Text;
            }
            if (FemaleButton.Checked)
            {
                gender = FemaleButton.Text;
            }
            //this.Hide();
            //Home ss = new Home();
            // ss.Show();

            //check field empty or not
            if (string.IsNullOrEmpty(NameTextBox.Text) == true)
            {
                MessageBox.Show("Please enter First Name");
                NameTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(LastNameTextBox.Text) == true)
            {
                MessageBox.Show("Please enter Last Name");
                LastNameTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(EmailTextBox.Text) == true)
            {
                MessageBox.Show("Please enter Email");
                EmailTextBox.Focus();
            }
            else if (Regex.IsMatch(EmailTextBox.Text, emailValStr) == false)
            {
                MessageBox.Show("Invalid email!!");
                EmailTextBox.Focus();
            }

            else if (string.IsNullOrEmpty(StudentIDTextBox.Text) == true)
            {
                MessageBox.Show("Please enter your ID");
                StudentIDTextBox.Focus();
            }
            else if (string.IsNullOrEmpty(PhoneText.Text) == true)
            {
                MessageBox.Show("Please enter Phone Number");
                PhoneText.Focus();
            }

            else if (phoneNumber != 11)
            {
                MessageBox.Show("Please enter valid phone number");
                PhoneText.Focus();
            }
            else if (string.IsNullOrEmpty(gender) == true)
            {
                MessageBox.Show("Please select gender");
                ConfirmPassword.Focus();
            }
            else if (string.IsNullOrEmpty(PasswordText.Text) == true)
            {
                MessageBox.Show("Please type Password");
                PasswordText.Focus();
            }
            else if (passLength <= 8)
            {
                MessageBox.Show(Convert.ToString(passLength));
                MessageBox.Show("Your password should contain minimum 8 characters or numbers");
                PasswordText.Focus();
            }
            else if (string.IsNullOrEmpty(ConfirmPassword.Text) == true)
            {
                MessageBox.Show("Please type Password again");
                ConfirmPassword.Focus();
            }
            else if (PasswordText.Text != ConfirmPassword.Text)
            {
                MessageBox.Show("You typed the wrond password");
                PasswordText.Focus();
            }

            else
            {
                // conn.ConnectionString = @"Data Source=LAPTOP-UDPCMQEF;Initial Catalog=LibraryManagementSystem;Integrated Security=True";
                //  conn.Open();


                SqlCommand cmd = new SqlCommand("insert into Person" + "(first_name,last_name,password,email,student_id,gender,contact_no) values (@first_name,@last_name,aes_encrypt(@password, 'key'),@email,@student_id,@gender,@contact_no)", connDB.getConn());
                cmd.Parameters.AddWithValue("@first_name", NameTextBox.Text);
                cmd.Parameters.AddWithValue("@last_name", LastNameTextBox.Text);
                cmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
                cmd.Parameters.AddWithValue("@student_id", StudentIDTextBox.Text);
                cmd.Parameters.AddWithValue("@gender", gender);
                cmd.Parameters.AddWithValue("@contact_no", PhoneText.Text);
                cmd.Parameters.AddWithValue("@password", password);
                cmd.ExecuteNonQuery();
                MessageBox.Show("You are registered now");
            }
        }
Exemplo n.º 11
0
 // save button clicked
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (FirstNameTextBox.Text == "" || FirstNameTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <First Name> field and entered only letters (a-z, A-Z)", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         FirstNameTextBox.Focus();
     }
     else if (LastNameTextBox.Text == "" || LastNameTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <Last Name> field and entered only letters (a-z, A-Z)", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         LastNameTextBox.Focus();
     }
     else if (PhoneTextBox.Text == "" || PhoneTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <Phone Number> field and input is in correct format (XXXXXXXXXX or XXX XXX XXXX or XXX-XXX-XXXX)", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         PhoneTextBox.Focus();
     }
     else if (EmailTextBox.Text == "" || EmailTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <Email> field and provided valid Email", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         EmailTextBox.Focus();
     }
     else if (CityTextBox.Text == "" || CityTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <City> field and provided valid input", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         CityTextBox.Focus();
     }
     else if (StateTextBox.Text == "" || StateTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <State> field and provided valid input", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         StateTextBox.Focus();
     }
     else if (ZipTextBox.Text == "" || ZipTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <Zip> field and input is in valid format (XXXXX)", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         ZipTextBox.Focus();
     }
     else if (AddressTextBox.Text == "" || AddressTextBox.ForeColor == Color.Red)
     {
         MessageBox.Show("Make sure you filled out <Address> field and provided valid input", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error);
         AddressTextBox.Focus();
     }
     else
     {
         string cmdText = "select count(*) from Customers where FirstName = @firstName and LastName = @lastName and Email = @email and Phone = @phone and Address = @address and City = @city and State = @state and Zip = @zip";
         scmd = new SqlCommand(cmdText, connection);
         connection.Open();
         scmd.Parameters.AddWithValue("@firstName", FirstNameTextBox.Text);
         scmd.Parameters.AddWithValue("@lastName", LastNameTextBox.Text);
         scmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
         scmd.Parameters.AddWithValue("@phone", PhoneTextBox.Text);
         scmd.Parameters.AddWithValue("@address", AddressTextBox.Text);
         scmd.Parameters.AddWithValue("@city", CityTextBox.Text);
         scmd.Parameters.AddWithValue("@state", StateTextBox.Text);
         scmd.Parameters.AddWithValue("@zip", ZipTextBox.Text);
         int exists = (int)scmd.ExecuteScalar(); // check if entered isnb is unique
         connection.Close();
         // if user clicks new customer button, add new customer mode is on
         if (addNewCustomerMode)
         {
             if (exists > 0)
             {
                 MessageBox.Show("Customer Already Exists", "Addition of existing Customer", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 DialogResult save = MessageBox.Show("Do you want to save the Customer?", "Add New Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                 if (save == DialogResult.Yes)
                 {
                     scmd = new SqlCommand("SET IDENTITY_INSERT Customers OFF; insert into Customers(FirstName, LastName, Email, Phone, Address, City, State, Zip) Values(@firstName, @lastName, @email, @phone, @address, @city, @state, @zip)", connection);
                     connection.Open();
                     scmd.Parameters.AddWithValue("@firstName", FirstNameTextBox.Text);
                     scmd.Parameters.AddWithValue("@lastName", LastNameTextBox.Text);
                     scmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
                     scmd.Parameters.AddWithValue("@phone", PhoneTextBox.Text);
                     scmd.Parameters.AddWithValue("@address", AddressTextBox.Text);
                     scmd.Parameters.AddWithValue("@state", CityTextBox.Text);
                     scmd.Parameters.AddWithValue("@city", CityTextBox.Text);
                     scmd.Parameters.AddWithValue("@zip", ZipTextBox.Text);
                     scmd.ExecuteNonQuery();
                     connection.Close();
                     MessageBox.Show("The Customer Was Added Successfully.");
                     DisplayCustomers(); // refresh combobox values
                     ResetAll();
                     CustomerComboBox.Enabled = true;
                 }
             }
         }
         // if user chooses customer from combobox, update customer mode is on
         if (updateCustomerMode)
         {
             if (exists > 0)
             {
                 MessageBox.Show("You haven't modified anything.", "Nothing to update", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 DialogResult save = MessageBox.Show("Do you want to update the Customer?", "Update Existing Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                 if (save == DialogResult.Yes)
                 {
                     cmdText = "update Customers set FirstName = @firstName, LastName = @lastName, Email = @email, Phone = @phone, Address = @address, City = @city, State = @state, Zip = @zip where ID = @customerID";
                     scmd    = new SqlCommand(cmdText, connection);
                     connection.Open();
                     scmd.Parameters.AddWithValue("@customerID", customerID);
                     scmd.Parameters.AddWithValue("@firstName", FirstNameTextBox.Text);
                     scmd.Parameters.AddWithValue("@lastName", LastNameTextBox.Text);
                     scmd.Parameters.AddWithValue("@email", EmailTextBox.Text);
                     scmd.Parameters.AddWithValue("@phone", PhoneTextBox.Text);
                     scmd.Parameters.AddWithValue("@address", AddressTextBox.Text);
                     scmd.Parameters.AddWithValue("@city", CityTextBox.Text);
                     scmd.Parameters.AddWithValue("@state", StateTextBox.Text);
                     scmd.Parameters.AddWithValue("@zip", ZipTextBox.Text);
                     scmd.ExecuteNonQuery();
                     connection.Close();
                     MessageBox.Show("The Customer Was Updated Successfully.");
                     DisplayCustomers(); // refresh combobox values
                     ResetAll();
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrEmpty(FechaIngresoDateTimePicker.Text))
            {
                paso = false;
                FechaIngresoDateTimePicker.Focus();
            }

            if (string.IsNullOrEmpty(FechaNacimientoDateTimePicker.Text))
            {
                paso = false;
                FechaNacimientoDateTimePicker.Focus();
            }

            if (string.IsNullOrEmpty(SueldoTextBox.Text))
            {
                paso = false;
                SueldoTextBox.Focus();
            }


            if (string.IsNullOrEmpty(CargoTextBox.Text.Replace("-", "")))
            {
                paso = false;
                CargoTextBox.Focus();
            }

            if (!EmailValido(EmailTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Email No Valido !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
            }

            if (!NumeroValido(CelularTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Celular No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
            }

            if (!NumeroValido(TelefonoTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Teléfono No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
            }

            if (string.IsNullOrEmpty(DireccionTextBox.Text))
            {
                paso = false;
                DireccionTextBox.Focus();
            }

            if (!CedulaValida(CedulaTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Cédula No Valida, Debe introducir solo números !!!\n Introducca la Cédula sin guiones.", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                CedulaTextBox.Focus();
            }

            if (string.IsNullOrEmpty(ApellidosTextBox.Text))
            {
                paso = false;
                ApellidosTextBox.Focus();
            }

            if (string.IsNullOrEmpty(NombresTextBox.Text))
            {
                paso = false;
                NombresTextBox.Focus();
            }
            return(paso);
        }
Exemplo n.º 13
0
        private bool Validar()
        {
            bool paso = true;

            MyErrorProvider.Clear();
            if (string.IsNullOrWhiteSpace(NombresTextBox.Text))
            {
                MyErrorProvider.SetError(NombresTextBox, "El campo Nombres no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }

            /*if (MasculinoRadioButton.Checked == false   || FemeninoRadioButton.Checked == false)
             * {
             *  MyErrorProvider.SetError(FemeninoRadioButton, "Seleccione una Sexo");
             *  MasculinoRadioButton.Focus();
             *  FemeninoRadioButton.Focus();
             *  paso = false;
             * }*/
            if (string.IsNullOrWhiteSpace(GrupoSangineoComboBox.Text))
            {
                MyErrorProvider.SetError(GrupoSangineoComboBox, "El campo GrupoSangineo no puede estar vacio");
                GrupoSangineoComboBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(CedulaMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CedulaMaskedTextBox, "El campo Cedula no puede estar vacio");
                CedulaMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(TelefonoMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(TelefonoMaskedTextBox, "El campo Telefono no puede estar vacio");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text))
            {
                MyErrorProvider.SetError(CelularMaskedTextBox, "El campo Celular no puede estar vacio");
                CelularMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(SeguroMedicoComboBox.Text))
            {
                MyErrorProvider.SetError(SeguroMedicoComboBox, "El campo Seguro Medico no puede estar vacio");
                SeguroMedicoComboBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                MyErrorProvider.SetError(DireccionTextBox, "El campo Direccion no puede estar vacio");
                DireccionTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El campo Seguro Medico no puede estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ObservacionTextBox.Text))
            {
                MyErrorProvider.SetError(ObservacionTextBox, "El campo Seguro Medico no puede estar vacio");
                ObservacionTextBox.Focus();
                paso = false;
            }


            return(paso);
        }
Exemplo n.º 14
0
        private bool Validar()
        {
            bool paso = true;

            MyerrorProvider.Clear();

            if (string.IsNullOrWhiteSpace(MatriculamaskedTextBox.Text.Replace("-", "")))
            {
                MyerrorProvider.SetError(MatriculamaskedTextBox, "El campo Matricula no puede estar vacio");
                MatriculamaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(NombreTextBox.Text))
            {
                MyerrorProvider.SetError(NombreTextBox, "El campo Nombre no puede estar vacio");
                NombreTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(ApellidoTextBox.Text))
            {
                MyerrorProvider.SetError(ApellidoTextBox, "El campo Apellido no puede estar vacio");
                ApellidoTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CedulamaskedTextBox.Text.Replace("-", "")))
            {
                MyerrorProvider.SetError(CedulamaskedTextBox, "El campo Cedula no puede estar vacio");
                CedulamaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(TelefonomaskedTextBox.Text.Replace("-", "")))
            {
                MyerrorProvider.SetError(TelefonomaskedTextBox, "El campo Telefono no puede estar vacio");
                TelefonomaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CelularmaskedTextBox.Text.Replace("-", "")))
            {
                MyerrorProvider.SetError(CelularmaskedTextBox, "El campo Celular no puede estar vacio");
                CelularmaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyerrorProvider.SetError(EmailTextBox, "El campo Email no puede estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(FechaNacimientoDateTimePicker.Text))
            {
                MyerrorProvider.SetError(FechaNacimientoDateTimePicker, "El campo Fecha de nacimiento no puede estar vacio");
                FechaNacimientoDateTimePicker.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(SexoComboBox.Text))
            {
                MyerrorProvider.SetError(SexoComboBox, "El campo Sexo no puede estar vacio");
                SexoComboBox.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 15
0
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrWhiteSpace(UsuarioTextBox.Text))
            {
                MyErrorProvider.SetError(UsuarioTextBox, "El campo Usuario no puede estar vacio.");
                UsuarioTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(ContrasenaTextBox.Text))
            {
                MyErrorProvider.SetError(ContrasenaTextBox, "El campo Contraseña no puede estar vacio.");
                ContrasenaTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(NombreTextBox.Text))
            {
                MyErrorProvider.SetError(NombreTextBox, "El campo Nombres no puede estar vacio.");
                NombreTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(ApellidoTextBox.Text))
            {
                MyErrorProvider.SetError(ApellidoTextBox, "El campo Apellidos no puede estar vacio.");
                ApellidoTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(TelefonoMaskedTextBox.Text.Replace("-", "")))
            {
                MyErrorProvider.SetError(TelefonoMaskedTextBox, "El campo Telefono no puede estar vacio.");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text.Replace("-", "")))
            {
                MyErrorProvider.SetError(CelularMaskedTextBox, "El campo Celular no puede estar vacio.");
                CelularMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El campo Email no puede estar vacio.");
                EmailTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                MyErrorProvider.SetError(DireccionTextBox, "El campo Direccion no puede estar vacio.");
                DireccionTextBox.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 16
0
        public bool ValidateEdition()
        {
            String errors      = "";
            String line        = "";
            bool   focusSetted = false;

            if (String.IsNullOrWhiteSpace(NameTextBox.Text) && String.IsNullOrWhiteSpace(FirstNameTextBox.Text))
            {
                errors += line + "Name and first name can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    if (String.IsNullOrWhiteSpace(NameTextBox.Text))
                    {
                        NameTextBox.Focus();
                        NameTextBox.SelectAll();
                    }
                    else
                    {
                        FirstNameTextBox.Focus();
                        FirstNameTextBox.SelectAll();
                    }
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                //errors += line + "Email can't be empty.";
                //line = "\n";
                //if (!focusSetted)
                //{
                //    EmailTextBox.Focus();
                //    EmailTextBox.SelectAll();
                //    focusSetted = true;
                //}
            }
            else if (!UserUtil.validateEmail(EmailTextBox.Text))
            {
                errors += line + "Wrong email format.";
                line    = "\n";
                if (!focusSetted)
                {
                    EmailTextBox.Focus();
                    EmailTextBox.SelectAll();
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(LoginTextBox.Text))
            {
                errors += line + "Login can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    LoginTextBox.Focus();
                    LoginTextBox.SelectAll();
                    focusSetted = true;
                }
            }

            if (String.IsNullOrWhiteSpace(PasswordTextBox.Password))
            {
                errors += line + "Password can't be empty.";
                line    = "\n";
                if (!focusSetted)
                {
                    PasswordTextBox.Focus();
                    PasswordTextBox.SelectAll();
                    focusSetted = true;
                }
            }
            else if (!Util.UserUtil.validatePassword(PasswordTextBox.Password, ConfirmPasswordTextBox.Password))
            {
                errors += line + "Password does not match.";
                line    = "\n";
                if (!focusSetted)
                {
                    ConfirmPasswordTextBox.Focus();
                    ConfirmPasswordTextBox.SelectAll();
                    focusSetted = true;
                }
            }
            bool isValid = String.IsNullOrWhiteSpace(errors);

            this.Console.Text       = errors;
            this.Console.Visibility = isValid ? Visibility.Collapsed : Visibility.Visible;
            return(isValid);
        }
Exemplo n.º 17
0
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrEmpty(FechaIngresoDateTimePicker.Text))
            {
                paso = false;
                FechaIngresoDateTimePicker.Focus();
            }

            if (string.IsNullOrEmpty(CiudadTextBox.Text))
            {
                paso = false;
                CiudadTextBox.Focus();
            }

            if (!EmailValido(EmailTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Email No Valido !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
            }

            if (!NumeroValido(CelularTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Celular No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
            }

            if (!NumeroValido(TelefonoTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Teléfono No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
            }

            if (string.IsNullOrEmpty(DireccionTextBox.Text))
            {
                paso = false;
                DireccionTextBox.Focus();
            }

            if (string.IsNullOrEmpty(NombreCompaniaTextBox.Text.Replace("-", "")))
            {
                paso = false;
                NombreCompaniaTextBox.Focus();
            }

            if (string.IsNullOrEmpty(ApellidosTextBox.Text))
            {
                paso = false;
                ApellidosTextBox.Focus();
            }

            if (string.IsNullOrEmpty(NombreSuplidorTextBox.Text))
            {
                paso = false;
                NombreSuplidorTextBox.Focus();
            }
            return(paso);
        }
Exemplo n.º 18
0
        private bool validar()
        {
            bool paso = true;

            MyerrorProvider.Clear();
            if (ValidarCelular())
            {
                MyerrorProvider.SetError(CelularMaskedTextBox, "Ya existe un usuario con este celular");
                CelularMaskedTextBox.Focus();
                paso = false;
            }

            if (!EmailValido(EmailTextBox.Text))
            {
                MyerrorProvider.SetError(EmailTextBox, "Email no valido");
                EmailTextBox.Focus();
                paso = false;
            }
            if (ContraseñaTextBox.Text == NombresTextBox.Text)
            {
                MyerrorProvider.SetError(ContraseñaTextBox, "La contraseña no debe ser igual al nombre");
                ContraseñaTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(NombresTextBox.Text))
            {
                MyerrorProvider.SetError(NombresTextBox, "El campo no puede estar vacio");
                NombresTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyerrorProvider.SetError(EmailTextBox, "El campo no puedes estar vacio");
                EmailTextBox.Focus();
                paso = false;
            }
            if (ValidarNombre())
            {
                MyerrorProvider.SetError(NombresTextBox, "Ya existe un usuario con esa y ese nombre contraseña");
                NombresTextBox.Focus();


                paso = false;
            }
            if (string.IsNullOrWhiteSpace(UsuariocomboBox.Text))
            {
                MyerrorProvider.SetError(UsuariocomboBox, "El campo no puedes estar vacio");
                UsuariocomboBox.Focus();
                paso = false;
            }



            if (string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text))
            {
                MyerrorProvider.SetError(CelularMaskedTextBox, "El campo no puede estar vacio");
                CelularMaskedTextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(ContraseñaTextBox.Text))
            {
                MyerrorProvider.SetError(ContraseñaTextBox, "El campo no puede estar vacio");
                ContraseñaTextBox.Focus();
                paso = false;
            }
            if (FechadateTimePicker.Value > DateTime.Now)
            {
                MyerrorProvider.SetError(FechadateTimePicker, "La fecha no es correcta");
                FechadateTimePicker.Focus();
                paso = false;
            }
            return(paso);
        }
Exemplo n.º 19
0
        private bool Validar()
        {
            MyErrorProvider.Clear();

            bool paso = true;

            if (string.IsNullOrWhiteSpace(NombreTextBox.Text))
            {
                MyErrorProvider.SetError(NombreTextBox, "El campo nombre no puede estar vacío");
                NombreTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(TelefonoMaskedTextBox.Text.Replace("-", string.Empty)) || string.IsNullOrWhiteSpace(CelularMaskedTextBox.Text.Replace("-", string.Empty)))
            {
                MyErrorProvider.SetError(TelefonoMaskedTextBox, "Debe de suministrar un numero de telefono o celular");
                MyErrorProvider.SetError(CelularMaskedTextBox, "Debe de suministrar un numero de telefono o celular");
                TelefonoMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(CedulaMaskedTextBox.Text.Replace("-", string.Empty)))
            {
                MyErrorProvider.SetError(CedulaMaskedTextBox, "El campo cedula no puede estar vacío");
                CedulaMaskedTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(GeneroComboBox.Text))
            {
                MyErrorProvider.SetError(GeneroComboBox, "Debe de seleccionar su genero");
                GeneroComboBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(EmailTextBox.Text))
            {
                MyErrorProvider.SetError(EmailTextBox, "El campo email no puede estar vacío");
                EmailTextBox.Focus();
                paso = false;
            }

            if (string.IsNullOrWhiteSpace(DireccionTextBox.Text))
            {
                MyErrorProvider.SetError(DireccionTextBox, "El campo direccion no puede estar vacío");
                DireccionTextBox.Focus();
                paso = false;
            }

            if (ImagenPictureBox.Image == ImagenOriginal)
            {
                MyErrorProvider.SetError(InsertarImagenButton, "Debe de suministrar una imagen de usuario");
                InsertarImagenButton.Focus();
                paso = false;
            }

            if (!EmailTextBox.Text.Contains("@"))
            {
                MyErrorProvider.SetError(EmailTextBox, "El email debe de tener arroba '@'. ");
                EmailTextBox.Focus();
                paso = false;
            }

            return(paso);
        }
Exemplo n.º 20
0
        private bool Validar()
        {
            bool paso = true;

            if (string.IsNullOrEmpty(NombresTextBox.Text))
            {
                paso = false;
                MessageBox.Show("El campo Nombres no puede estar vacio", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                NombresTextBox.Focus();
            }

            if (string.IsNullOrEmpty(ApellidosTextBox.Text))
            {
                paso = false;
                MessageBox.Show("El campo Apellidos no puede estar vacio", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                ApellidosTextBox.Focus();
            }

            if (!CedulaValida(CedulaTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Cédula No Valida, Debe introducir solo números !!!\n Introducca la Cédula sin guiones.", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                CedulaTextBox.Focus();
            }

            if (SexoComboBox.SelectedItem == null)
            {
                paso = false;
                MessageBox.Show("Debe completar el campo sexo", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                SexoComboBox.Focus();
            }
            if (!NumeroValido(CelularTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Celular No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
            }

            if (!NumeroValido(TelefonoTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Teléfono No Valido, Debe introducir solo números !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
            }

            if (string.IsNullOrEmpty(DireccionTextBox.Text))
            {
                paso = false;
                MessageBox.Show("El campo Direccion no puede estar vacio", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                DireccionTextBox.Focus();
            }

            if (!EmailValido(EmailTextBox.Text))
            {
                paso = false;
                MessageBox.Show("Email No Valido !!!", "Informacion", MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
            }

            if (string.IsNullOrEmpty(FechaIngresoDateTimePicker.Text))
            {
                paso = false;
                MessageBox.Show("El campo Fecha Ingreso no puede estar vacio", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                FechaIngresoDateTimePicker.Focus();
            }

            if (string.IsNullOrEmpty(FechaNacimientoDateTimePicker.Text))
            {
                paso = false;
                MessageBox.Show("El campo fecha nacimiento no puede estar vacio", "Informacion", MessageBoxButton.OK, MessageBoxImage.Information);
                FechaNacimientoDateTimePicker.Focus();
            }

            return(paso);
        }
Exemplo n.º 21
0
        private void GuardarButton_Click(object sender, RoutedEventArgs e)
        {
            if (!Validar())
            {
                return;
            }

            if (AmigoIdTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Amigo Id) está vacío.\n\nAsigne un ID al Amigo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                AmigoIdTextBox.Text = "0";
                AmigoIdTextBox.Focus();
                AmigoIdTextBox.SelectAll();
                return;
            }

            if (NombresTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Nombres) está vacío.\n\nAsi Favor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                NombresTextBox.Clear();
                NombresTextBox.Focus();
                return;
            }

            if (ApellidosTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Apellidos) está vacío.\n\nAsi Favor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                ApellidosTextBox.Clear();
                ApellidosTextBox.Focus();
                return;
            }

            if (DireccionTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Direccion) está vacío.\n\nAsi Favor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                DireccionTextBox.Clear();
                DireccionTextBox.Focus();
                return;
            }

            if (TelefonoTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Teléfono) está vacío.\n\nFavor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Text = "0";
                TelefonoTextBox.Focus();
                TelefonoTextBox.SelectAll();
                return;
            }

            if (TelefonoTextBox.Text.Length != 10)
            {
                MessageBox.Show($"El Teféfono ({TelefonoTextBox.Text}) no es válido.\n\nEl Teléfono debe tener 10 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
                return;
            }

            if (CelularTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Celular) está vacío.\n\nFavor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Text = "0";
                CelularTextBox.Focus();
                CelularTextBox.SelectAll();
                return;
            }

            if (CelularTextBox.Text.Length != 10)
            {
                MessageBox.Show($"El Celular ({CelularTextBox.Text}) no es válido.\n\nEl Celular debe tener 10 dígitos (0-9).", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
                return;
            }

            if (EmailTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Email) está vacío.\n\nAsi Favor de llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Clear();
                EmailTextBox.Focus();
                return;
            }

            if (FechaNacimientoDatePicker.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El Campo (Fecha de Nacimiento) está vacío.\n\nFavor llenar este campo.", "Advertencia", MessageBoxButton.OK, MessageBoxImage.Warning);
                FechaNacimientoDatePicker.Focus();
                return;
            }

            var paso = AmigosBLL.Guardar(amigos);

            if (paso)
            {
                Limpiar();
                MessageBox.Show("Transacción Exitosa", "Éxito", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("Transacción Fallida", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 22
0
        private void EnterButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(FIOTextBox.Text))
            {
                //MessageBox.Show("Введите ФИО", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                ErrorText.Text = "Введите ФИО";
                FIOTextBox.Focus();
                return;
            }
            if (string.IsNullOrEmpty(LoginTextBox.Text))
            {
                //MessageBox.Show("Введите логин", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                ErrorText.Text = "Введите логин";
                LoginTextBox.Focus();
                return;
            }
            if (string.IsNullOrEmpty(EmailTextBox.Text))
            {
                //MessageBox.Show("Введите E-mail", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                ErrorText.Text = "Введите E-mail";
                EmailTextBox.Focus();
                return;
            }
            if (string.IsNullOrEmpty(PasswordTextBox.Password))
            {
                //MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                ErrorText.Text = "Введите пароль";
                PasswordTextBox.Focus();
                return;
            }

            if (PasswordTextBox.Password != SecondPasswordTextBox.Password)
            {
                //MessageBox.Show("Введённые пароли не совпадают", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                ErrorText.Text = "Введённые пароли не совпадают";
                SecondPasswordTextBox.Focus();
                return;
            }
            string mail = EmailTextBox.Text;

            if (!string.IsNullOrEmpty(mail))
            {
                if (!Regex.IsMatch(mail, @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                                   @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$"))
                {
                    //MessageBox.Show("Неверный формат электронной почты", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
                    ErrorText.Text = "Неверный формат электронной почты";
                    return;
                }
            }
            if (PasswordTextBox.Password == SecondPasswordTextBox.Password)
            {
                try
                {
                    if (Data.AddElement(new User
                    {
                        UserFIO = FIOTextBox.Text,
                        UserMail = EmailTextBox.Text,
                        UserLogin = LoginTextBox.Text,
                        UserPassword = Data.GetHashString(PasswordTextBox.Password),
                        isAdmin = false
                    }))
                    {
                        throw new Exception("Не удалось зарегистрироваться");
                    }
                    Data.UpdateUsers();
                    MessageBox.Show("Вы успешно зарегистрировались, используйте введённые данные для входа", "Успешно", MessageBoxButton.OK, MessageBoxImage.None);
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка");
                }
            }
        }
        public CreateAccount(IResolver resolver, CreateAccountViewModel viewModel)
        {
            InitializeComponent();

            _resolver  = resolver;
            _pbData    = _resolver.GetInstanceOf <IPBData>();
            _analytics = _resolver.GetInstanceOf <IInAppAnalytics>();
            _owner     = ((PBApp)Application.Current).FindWindow <LoginWindow>();

            Loaded += OnLoaded;

            TitleGrid.MouseLeftButtonDown += OnTitleGridMouseLeftButtonDown;
            EmailTextBox.KeyDown          += OnEmailTextBoxKeyDown;
            EmailTextBox.LostFocus        += (o, e) =>
            {
                if (_vm.IsEmailHasValue)
                {
                    _vm.ValidateEmail();
                }
            };

            _vm         = viewModel;
            DataContext = _vm;

            _vm.OnSubmit += (o, e) =>
            {
                _vm.ValidateEmail();

                SetTag(PasswordBoxObjectType.Master, _vm.IsValidMasterPassword);
                SetTag(PasswordBoxObjectType.Confirm, _vm.IsPasswordsEqual && _vm.IsValidMasterPassword);

                Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
                {
                    if (!_vm.IsValidEmail)
                    {
                        EmailTextBox.Focus();
                    }
                    else if (!_vm.IsValidMasterPassword)
                    {
                        _masterPasswordTextBox.Focus();
                    }
                    else if (!_vm.IsPasswordsEqual)
                    {
                        _confirmPasswordTextBox.Focus();
                    }
                }));
            };

            _vm.OnReset += (o, e) =>
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new Action(delegate()
                {
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsPasswordsEqual);
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidConfirmPassword);
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsConfirmPasswordHasValue);
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsEmailHasValue);
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidMasterPassword);
                    _vm.ResetValidation(CreateAccountViewModel.ValidationProperties.IsValidEmail);
                    Clear(PasswordBoxObjectType.Master, true);
                    Clear(PasswordBoxObjectType.Confirm, true);
                    EmailTextBox.Focus();
                    Keyboard.Focus(EmailTextBox);
                    EmailTextBox.Select(0, 0);
                }));
            };

            _owner.Topmost = false;

            EmailTextBox.Focus();
        }
        private bool Validar()
        {
            bool esValido = true;

            if (AmigoIdTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Producto Id está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                AmigoIdTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (NombresTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Descripcion está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                NombresTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (DireccionTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Precio está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                DireccionTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (CelularTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("UsuarioId está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (EmailTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("ITBIS está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (FechaDatePicker.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Fecha está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                FechaDatePicker.Focus();
                GuardarButton.IsEnabled = true;
            }

            return(esValido);
        }
        //Campo vacio
        private bool Validar()
        {
            bool esValido = true;

            if (ClienteIdTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("ClienteId está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                ClienteIdTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (NombresTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Nombres está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                NombresTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (ApellidosTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Apellidos está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                ApellidosTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (EmailTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Email está vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (TelefonoTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Telefono está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (CedulaTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Cedula está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                CedulaTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (DireccionTextBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Direccion está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                DireccionTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (SexoComboBox.Text.Length == 0)
            {
                esValido = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Sexo está vacia", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                SexoComboBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            return(esValido);
        }
Exemplo n.º 26
0
        /*
         * Event Handler for Confirm Button
         * -Validating FUll Name, Telephone Number, Email Address
         * -
         */
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            StreamWriter FileWriter;
            string       DynamicMessage;

            if (ProceedButton.Enabled == true)
            {
                MessageBox.Show("Please Confirm the Term by pressing Proceed button before confirming the membership");
            }
            else
            {
                if (NotNullValue(FullNameTextBox.Text, 1))
                {
                    //Full Name Regular Express Validation
                    //One Word is mandatory which includes Capital and small Letters
                    if (!Regex.IsMatch(FullNameTextBox.Text, @"^[A-Z a-z]*([A-Z a-z]*)+$"))
                    {
                        MessageBox.Show("Please enter valid name", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        FullNameTextBox.Focus();
                        FullNameTextBox.SelectAll();
                    }
                    else
                    {
                        if (NotNullValue(TelephoneTextBox.Text, 2))
                        {
                            //Telephone Number Reguar Expression Validation
                            //Grouping of 3 Number followed by space(not mandatory), then Next 3 numbers followed by space and then last 4 digits
                            if (!Regex.IsMatch(TelephoneTextBox.Text, @"^(\(?\d{3}\)*\s?\d{3}\s?\d{4})$"))
                            {
                                MessageBox.Show("Please enter valid telephone Number", "Invalid Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                TelephoneTextBox.Focus();
                                TelephoneTextBox.SelectAll();
                            }
                            else
                            {
                                if (NotNullValue(EmailTextBox.Text, 3))
                                {
                                    //Email Validation by Regular Expression
                                    bool CorrectEmail = Regex.IsMatch(EmailTextBox.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);

                                    if (!CorrectEmail)
                                    {
                                        MessageBox.Show("Please enter valid email address", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        EmailTextBox.Focus();
                                        EmailTextBox.SelectAll();
                                    }
                                    else
                                    {
                                        //If all the detais are correct, providing popup
                                        DynamicMessage = "Provided Details are as below:";
                                        DynamicMessage = DynamicMessage + "\n\nMembership Details :";
                                        DynamicMessage = DynamicMessage + "\nMembership ID      : " + MembershipIDLabel.Text;
                                        DynamicMessage = DynamicMessage + "\nConfirmed Term     : " + ConfirmedTerm.ToString();
                                        DynamicMessage = DynamicMessage + "\nMembership Fees  : " + ConfirmedTermTotal.ToString();
                                        DynamicMessage = DynamicMessage + "\n\nPersonal Details :";
                                        DynamicMessage = DynamicMessage + "\nFull Name              : " + FullNameTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nTelephone No.      : " + TelephoneTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\nEmail ID                 : " + EmailTextBox.Text;
                                        DynamicMessage = DynamicMessage + "\n\nDo you want to cofirm the Membership Details?";

                                        //Yes No Popup  Display decision
                                        DialogResult DR = MessageBox.Show(DynamicMessage, "Do you want to Continue?", MessageBoxButtons.YesNo);
                                        if (DR == DialogResult.Yes)
                                        {
                                            try
                                            {
                                                //Saving details of membership to the Database File
                                                FileWriter = File.AppendText(DatabaseFileName);
                                                FileWriter.WriteLine(MembershipIDLabel.Text);
                                                FileWriter.WriteLine(JoinDayLabel.Text);
                                                FileWriter.WriteLine(FullNameTextBox.Text);
                                                FileWriter.WriteLine(TelephoneTextBox.Text);
                                                FileWriter.WriteLine(EmailTextBox.Text);
                                                FileWriter.WriteLine(ConfirmedTerm.ToString());
                                                FileWriter.WriteLine(ConfirmedTermTotal.ToString("N2"));
                                                FileWriter.Close();
                                                //closing File Writer

                                                if (SummaryButton.Enabled == false)
                                                {
                                                    SummaryButton.Enabled = true;
                                                }
                                                if (SearchButton.Enabled == false)
                                                {
                                                    SearchButton.Enabled = true;
                                                }

                                                //Confirmation Message
                                                DynamicMessage = "Hello, " + FullNameTextBox.Text + "!. Welcome Aboard. :) \n Your Membership ID is : " + MembershipIDLabel.Text;
                                                MessageBox.Show(DynamicMessage, "Membership Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                                MembershipDetailsGroupBox.Visible = false;
                                                //Clearing Fields
                                                TermTextBox.Text =
                                                    ClientConfirmedTextBox.Text               =
                                                        PricePerMonthLabel.Text               =
                                                            PriceFullTermLabel.Text           =
                                                                PriceNextTermLabel.Text       =
                                                                    FullNameTextBox.Text      =
                                                                        TelephoneTextBox.Text =
                                                                            EmailTextBox.Text = "";
                                                //Enabling Buttons
                                                SearchButton.Enabled        =
                                                    SummaryButton.Enabled   =
                                                        TermTextBox.Enabled =
                                                            ClientConfirmedTextBox.Enabled = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                // Display an error message.
                                                MessageBox.Show(ex.Message);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            string Str = TransactionNumberTextBox.Text;
            double Num;
            bool   isNum = double.TryParse(Str, out Num);

            string Str2 = PhoneNumberTextBox.Text;
            double Num2;
            bool   isNum2 = double.TryParse(Str2, out Num2);

            if (isNum)
            {
                if (NameTextBox.Text != "")
                {
                    if (isNum2)
                    {
                        if (EmailTextBox.Text != "")
                        {
                            Message = ("Details of your transaction below\n" +
                                       "Transaction id: " + TransactionNumberTextBox.Text + "\n" +
                                       "Name: " + NameTextBox.Text + "\n" +
                                       "Phone Number: " + PhoneNumberTextBox.Text + "\n" +
                                       "Email: " + EmailTextBox.Text + "\n" + "Principal+interest: " +
                                       value + "\n" +
                                       "If the details above are correct and you wish to proceed click OK ");
                            Heading = "Confirmation";
                            MessageBoxButtons buttons     = MessageBoxButtons.OKCancel;
                            MessageBoxIcon    messageIcon = MessageBoxIcon.Question;
                            DialogResult      result;
                            result = MessageBox.Show(Message, Heading, buttons, messageIcon);
                            if (result == DialogResult.OK)
                            {
                                FileWriter();

                                MessageBox.Show("Clients details have been saved ", "Details Saved", MessageBoxButtons.OK);

                                TransCount     += TransactionNumberTextBox.Text + "\n";
                                InvestedAmount += decimal.Parse(InvestAmountTextBox.Text);
                                NumberOfTransactions++;

                                SummaryGB.Visible     = true;
                                SummaryButton.Visible = true;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Please enter your email address");
                            EmailTextBox.Focus();
                            EmailTextBox.SelectAll();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a phone number, Only numeric Input accepted");
                        PhoneNumberTextBox.Focus();
                        PhoneNumberTextBox.SelectAll();
                    }
                }
                else
                {
                    MessageBox.Show("Please enter your name");
                    NameTextBox.Focus();
                    NameTextBox.SelectAll();
                }
            }
            else
            {
                MessageBox.Show("Please enter a SIX digit unique key");
                TransactionNumberTextBox.Focus();
                TransactionNumberTextBox.SelectAll();
            }
        }
Exemplo n.º 28
0
        private bool validar()
        {
            bool paso = true;

            if (!Regex.IsMatch(AmigoIdTextBox.Text, @"^[0-9]+$"))
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("En este campo solo se permiten numeros", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                AmigoIdTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (new Contexto().Amigos.Any(p => p.Celular == CelularTextBox.Text) && Convert.ToInt32(AmigoIdTextBox.Text) == 0)
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Ya existe un Amigo con este numero", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (new Contexto().Amigos.Any(p => p.Nombres == NombresTextBox.Text) && Convert.ToInt32(AmigoIdTextBox.Text) == 0)
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Este nombre ya esxiste", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                NombresTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (!Regex.IsMatch(TelefonoTextBox.Text, @"^(809|829|849)+[0-9]{7}"))
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Numero invalido", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                TelefonoTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (!Regex.IsMatch(CelularTextBox.Text, @"^(809|829|849)+[0-9]{7}"))
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("ENumero invalido", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }



            if (TelefonoTextBox.Text == CelularTextBox.Text)
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("El numero del celular y el telefono no pueden ser iguales", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                CelularTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (new EmailAddressAttribute().IsValid(EmailTextBox.Text) == false)
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Este email noes valido", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                EmailTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }



            if (NombresTextBox.Text.Length == 0)
            {
                GuardarButton.IsEnabled = false;
                MessageBox.Show("El nombre no puede estar vacio", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                AmigoIdTextBox.Focus();
            }
            if (!Regex.IsMatch(NombresTextBox.Text, @"^[A-Za-z ]+$"))
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Los nombres solo tienen textos ", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                NombresTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }

            if (NombresTextBox.Text == "Mamaguevo")
            {
                paso = false;
                GuardarButton.IsEnabled = false;
                MessageBox.Show("Aqui no aceptamos comediantes crack", "Fallo",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                AmigoIdTextBox.Focus();
                GuardarButton.IsEnabled = true;
            }



            return(paso);
        }
Exemplo n.º 29
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     EmailTextBox.Focus();
 }
Exemplo n.º 30
0
 public LoginWindow()
 {
     InitializeComponent();
     EmailTextBox.Focus();
 }