Пример #1
0
        private void cerrarSesion()
        {
            string verificarSalida = MessageBox.Show("Deseas salir del sistema?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();

            if (verificarSalida == "Yes")
            {
                try
                {
                    sql.open();
                    sql.CheckOut(ID);
                    this.Hide();

                    moduloLogin moduloSeguridad = new moduloLogin();
                    moduloSeguridad.frm = this;
                    moduloSeguridad.ShowDialog();
                    this.Text = "Comercializadora y Distribuidora \"El Sol\" S.A. de C.V. - " + sql.getNombreUsuario(ID);

                    desabilitarTodosBotones();
                    sql.CheckIn(ID);

                    if (sql.getTipoUsuario(ID) == 1)
                    {
                        botonModuloEmpleados.Enabled = true;
                        botonModuloCatalogo.Enabled  = true;
                        botonModuloVentas.Enabled    = true;
                        botonModuloCompras.Enabled   = true;
                        botonModuloReportes.Enabled  = true;
                        botonCerrarSesion.Enabled    = true;
                    }
                    else
                    {
                        botonModuloCatalogo.Enabled = true;
                        botonModuloVentas.Enabled   = true;
                        botonCerrarSesion.Enabled   = true;
                    }

                    sql.close();
                    this.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("(" + ex.Source + "): " + ex.Message, "Error");
                }
            }
            else
            {
                // No hacer nada
            }
        }