예제 #1
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            bool valida = this.ValidarCampos();

            if (valida)
            {
                CajeroDataSource cajer = new CajeroDataSource();
                cajer = this.GuardarDatos();
                bool existe = this.negocioCajero.ExisteCajero(cajer.UsuarioCajero);
                if (!existe)
                {
                    bool guardo = this.negocioCajero.GuardarCajero(cajer);
                    if (guardo)
                    {
                        MessageBox.Show("El cajero ha sido guardado", "GUARDAR", MessageBoxButtons.OK);
                        this.CamposLimpios();
                        this.CargarCajero();
                        this.CamposInactivos();
                    }
                }
                else
                {
                    MessageBox.Show("El usuario ya se encuentra registrado", "ERROR", MessageBoxButtons.OK);
                }
            }
        }
예제 #2
0
        private CajeroDataSource GuardarDatos()
        {
            if (this.botonclick.Equals("editar"))
            {
            }
            CajeroDataSource cajero = new CajeroDataSource();

            cajero.CodigoCajero  = int.Parse(txt_codigo.Text);
            cajero.NombreCajero  = txt_nombre.Text;
            cajero.UsuarioCajero = txt_user.Text;
            cajero.ClaveCajero   = txt_contra.Text;
            return(cajero);
        }
예제 #3
0
        public bool GuardarCajero(CajeroDataSource cajer)
        {
            bool   guardo = false;
            cajero cajer1 = new cajero();

            cajer1.usuariocaje = cajer.UsuarioCajero;
            cajer1.nombrecaje  = cajer.NombreCajero;
            cajer1.usuariocaje = cajer.UsuarioCajero;
            cajer1.clave       = cajer.ClaveCajero;
            try
            {
                guardo = this.persistencia.GuardarCajero(cajer1);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(guardo);
        }
예제 #4
0
        public List <CajeroDataSource> CargarCajero()
        {
            List <CajeroDataSource> caje = new List <CajeroDataSource>();

            try
            {
                var items = this.persistencia.CargarDatos();
                foreach (var item in items)
                {
                    CajeroDataSource cajer = new CajeroDataSource();
                    cajer.UsuarioCajero = item.usuariocaje;
                    cajer.NombreCajero  = item.nombrecaje;
                    caje.Add(cajer);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(caje);
        }