private void button2_Click(object sender, EventArgs e)
        {
            if (Nombre.Text == "")
            {
                Nombre.Focus();
                MessageBox.Show("este campo esta vacio");
            }
            else if (Apellido.Text == "")

            {
                Apellido.Focus();
                MessageBox.Show("este campo esta vacio");
            }
            else if (Documento.Text == "")
            {
                Documento.Focus();
                MessageBox.Show("este campo esta vacio");
            }
            else if (Fecha_nacimiento.Text == "")
            {
                Fecha_nacimiento.Focus();
                MessageBox.Show("este campo esta vacio");
            }

            else
            {
            }
        }
        public RegisterView()
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
            CC.ReturnCommand       = new Command(() => Nombre.Focus());
            Nombre.ReturnCommand   = new Command(() => Apellido.Focus());
            Apellido.ReturnCommand = new Command(() => typeUser.Focus());

            btnLogin.Clicked += (sender, e) => {
                ((NavigationPage)this.Parent).PushAsync(new LoginView());
            };
        }
        // GotFocus y LostFocus para los WaterMakers de los TextBox

        private void comprobarFocus()
        {
            if (!string.IsNullOrEmpty(Nombre.Text))
            {
                NombreWM.Visibility = System.Windows.Visibility.Collapsed;
                Nombre.Visibility   = System.Windows.Visibility.Visible;
                Nombre.Focus();
            }
            if (!string.IsNullOrEmpty(Apellido.Text))
            {
                ApellidoWM.Visibility = System.Windows.Visibility.Collapsed;
                Apellido.Visibility   = System.Windows.Visibility.Visible;
                Apellido.Focus();
            }
            if (!string.IsNullOrEmpty(Telefono1.Text))
            {
                Telefono1WM.Visibility = System.Windows.Visibility.Collapsed;
                Telefono1.Visibility   = System.Windows.Visibility.Visible;
                Telefono1.Focus();
            }
            if (!string.IsNullOrEmpty(Telefono2.Text))
            {
                Telefono2WM.Visibility = System.Windows.Visibility.Collapsed;
                Telefono2.Visibility   = System.Windows.Visibility.Visible;
                Telefono2.Focus();
            }
            if (!string.IsNullOrEmpty(Direccion.Text))
            {
                DireccionWM.Visibility = System.Windows.Visibility.Collapsed;
                Direccion.Visibility   = System.Windows.Visibility.Visible;
                Direccion.Focus();
            }
            if (!string.IsNullOrEmpty(email.Text))
            {
                emailWM.Visibility = System.Windows.Visibility.Collapsed;
                email.Visibility   = System.Windows.Visibility.Visible;
                email.Focus();
            }
        }
 private void ApellidoWM_GotFocus(object sender, RoutedEventArgs e)
 {
     ApellidoWM.Visibility = System.Windows.Visibility.Collapsed;
     Apellido.Visibility   = System.Windows.Visibility.Visible;
     Apellido.Focus();
 }
        private async void EventModificar_Clicked(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.AppSettings["ipServer"];

            try
            {
                var id         = IdEmpleado.Text;
                var nombreV    = Nombre.Text;
                var apellidoV  = Apellido.Text;
                var sexoV      = Sexo.SelectedIndex;
                var direccionV = Direccion.Text;
                var telefonoV  = telefono.Text;
                var cedulaV    = cedula.Text;
                var fnV        = FN.Date;



                if (string.IsNullOrEmpty(nombreV))
                {
                    await DisplayAlert("Validacion", "Ingrese el nombre de Usuario", "Aceptar");

                    Nombre.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(apellidoV))
                {
                    await DisplayAlert("Validacion", "Ingresar el apellido del empleado", "Aceptar");

                    Apellido.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(direccionV))
                {
                    await DisplayAlert("Validacion", "Ingreser la direccion del empleado", "Aceptar");

                    Direccion.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(telefonoV))
                {
                    await DisplayAlert("Validacion", "Ingresar el numero telefonico del empleado", "Aceptar");

                    telefono.Focus();
                    return;
                }

                if (string.IsNullOrEmpty(cedulaV))
                {
                    await DisplayAlert("Validacion", "Ingreser la cedula del empleado", "Aceptar");

                    cedula.Focus();
                    return;
                }


                if (string.IsNullOrEmpty(fnV.ToString()))
                {
                    await DisplayAlert("Validacion", "Ingresar la fecha de nacimiento del usuario", "Aceptar");

                    FN.Focus();
                    return;
                }


                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(connectionString);

                var empleados = new Emple()
                {
                    EmpleadoID       = int.Parse(id),
                    Nombres          = nombreV,
                    Apellidos        = apellidoV,
                    Sexo             = (Sexo.SelectedIndex == 0) ? false : true,
                    Direccion        = direccionV,
                    Telefono         = telefonoV,
                    Fecha_Nacimiento = fnV,
                    Cedula           = cedulaV,
                    Edad             = DateTime.Now.Year - fnV.Value.Year
                };

                var           json          = JsonConvert.SerializeObject(empleados);
                StringContent stringContent = new StringContent(json, Encoding.UTF8, "application/json");

                var request = await client.PostAsync("/api/Empleados/modificar", stringContent);

                if (request.IsSuccessStatusCode)
                {
                    var responseJson = await request.Content.ReadAsStringAsync();

                    var respuesta = JsonConvert.DeserializeObject <Request>(responseJson);

                    if (respuesta.status)
                    {
                        await MaterialDialog.Instance.AlertAsync(message : "Usuario se modifico correctamente",
                                                                 title : "Registro",
                                                                 acknowledgementText : "Aceptar");
                    }
                    else
                    {
                        await MaterialDialog.Instance.AlertAsync(message : "Usuario no pudo modificarse correctamente",
                                                                 title : "Registro",
                                                                 acknowledgementText : "Aceptar");
                    }
                }
                else
                {
                    await MaterialDialog.Instance.AlertAsync(message : "Error",
                                                             title : "Error",
                                                             acknowledgementText : "Aceptar");
                }
            }
            catch (Exception ex)
            {
                await MaterialDialog.Instance.AlertAsync(message : ex.Message,
                                                         title : ex.Message,
                                                         acknowledgementText : "Aceptar");
            }
        }
Beispiel #6
0
        private bool validar()
        {
            if (Nombre.Text.Length == 0)
            {
                MessageBox.Show("El Campo nombre esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Nombre.Focus();
                return(false);
            }

            if (Apellido.Text.Length == 0)
            {
                MessageBox.Show("El Campo Apellido esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Apellido.Focus();
                return(false);
            }

            if (PaisID.Text.Length == 0 || PaisID.SelectedValue == null)
            {
                MessageBox.Show("El Campo Pais esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PaisID.Focus();
                return(false);
            }

            if (ProvinciaID.Text.Length == 0 || ProvinciaID.SelectedValue == null)
            {
                MessageBox.Show("El Campo Provincia esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ProvinciaID.Focus();
                return(false);
            }

            if (PerfilID.Text.Length == 0 || PerfilID.SelectedValue == null)
            {
                MessageBox.Show("El Campo Prefil esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PerfilID.Focus();
                return(false);
            }

            if (User.Text.Length == 0)
            {
                MessageBox.Show("El Campo Usuario esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                User.Focus();
                return(false);
            }

            if (PassWord.Text.Length == 0)
            {
                MessageBox.Show("El Campo Contraseña esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PassWord.Focus();
                return(false);
            }
            if (CofPassWord.Text.Length == 0)
            {
                MessageBox.Show("El Campo Confirmar Contraseña esta vacio", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CofPassWord.Focus();
                return(false);
            }

            if (CofPassWord.Text != PassWord.Text)
            {
                MessageBox.Show("La Contraseña no coinciden favor confirme", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PassWord.Focus();
                return(false);
            }

            return(true);
        }