Exemple #1
0
        /// <summary>
        /// Agrega un Usuario Cajero a la DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //Creo el Cajero.
            Cajero c = new Cajero();

            try
            {
                //Seteo sus datos.
                try
                {
                    c.Ci = Convert.ToInt32(txtCedula.Text);
                }
                catch (FormatException)
                {
                    MessageBox.Show("La Cédula debe contener 8 dígitos.", "Campo Inválido");
                    return;
                }
                catch (OverflowException) { MessageBox.Show("La Cédula debe contener 8 dígitos.", "Campo Inválido"); }
                c.Usu         = txtUsuario.Text;
                c.NomCompleto = txtNombreC.Text;
                c.HoraInicio  = CBHIHH.SelectedItem.ToString() + CBHIMM.SelectedItem.ToString();
                c.HoraFin     = CBHFHH.SelectedItem.ToString() + CBHFMM.SelectedItem.ToString();

                //Llamo a la fabrica para darlo de alta.
                SServicio.Alta(c, usuario);

                //Refresco el DataGrid con los nuevos datos.
                Refresh();
            }
            catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); }
        }
Exemple #2
0
        /// <summary>
        /// Agrega un Usuario Cajero a la DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //Creo el Cajero.
            Gerente g = new Gerente();

            try
            {
                //Seteo sus datos.
                try
                {
                    g.Ci = Convert.ToInt32(txtCedula.Text);
                }
                catch (FormatException) { throw new FormatException("El Documento debe contener 8 digitos."); }
                catch (OverflowException) { throw new OverflowException("El Documento debe contener 8 digitos."); }

                g.Usu         = txtUsuario.Text;
                g.NomCompleto = txtNombreC.Text;
                g.Email       = txtEmail.Text;

                //Llamo a la fabrica para darlo de alta.
                SServicio.Alta(g, usuario);

                //Refresco el DataGrid con los nuevos datos.
                Refresh();
            }
            catch (Exception ex) { lblError.Text = ex.Message; }
        }