domingo, 25 de octubre de 2015

CONTRASEÑA

namespace REPASO_EXAMEN_1_CON_CLAVE
{
    public partial class PRINCIPAL : Form
    {
        List<Producto> prod = new List<Producto>();
        int id = 0;
        public PRINCIPAL()
        {
            InitializeComponent();
        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {

            if ((string.IsNullOrEmpty(txtNombre.Text)) | (string.IsNullOrEmpty(txtFechaInicio.Text)) | (string.IsNullOrEmpty(txtFechaFin.Text)))
            {
                MessageBox.Show("ingrese campos");
            }
            else
            {

                DateTime fecha = DateTime.Parse(txtFechaInicio.Text);
                DateTime fecha2 = DateTime.Parse(txtFechaFin.Text);
                int comparacion = DateTime.Compare(fecha, fecha2);
                if (comparacion < 0)
                {
                    id++;
                    lblId.Text = Convert.ToString(id);
                    Producto produ = new Producto(id, txtNombre.Text, Convert.ToDateTime(txtFechaInicio.Text), Convert.ToDateTime(txtFechaFin.Text));
                    prod.Add(produ);
                    foreach (var item in prod)
                    {
                        lstLista.Items.Add(item);
                        MessageBox.Show("Datos guardados exitosamente");
                    }
                }

                else
                {
                    MessageBox.Show("Fechas ingresadas incorrectamente");



                }
            }
        }

        private void btnNuevo_Click(object sender, EventArgs e)
        {
            txtNombre.Clear();
            txtFechaInicio.Clear();
            txtFechaFin.Clear();
        }

        private void lstLista_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (Producto item in lstLista.SelectedItems)
            {
                lblId.Text = Convert.ToString(item.Id);
                txtNombre.Text = item.Nombre;
                txtFechaInicio.Text = Convert.ToString(item.FechaInicio);
                txtFechaFin.Text = Convert.ToString(item.FechaFin);
            }
        }
    }
}

---------------------

namespace REPASO_EXAMEN_1_CON_CLAVE
{
    public partial class Form1 : Form
    {
        List<Usuario> listaUsuarios = new List<Usuario>();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Usuario usu = new Usuario("mayra", "may", "may");
            Usuario usu1 = new Usuario("andres", "andy", "andy");
            listaUsuarios.Add(usu);
            listaUsuarios.Add(usu1);
        }

        private void btnIngresar_Click(object sender, EventArgs e)
        {
            Usuario usuarios = new Usuario(txtNombre.Text, txtLogin.Text, txtPassword.Text);
            listaUsuarios.Add(usuarios);
            foreach (var item in listaUsuarios)
            {
                if (item.Login == txtLogin.Text && item.Password == txtPassword.Text)
                {
                    MessageBox.Show("BIENVENIDO " + txtNombre.Text);
                    PRINCIPAL prin = new PRINCIPAL();
                    prin.ShowDialog();
                    break;
                }
                else
                {
                    if (item.Login != txtLogin.Text && item.Password != txtPassword.Text)
                    {
                        MessageBox.Show("NO REGISTRADO");
                        break;
                    }
                }
            }
        }
     
                }
            }
       
 

No hay comentarios:

Publicar un comentario