Beispiel #1
0
        public string Insertar(DNivel Nivel)
        {
            string        rpta   = "";
            SqlConnection sqlCon = new SqlConnection();

            try
            {
                sqlCon.ConnectionString = Conexion.cn;
                sqlCon.Open();
                //Comandos
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection  = sqlCon;
                sqlCmd.CommandText = "sp_insertarNivel";
                sqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIdNivel = new SqlParameter();
                ParIdNivel.ParameterName = "@idNivel";
                ParIdNivel.SqlDbType     = SqlDbType.Int;
                ParIdNivel.Direction     = ParameterDirection.Output;
                sqlCmd.Parameters.Add(ParIdNivel);

                SqlParameter ParIdModulo = new SqlParameter();
                ParIdModulo.ParameterName = "@idModulo";
                ParIdModulo.SqlDbType     = SqlDbType.Int;
                ParIdModulo.Value         = Nivel.IdModulo;
                sqlCmd.Parameters.Add(ParIdModulo);

                SqlParameter ParIdTipoTrabajador = new SqlParameter();
                ParIdTipoTrabajador.ParameterName = "@idTipoTrabajador";
                ParIdTipoTrabajador.SqlDbType     = SqlDbType.Int;
                ParIdTipoTrabajador.Value         = Nivel.IdTipoTrabajador;
                sqlCmd.Parameters.Add(ParIdTipoTrabajador);

                rpta = sqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se ingresó el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (sqlCon.State == ConnectionState.Open)
                {
                    sqlCon.Close();
                }
            }
            return(rpta);
        }
Beispiel #2
0
        public string Eliminar(DNivel Nivel)
        {
            string        rpta   = "";
            SqlConnection sqlCon = new SqlConnection();

            try
            {
                sqlCon.ConnectionString = Conexion.cn;
                sqlCon.Open();
                //Comandos
                SqlCommand sqlCmd = new SqlCommand();
                sqlCmd.Connection  = sqlCon;
                sqlCmd.CommandText = "sp_eliminarNivel";
                sqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParIdNivel = new SqlParameter();
                ParIdNivel.ParameterName = "@idNivel";
                ParIdNivel.SqlDbType     = SqlDbType.Int;
                ParIdNivel.Value         = Nivel.IdNivel;
                sqlCmd.Parameters.Add(ParIdNivel);

                rpta = sqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se eliminó el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (sqlCon.State == ConnectionState.Open)
                {
                    sqlCon.Close();
                }
            }
            return(rpta);
        }