Beispiel #1
0
        public void editar(DataGridView dt, TextBox txtC, TextBox txtNom)
        {
            int id;

            id     = int.Parse(dt.CurrentRow.Cells[0].Value.ToString());
            mRoles = sRoles.editar(id);

            txtC.Text   = mRoles.Codigo;
            txtNom.Text = mRoles.Roll;
        }
Beispiel #2
0
        public List <Object> mostrarTabla(String buscar)
        {
            List <object> lista = new List <object>();

            Con = base.conexion();

            SQL = "spBuscarRoll";

            try
            {
                Con.Open();
                coman             = new MySqlCommand(SQL, Con);
                coman.CommandType = CommandType.StoredProcedure;
                coman.Parameters.AddWithValue("@cod", buscar);
                mSDR = coman.ExecuteReader();

                while (mSDR.Read())
                {
                    M_Roles obj = new M_Roles();
                    obj.Id     = int.Parse(mSDR[0].ToString());
                    obj.Codigo = mSDR[1].ToString();
                    obj.Roll   = mSDR[2].ToString();
                    lista.Add(obj);
                }
                coman.Parameters.Clear();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error " + ex.Message);
            }
            finally
            {
                try
                {
                    Con.Close();
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Message);
                }
            }

            return(lista);
        }
Beispiel #3
0
        public M_Roles editar(int id)
        {
            Con = base.conexion();
            SQL = "spListarIDRoll";
            M_Roles obj = new M_Roles();

            try
            {
                Con.Open();
                coman             = new MySqlCommand(SQL, Con);
                coman.CommandType = CommandType.StoredProcedure;
                coman.Parameters.AddWithValue("@i", id);

                mSDR = coman.ExecuteReader();

                while (mSDR.Read())
                {
                    obj.Id     = int.Parse(mSDR[0].ToString());
                    obj.Codigo = mSDR[1].ToString();
                    obj.Roll   = mSDR[2].ToString();
                }
                coman.Parameters.Clear();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                try
                {
                    Con.Close();
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Message);
                }
            }

            return(obj);
        }
Beispiel #4
0
        public bool actualizar(M_Roles obj)
        {
            Con = base.conexion();
            SQL = "spActualizarRoles";

            try
            {
                Con.Open();
                coman             = new MySqlCommand(SQL, Con);
                coman.CommandType = CommandType.StoredProcedure;

                coman.Parameters.AddWithValue("@cod", obj.Codigo);
                coman.Parameters.AddWithValue("@roll", obj.Roll);
                coman.Parameters.AddWithValue("@idR", obj.Id);

                coman.ExecuteNonQuery();
                coman.Parameters.Clear();
                return(true);
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error " + ex.Message.ToString());
                return(false);
            }
            finally
            {
                try
                {
                    Con.Close();
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine("Error " + ex.Message);
                }
            }
        }